diff --git a/src/avalanche/proof.h b/src/avalanche/proof.h --- a/src/avalanche/proof.h +++ b/src/avalanche/proof.h @@ -39,8 +39,9 @@ public: explicit Stake() = default; - Stake(COutPoint utxo_, Amount amount_, uint32_t height_, CPubKey pubkey_) - : utxo(utxo_), amount(amount_), height(height_), + Stake(COutPoint utxo_, Amount amount_, uint32_t height_, bool is_coinbase, + CPubKey pubkey_) + : utxo(utxo_), amount(amount_), height(height_ << 1 | is_coinbase), pubkey(std::move(pubkey_)) {} ADD_SERIALIZE_METHODS; diff --git a/src/avalanche/proofbuilder.h b/src/avalanche/proofbuilder.h --- a/src/avalanche/proofbuilder.h +++ b/src/avalanche/proofbuilder.h @@ -34,7 +34,8 @@ : sequence(sequence_), expirationTime(expirationTime_), master(std::move(master_)) {} - bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, CKey key); + bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, + bool is_coinbase, CKey key); Proof build(); diff --git a/src/avalanche/proofbuilder.cpp b/src/avalanche/proofbuilder.cpp --- a/src/avalanche/proofbuilder.cpp +++ b/src/avalanche/proofbuilder.cpp @@ -25,13 +25,14 @@ } bool ProofBuilder::addUTXO(COutPoint utxo, Amount amount, uint32_t height, - CKey key) { + bool is_coinbase, CKey key) { if (!key.IsValid()) { return false; } - stakes.emplace_back(Stake(std::move(utxo), amount, height, key.GetPubKey()), - std::move(key)); + stakes.emplace_back( + Stake(std::move(utxo), amount, height, is_coinbase, key.GetPubKey()), + std::move(key)); return true; } @@ -70,7 +71,7 @@ ProofBuilder pb(0, std::numeric_limits::max(), CPubKey()); pb.addUTXO(COutPoint(TxId(GetRandHash()), 0), (int64_t(score) * COIN) / 100, - 0, std::move(key)); + 0, false, std::move(key)); return pb.build(); } diff --git a/src/avalanche/test/proof_tests.cpp b/src/avalanche/test/proof_tests.cpp --- a/src/avalanche/test/proof_tests.cpp +++ b/src/avalanche/test/proof_tests.cpp @@ -46,7 +46,7 @@ key.MakeNewKey(true); pb.addUTXO(COutPoint(TxId(GetRandHash()), InsecureRand32()), int64_t(InsecureRand32()) * COIN / 100, InsecureRand32(), - key); + InsecureRandBool(), key); } Proof p = pb.build(); diff --git a/src/avalanche/test/util.cpp b/src/avalanche/test/util.cpp --- a/src/avalanche/test/util.cpp +++ b/src/avalanche/test/util.cpp @@ -19,7 +19,7 @@ ProofBuilder pb(0, std::numeric_limits::max(), CPubKey()); pb.addUTXO(COutPoint(TxId(GetRandHash()), 0), (int64_t(score) * COIN) / 100, - 0, std::move(key)); + 0, false, std::move(key)); return pb.build(); } diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp --- a/src/rpc/avalanche.cpp +++ b/src/rpc/avalanche.cpp @@ -183,7 +183,7 @@ iscbparam.isNull() ? false : iscbparam.get_bool(); CKey key = DecodeSecret(find_value(stake, "privatekey").get_str()); - if (!pb.addUTXO(utxo, amount, uint32_t(height) << 1 | iscoinbase, + if (!pb.addUTXO(utxo, amount, uint32_t(height), iscoinbase, std::move(key))) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid private key"); }