Make CTransaction::nConsensusBranchId a std::optional
This commit is contained in:
parent
52568f58a8
commit
53828a38ba
|
@ -186,7 +186,7 @@ void CTransaction::UpdateHash() const
|
|||
|
||||
CTransaction::CTransaction() : nVersion(CTransaction::SPROUT_MIN_CURRENT_VERSION),
|
||||
fOverwintered(false), nVersionGroupId(0), nExpiryHeight(0),
|
||||
nConsensusBranchId(0),
|
||||
nConsensusBranchId(std::nullopt),
|
||||
vin(), vout(), nLockTime(0),
|
||||
valueBalance(0), vShieldedSpend(), vShieldedOutput(),
|
||||
orchardBundle(),
|
||||
|
|
|
@ -659,7 +659,7 @@ class CTransaction
|
|||
private:
|
||||
/// The consensus branch ID that this transaction commits to.
|
||||
/// Serialized from v5 onwards.
|
||||
uint32_t nConsensusBranchId;
|
||||
std::optional<uint32_t> nConsensusBranchId;
|
||||
OrchardBundle orchardBundle;
|
||||
|
||||
/** Memory only. */
|
||||
|
@ -781,7 +781,7 @@ public:
|
|||
|
||||
if (isZip225V5) {
|
||||
// Common Transaction Fields (plus version bytes above)
|
||||
READWRITE(nConsensusBranchId);
|
||||
READWRITE(*nConsensusBranchId);
|
||||
READWRITE(*const_cast<uint32_t*>(&nLockTime));
|
||||
READWRITE(*const_cast<uint32_t*>(&nExpiryHeight));
|
||||
|
||||
|
@ -870,7 +870,7 @@ public:
|
|||
return header;
|
||||
}
|
||||
|
||||
uint32_t GetConsensusBranchId() const {
|
||||
std::optional<uint32_t> GetConsensusBranchId() const {
|
||||
return nConsensusBranchId;
|
||||
}
|
||||
|
||||
|
@ -929,7 +929,7 @@ struct CMutableTransaction
|
|||
uint32_t nVersionGroupId;
|
||||
/// The consensus branch ID that this transaction commits to.
|
||||
/// Serialized from v5 onwards.
|
||||
uint32_t nConsensusBranchId;
|
||||
std::optional<uint32_t> nConsensusBranchId;
|
||||
std::vector<CTxIn> vin;
|
||||
std::vector<CTxOut> vout;
|
||||
uint32_t nLockTime;
|
||||
|
@ -991,7 +991,7 @@ struct CMutableTransaction
|
|||
|
||||
if (isZip225V5) {
|
||||
// Common Transaction Fields (plus version bytes above)
|
||||
READWRITE(nConsensusBranchId);
|
||||
READWRITE(*nConsensusBranchId);
|
||||
READWRITE(nLockTime);
|
||||
READWRITE(nExpiryHeight);
|
||||
|
||||
|
|
|
@ -477,7 +477,7 @@ void test_simple_joinsplit_invalidity(uint32_t consensusBranchId, CMutableTransa
|
|||
CValidationState state;
|
||||
|
||||
newTx.vJoinSplit.push_back(JSDescription());
|
||||
|
||||
|
||||
JSDescription *jsdesc = &newTx.vJoinSplit[0];
|
||||
jsdesc->vpub_old = -1;
|
||||
|
||||
|
@ -921,7 +921,7 @@ BOOST_AUTO_TEST_CASE(TxV5)
|
|||
SignatureHash(
|
||||
scriptCode, tx, nIn,
|
||||
SIGHASH_ALL,
|
||||
amount, tx.GetConsensusBranchId()
|
||||
amount, *tx.GetConsensusBranchId()
|
||||
).GetHex(),
|
||||
test[6].getValStr());
|
||||
|
||||
|
@ -930,7 +930,7 @@ BOOST_AUTO_TEST_CASE(TxV5)
|
|||
SignatureHash(
|
||||
scriptCode, tx, nIn,
|
||||
SIGHASH_NONE,
|
||||
amount, tx.GetConsensusBranchId()
|
||||
amount, *tx.GetConsensusBranchId()
|
||||
).GetHex(),
|
||||
test[7].getValStr());
|
||||
}
|
||||
|
@ -940,7 +940,7 @@ BOOST_AUTO_TEST_CASE(TxV5)
|
|||
SignatureHash(
|
||||
scriptCode, tx, nIn,
|
||||
SIGHASH_SINGLE,
|
||||
amount, tx.GetConsensusBranchId()
|
||||
amount, *tx.GetConsensusBranchId()
|
||||
).GetHex(),
|
||||
test[8].getValStr());
|
||||
}
|
||||
|
@ -950,7 +950,7 @@ BOOST_AUTO_TEST_CASE(TxV5)
|
|||
SignatureHash(
|
||||
scriptCode, tx, nIn,
|
||||
SIGHASH_ALL | SIGHASH_ANYONECANPAY,
|
||||
amount, tx.GetConsensusBranchId()
|
||||
amount, *tx.GetConsensusBranchId()
|
||||
).GetHex(),
|
||||
test[9].getValStr());
|
||||
}
|
||||
|
@ -960,7 +960,7 @@ BOOST_AUTO_TEST_CASE(TxV5)
|
|||
SignatureHash(
|
||||
scriptCode, tx, nIn,
|
||||
SIGHASH_NONE | SIGHASH_ANYONECANPAY,
|
||||
amount, tx.GetConsensusBranchId()
|
||||
amount, *tx.GetConsensusBranchId()
|
||||
).GetHex(),
|
||||
test[10].getValStr());
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ BOOST_AUTO_TEST_CASE(TxV5)
|
|||
SignatureHash(
|
||||
scriptCode, tx, nIn,
|
||||
SIGHASH_SINGLE | SIGHASH_ANYONECANPAY,
|
||||
amount, tx.GetConsensusBranchId()
|
||||
amount, *tx.GetConsensusBranchId()
|
||||
).GetHex(),
|
||||
test[11].getValStr());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue