Skip to content

Commit fa3843e

Browse files
authored
Merge pull request #9 from JoyStream/development
dev to master - v0.2.0
2 parents 75028ff + c02c5ae commit fa3843e

17 files changed

Lines changed: 96 additions & 52 deletions

conan_package/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ class PaymentChannelBase(ConanFile):
99
repo_https_url = "https://github.com/JoyStream/paymentchannel-cpp.git"
1010
description = "Conan recipe for paymentchannel-cpp library"
1111

12-
version="0.1.2"
12+
version="0.2.0"
1313
build_policy = "missing"
1414
settings = "os", "compiler", "build_type", "arch"
1515
generators = "cmake"
16-
requires = "Common/0.1.2@joystream/stable", "CoinCore/0.1.2@joystream/stable"
16+
requires = "Common/0.2.0@joystream/stable"
1717

1818
def source(self):
1919
raise Exception("abstract base package was exported")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class PaymnetChannelRelease(PaymentChannelBase):
1212

1313
exports_sources = "../sources*"
1414

15+
build_policy="always"
16+
1517
def source(self):
1618
os.mkdir("repo")
1719
shutil.move("sources", "repo/")

conan_package/test_package/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PROJECT(PackageTest)
2-
cmake_minimum_required(VERSION 3.1)
2+
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
33

44
set(CMAKE_CXX_STANDARD 11)
55

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include <paymentchannel/paymentchannel.hpp>
22

33
int main() {
4-
joystream::paymentchannel::Payor payor;
5-
joystream::paymentchannel::Payee payee;
4+
const Coin::Network network = Coin::Network::mainnet;
5+
joystream::paymentchannel::Payor payor(network);
6+
joystream::paymentchannel::Payee payee(network);
67
return 0;
78
}

example/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PROJECT(PackageTest)
2-
cmake_minimum_required(VERSION 3.1)
2+
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
33

44
set(CMAKE_CXX_STANDARD 11)
55

example/example.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ int main(int argc, char* argv[]) {
1111
const uint64_t settlementFee = 2500;
1212
const uint64_t refundFee = 2500;
1313
const uint64_t refundAmount = funds - refundFee;
14+
const Coin::Network network = Coin::Network::mainnet;
1415

1516
Coin::RelativeLockTime refundLockTime = Coin::RelativeLockTime::fromBlockUnits(5);
1617
const Coin::typesafeOutPoint anchor;
@@ -19,7 +20,7 @@ int main(int argc, char* argv[]) {
1920
const Coin::PublicKey payeeContractPk = Coin::PrivateKey::generate().toPublicKey();
2021
const Coin::PubKeyHash payeeFinalPkHash;
2122

22-
joystream::paymentchannel::Payor payor(price, numberOfPaymentsMade, funds, settlementFee, refundLockTime, anchor, payorContractKeyPair, payorFinalPkHash, payeeContractPk, payeeFinalPkHash);
23+
joystream::paymentchannel::Payor payor(price, numberOfPaymentsMade, funds, settlementFee, refundLockTime, anchor, payorContractKeyPair, payorFinalPkHash, payeeContractPk, payeeFinalPkHash, network);
2324

2425
auto refund = payor.refund();
2526

sources/include/paymentchannel/ContractTransactionBuilder.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace Coin {
1919
class Transaction;
20+
enum class Network;
2021
}
2122

2223
namespace joystream {
@@ -44,15 +45,16 @@ class ContractTransactionBuilder {
4445
* is also signed if funding was provided.
4546
* @return contract transaction
4647
*/
47-
Coin::Transaction transaction() const;
48+
Coin::Transaction transaction(Coin::Network) const;
4849

4950
// Transaction fee for contract with given terms
50-
static uint64_t totalFee(uint32_t numberOfCommitments, bool hasChange, uint64_t feePerKb, uint64_t sizeOfAllInputs);
51+
static uint64_t totalFee(uint32_t numberOfCommitments, bool hasChange, uint64_t feePerKb, uint64_t sizeOfAllInputs,
52+
Coin::Network);
5153

5254
private:
5355

5456
// The size of a contract transaction with given terms
55-
static uint64_t transactionSize(uint32_t, bool);
57+
static uint64_t transactionSize(uint32_t, bool, Coin::Network);
5658

5759
// Funding contract
5860
boost::optional<Coin::UnspentOutputSet> _funding;

sources/include/paymentchannel/Payee.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace paymentchannel {
3636

3737
public:
3838

39-
Payee();
39+
Payee(Coin::Network network);
4040

4141
Payee(uint64_t numberOfPaymentsMade,
4242
Coin::RelativeLockTime lockTime,
@@ -48,7 +48,8 @@ namespace paymentchannel {
4848
const Coin::PubKeyHash & payeeFinalPkHash,
4949
const Coin::PublicKey & payorContractPk,
5050
const Coin::PubKeyHash & payorFinalPkHash,
51-
const Coin::Signature & lastValidPayorPaymentSignature);
51+
const Coin::Signature & lastValidPayorPaymentSignature,
52+
Coin::Network network);
5253

5354
// Attempts to register payment if signature is valid
5455
// ==================================================
@@ -145,6 +146,7 @@ namespace paymentchannel {
145146
// The last valid payment signature received, corresponds to _numberOfPaymentsMade
146147
Coin::Signature _lastValidPayorPaymentSignature;
147148

149+
Coin::Network _network;
148150
};
149151

150152
}

sources/include/paymentchannel/Payor.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace paymentchannel {
3838

3939
public:
4040

41-
Payor();
41+
Payor(Coin::Network network);
4242

4343
Payor(uint64_t price,
4444
uint64_t numberOfPaymentsMade,
@@ -49,7 +49,8 @@ namespace paymentchannel {
4949
const Coin::KeyPair & payorContractKeyPair,
5050
const Coin::PubKeyHash & payorFinalPkHash,
5151
const Coin::PublicKey & payeeContractPk,
52-
const Coin::PubKeyHash & payeeFinalPkHash);
52+
const Coin::PubKeyHash & payeeFinalPkHash,
53+
Coin::Network network);
5354

5455
// Commitment for channel
5556
Commitment commitment() const;
@@ -132,6 +133,8 @@ namespace paymentchannel {
132133

133134
// Controls payee payments, received in sign_refund.pk
134135
Coin::PubKeyHash _payeeFinalPkHash;
136+
137+
Coin::Network _network;
135138
};
136139

137140
}

sources/include/paymentchannel/Settlement.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include <paymentchannel/Commitment.hpp>
1212
#include <common/Payment.hpp>
1313
#include <common/typesafeOutPoint.hpp>
14-
#include <common/Utilities.hpp>
1514

1615
namespace Coin {
1716
class Transaction;
1817
class typesafeOutPoint;
1918
class TransactionSignature;
2019
class PrivateKey;
20+
class SigHashType;
2121
}
2222

2323
namespace joystream {
@@ -30,11 +30,13 @@ namespace paymentchannel {
3030
Settlement(const Coin::typesafeOutPoint & contractOutPoint,
3131
const Commitment & commitment,
3232
const Coin::Payment & toPayor,
33-
const Coin::Payment & toPayee);
33+
const Coin::Payment & toPayee,
34+
Coin::Network network);
3435

3536
Settlement(const Coin::typesafeOutPoint & contractOutPoint,
3637
const Commitment & commitment,
37-
const Coin::Payment & toPayor);
38+
const Coin::Payment & toPayor,
39+
Coin::Network network);
3840

3941
// Creates to appropriate settlement given the dust
4042
// limit and transaction fee
@@ -43,7 +45,8 @@ namespace paymentchannel {
4345
const Coin::PubKeyHash & payorPkHash,
4446
const Coin::PubKeyHash & payeePkHash,
4547
uint64_t paid,
46-
uint64_t fee);
48+
uint64_t fee,
49+
Coin::Network network);
4750

4851
// Implicit fee by comparing commitment and (payor + payee) payment
4952
int64_t fee() const;
@@ -90,10 +93,11 @@ namespace paymentchannel {
9093

9194
// Payment back to payor
9295
Coin::Payment _toPayor;
96+
97+
Coin::Network _network;
9398
};
9499

95100
}
96101
}
97102

98103
#endif // PAYMENT_CHANNEL_SETTLEMENT_HPP
99-

0 commit comments

Comments
 (0)