aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormerge-script <fanquake@gmail.com>2024-06-12 10:32:31 +0100
committermerge-script <fanquake@gmail.com>2024-06-12 10:32:31 +0100
commit5ee6b76c69d51158c13f6ad9ea1b264372e58d4d (patch)
treefeab6f5725952448a30ed3643fce8f2bc17f0927 /src
parent416e26c1db7769e5de05fae1c07c47991a3447c2 (diff)
parent429ec1aaaaafab150f11e27fcf132a99b57c4fc7 (diff)
Merge bitcoin/bitcoin#29325: consensus: Store transaction nVersion as uint32_t
429ec1aaaaafab150f11e27fcf132a99b57c4fc7 refactor: Rename CTransaction::nVersion to version (Ava Chow) 27e70f1f5be1f536f2314cd2ea42b4f80d927fbd consensus: Store transaction nVersion as uint32_t (Ava Chow) Pull request description: Given that the use of a transaction's nVersion is always as an unsigned int, it doesn't make sense to store it as signed and then cast it to unsigned everywhere it is used and displayed. Since a few alternative implementations have recently been revealed to have made an error with this signedness that would have resulted in consensus failure, I think it makes sense for us to just make this always unsigned to make it clear that the version is treated as unsigned. This would also help us avoid future potential issues with signedness of this value. I believe that this is safe and does not actually change what transactions would or would not be considered both standard and consensus valid. Within consensus, the only use of the version in consensus is in BIP68 validation which was already casting it to uint32_t. Within policy, although it is used as a signed int for the transaction version number check, I do not think that this change would change standardness. Standard transactions are limited to the range [1, 2]. Negative numbers would have fallen under the < 1 condition, but by making it unsigned, they are still non-standard under the > 2 condition. Unsigned and signed ints are serialized and unserialized the same way so there is no change in serialization. ACKs for top commit: maflcko: ACK 429ec1aaaaafab150f11e27fcf132a99b57c4fc7 🐿 glozow: ACK 429ec1aaaa shaavan: ACK 429ec1aaaaafab150f11e27fcf132a99b57c4fc7 💯 Tree-SHA512: 0bcd92a245d7d16c3665d2d4e815a4ef28207ad4a1fb46c6f0203cdafeab1b82c4e95e4bdce7805d80a4f4a46074f6542abad708e970550d38a00d759e3dcef1
Diffstat (limited to 'src')
-rw-r--r--src/bitcoin-tx.cpp6
-rw-r--r--src/compressor.h4
-rw-r--r--src/consensus/tx_verify.cpp6
-rw-r--r--src/core_write.cpp4
-rw-r--r--src/kernel/chainparams.cpp2
-rw-r--r--src/policy/policy.cpp2
-rw-r--r--src/policy/policy.h2
-rw-r--r--src/policy/v3_policy.cpp24
-rw-r--r--src/policy/v3_policy.h4
-rw-r--r--src/primitives/transaction.cpp12
-rw-r--r--src/primitives/transaction.h14
-rw-r--r--src/rpc/rawtransaction.cpp8
-rw-r--r--src/script/interpreter.cpp10
-rw-r--r--src/script/miniscript.h2
-rw-r--r--src/signet.cpp4
-rw-r--r--src/test/data/tx_invalid.json2
-rw-r--r--src/test/fuzz/package_eval.cpp2
-rw-r--r--src/test/fuzz/tx_pool.cpp2
-rw-r--r--src/test/fuzz/util.cpp4
-rw-r--r--src/test/hash_tests.cpp4
-rw-r--r--src/test/miner_tests.cpp4
-rw-r--r--src/test/sighash_tests.cpp2
-rw-r--r--src/test/sigopcount_tests.cpp4
-rw-r--r--src/test/transaction_tests.cpp20
-rw-r--r--src/test/txpackage_tests.cpp4
-rw-r--r--src/test/txvalidation_tests.cpp8
-rw-r--r--src/test/txvalidationcache_tests.cpp14
-rw-r--r--src/test/util/transaction_utils.cpp4
-rw-r--r--src/test/util/txmempool.cpp6
-rw-r--r--src/validation.cpp6
-rw-r--r--src/wallet/spend.cpp8
31 files changed, 96 insertions, 102 deletions
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index cfac50e090..97096dfe3c 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -203,12 +203,12 @@ static CAmount ExtractAndValidateValue(const std::string& strValue)
static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
{
- int64_t newVersion;
- if (!ParseInt64(cmdVal, &newVersion) || newVersion < 1 || newVersion > TX_MAX_STANDARD_VERSION) {
+ uint32_t newVersion;
+ if (!ParseUInt32(cmdVal, &newVersion) || newVersion < 1 || newVersion > TX_MAX_STANDARD_VERSION) {
throw std::runtime_error("Invalid TX version requested: '" + cmdVal + "'");
}
- tx.nVersion = (int) newVersion;
+ tx.version = newVersion;
}
static void MutateTxLocktime(CMutableTransaction& tx, const std::string& cmdVal)
diff --git a/src/compressor.h b/src/compressor.h
index 0968454679..a0970c595e 100644
--- a/src/compressor.h
+++ b/src/compressor.h
@@ -55,8 +55,8 @@ struct ScriptCompression
{
/**
* make this static for now (there are only 6 special scripts defined)
- * this can potentially be extended together with a new nVersion for
- * transactions, in which case this value becomes dependent on nVersion
+ * this can potentially be extended together with a new version for
+ * transactions, in which case this value becomes dependent on version
* and nHeight of the enclosing transaction.
*/
static const unsigned int nSpecialScripts = 6;
diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp
index 154146f08d..95466b759c 100644
--- a/src/consensus/tx_verify.cpp
+++ b/src/consensus/tx_verify.cpp
@@ -48,11 +48,7 @@ std::pair<int, int64_t> CalculateSequenceLocks(const CTransaction &tx, int flags
int nMinHeight = -1;
int64_t nMinTime = -1;
- // tx.nVersion is signed integer so requires cast to unsigned otherwise
- // we would be doing a signed comparison and half the range of nVersion
- // wouldn't support BIP 68.
- bool fEnforceBIP68 = static_cast<uint32_t>(tx.nVersion) >= 2
- && flags & LOCKTIME_VERIFY_SEQUENCE;
+ bool fEnforceBIP68 = tx.version >= 2 && flags & LOCKTIME_VERIFY_SEQUENCE;
// Do not enforce sequence numbers as a relative lock time
// unless we have been instructed to
diff --git a/src/core_write.cpp b/src/core_write.cpp
index 3a2bf865fc..253dfde100 100644
--- a/src/core_write.cpp
+++ b/src/core_write.cpp
@@ -174,9 +174,7 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
entry.pushKV("txid", tx.GetHash().GetHex());
entry.pushKV("hash", tx.GetWitnessHash().GetHex());
- // Transaction version is actually unsigned in consensus checks, just signed in memory,
- // so cast to unsigned before giving it to the user.
- entry.pushKV("version", static_cast<int64_t>(static_cast<uint32_t>(tx.nVersion)));
+ entry.pushKV("version", tx.version);
entry.pushKV("size", tx.GetTotalSize());
entry.pushKV("vsize", (GetTransactionWeight(tx) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR);
entry.pushKV("weight", GetTransactionWeight(tx));
diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp
index 94b8a44323..af02c6963b 100644
--- a/src/kernel/chainparams.cpp
+++ b/src/kernel/chainparams.cpp
@@ -29,7 +29,7 @@
static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
CMutableTransaction txNew;
- txNew.nVersion = 1;
+ txNew.version = 1;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp
index d8b4b907e4..e84a8428bf 100644
--- a/src/policy/policy.cpp
+++ b/src/policy/policy.cpp
@@ -93,7 +93,7 @@ bool IsStandard(const CScript& scriptPubKey, const std::optional<unsigned>& max_
bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, std::string& reason)
{
- if (tx.nVersion > TX_MAX_STANDARD_VERSION || tx.nVersion < 1) {
+ if (tx.version > TX_MAX_STANDARD_VERSION || tx.version < 1) {
reason = "version";
return false;
}
diff --git a/src/policy/policy.h b/src/policy/policy.h
index 20d632183a..a82488a28c 100644
--- a/src/policy/policy.h
+++ b/src/policy/policy.h
@@ -131,7 +131,7 @@ bool IsStandard(const CScript& scriptPubKey, const std::optional<unsigned>& max_
// Changing the default transaction version requires a two step process: first
// adapting relay policy by bumping TX_MAX_STANDARD_VERSION, and then later
// allowing the new transaction version in the wallet/RPC.
-static constexpr decltype(CTransaction::nVersion) TX_MAX_STANDARD_VERSION{3};
+static constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3};
/**
* Check for standard transaction types
diff --git a/src/policy/v3_policy.cpp b/src/policy/v3_policy.cpp
index 9151d97ac2..bcf0b2b236 100644
--- a/src/policy/v3_policy.cpp
+++ b/src/policy/v3_policy.cpp
@@ -43,13 +43,13 @@ struct ParentInfo {
const Txid& m_txid;
/** Wtxid used for debug string */
const Wtxid& m_wtxid;
- /** nVersion used to check inheritance of v3 and non-v3 */
- decltype(CTransaction::nVersion) m_version;
+ /** version used to check inheritance of v3 and non-v3 */
+ decltype(CTransaction::version) m_version;
/** If parent is in mempool, whether it has any descendants in mempool. */
bool m_has_mempool_descendant;
ParentInfo() = delete;
- ParentInfo(const Txid& txid, const Wtxid& wtxid, decltype(CTransaction::nVersion) version, bool has_mempool_descendant) :
+ ParentInfo(const Txid& txid, const Wtxid& wtxid, decltype(CTransaction::version) version, bool has_mempool_descendant) :
m_txid{txid}, m_wtxid{wtxid}, m_version{version},
m_has_mempool_descendant{has_mempool_descendant}
{}
@@ -66,7 +66,7 @@ std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t v
const auto in_package_parents{FindInPackageParents(package, ptx)};
// Now we have all ancestors, so we can start checking v3 rules.
- if (ptx->nVersion == TRUC_VERSION) {
+ if (ptx->version == TRUC_VERSION) {
// SingleV3Checks should have checked this already.
if (!Assume(vsize <= V3_MAX_VSIZE)) {
return strprintf("v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
@@ -94,14 +94,14 @@ std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t v
Assume(mempool_parent->GetCountWithDescendants() == 1);
return ParentInfo{mempool_parent->GetTx().GetHash(),
mempool_parent->GetTx().GetWitnessHash(),
- mempool_parent->GetTx().nVersion,
+ mempool_parent->GetTx().version,
/*has_mempool_descendant=*/mempool_parent->GetCountWithDescendants() > 1};
} else {
auto& parent_index = in_package_parents.front();
auto& package_parent = package.at(parent_index);
return ParentInfo{package_parent->GetHash(),
package_parent->GetWitnessHash(),
- package_parent->nVersion,
+ package_parent->version,
/*has_mempool_descendant=*/false};
}
}();
@@ -146,14 +146,14 @@ std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t v
} else {
// Non-v3 transactions cannot have v3 parents.
for (auto it : mempool_ancestors) {
- if (it->GetTx().nVersion == TRUC_VERSION) {
+ if (it->GetTx().version == TRUC_VERSION) {
return strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
it->GetSharedTx()->GetHash().ToString(), it->GetSharedTx()->GetWitnessHash().ToString());
}
}
for (const auto& index: in_package_parents) {
- if (package.at(index)->nVersion == TRUC_VERSION) {
+ if (package.at(index)->version == TRUC_VERSION) {
return strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
ptx->GetHash().ToString(),
ptx->GetWitnessHash().ToString(),
@@ -172,12 +172,12 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
{
// Check v3 and non-v3 inheritance.
for (const auto& entry : mempool_ancestors) {
- if (ptx->nVersion != TRUC_VERSION && entry->GetTx().nVersion == TRUC_VERSION) {
+ if (ptx->version != TRUC_VERSION && entry->GetTx().version == TRUC_VERSION) {
return std::make_pair(strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
entry->GetSharedTx()->GetHash().ToString(), entry->GetSharedTx()->GetWitnessHash().ToString()),
nullptr);
- } else if (ptx->nVersion == TRUC_VERSION && entry->GetTx().nVersion != TRUC_VERSION) {
+ } else if (ptx->version == TRUC_VERSION && entry->GetTx().version != TRUC_VERSION) {
return std::make_pair(strprintf("v3 tx %s (wtxid=%s) cannot spend from non-v3 tx %s (wtxid=%s)",
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
entry->GetSharedTx()->GetHash().ToString(), entry->GetSharedTx()->GetWitnessHash().ToString()),
@@ -189,8 +189,8 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
static_assert(V3_ANCESTOR_LIMIT == 2);
static_assert(V3_DESCENDANT_LIMIT == 2);
- // The rest of the rules only apply to transactions with nVersion=3.
- if (ptx->nVersion != TRUC_VERSION) return std::nullopt;
+ // The rest of the rules only apply to transactions with version=3.
+ if (ptx->version != TRUC_VERSION) return std::nullopt;
if (vsize > V3_MAX_VSIZE) {
return std::make_pair(strprintf("v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
diff --git a/src/policy/v3_policy.h b/src/policy/v3_policy.h
index 84dadd8719..90eaeda46f 100644
--- a/src/policy/v3_policy.h
+++ b/src/policy/v3_policy.h
@@ -15,9 +15,9 @@
#include <set>
#include <string>
-// This module enforces rules for BIP 431 TRUC transactions (with nVersion=3) which help make
+// This module enforces rules for BIP 431 TRUC transactions (with version=3) which help make
// RBF abilities more robust.
-static constexpr decltype(CTransaction::nVersion) TRUC_VERSION{3};
+static constexpr decltype(CTransaction::version) TRUC_VERSION{3};
// v3 only allows 1 parent and 1 child when unconfirmed.
/** Maximum number of transactions including an unconfirmed tx and its descendants. */
diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp
index b4a860dd9e..25b961a66b 100644
--- a/src/primitives/transaction.cpp
+++ b/src/primitives/transaction.cpp
@@ -63,8 +63,8 @@ std::string CTxOut::ToString() const
return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, HexStr(scriptPubKey).substr(0, 30));
}
-CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERSION), nLockTime(0) {}
-CMutableTransaction::CMutableTransaction(const CTransaction& tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nLockTime(tx.nLockTime) {}
+CMutableTransaction::CMutableTransaction() : version{CTransaction::CURRENT_VERSION}, nLockTime{0} {}
+CMutableTransaction::CMutableTransaction(const CTransaction& tx) : vin(tx.vin), vout(tx.vout), version{tx.version}, nLockTime{tx.nLockTime} {}
Txid CMutableTransaction::GetHash() const
{
@@ -92,8 +92,8 @@ Wtxid CTransaction::ComputeWitnessHash() const
return Wtxid::FromUint256((HashWriter{} << TX_WITH_WITNESS(*this)).GetHash());
}
-CTransaction::CTransaction(const CMutableTransaction& tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nLockTime(tx.nLockTime), m_has_witness{ComputeHasWitness()}, hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
-CTransaction::CTransaction(CMutableTransaction&& tx) : vin(std::move(tx.vin)), vout(std::move(tx.vout)), nVersion(tx.nVersion), nLockTime(tx.nLockTime), m_has_witness{ComputeHasWitness()}, hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
+CTransaction::CTransaction(const CMutableTransaction& tx) : vin(tx.vin), vout(tx.vout), version{tx.version}, nLockTime{tx.nLockTime}, m_has_witness{ComputeHasWitness()}, hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
+CTransaction::CTransaction(CMutableTransaction&& tx) : vin(std::move(tx.vin)), vout(std::move(tx.vout)), version{tx.version}, nLockTime{tx.nLockTime}, m_has_witness{ComputeHasWitness()}, hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
CAmount CTransaction::GetValueOut() const
{
@@ -115,9 +115,9 @@ unsigned int CTransaction::GetTotalSize() const
std::string CTransaction::ToString() const
{
std::string str;
- str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n",
+ str += strprintf("CTransaction(hash=%s, ver=%u, vin.size=%u, vout.size=%u, nLockTime=%u)\n",
GetHash().ToString().substr(0,10),
- nVersion,
+ version,
vin.size(),
vout.size(),
nLockTime);
diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h
index 976542cfae..bf86562886 100644
--- a/src/primitives/transaction.h
+++ b/src/primitives/transaction.h
@@ -197,13 +197,13 @@ static constexpr TransactionSerParams TX_NO_WITNESS{.allow_witness = false};
/**
* Basic transaction serialization format:
- * - int32_t nVersion
+ * - uint32_t version
* - std::vector<CTxIn> vin
* - std::vector<CTxOut> vout
* - uint32_t nLockTime
*
* Extended transaction serialization format:
- * - int32_t nVersion
+ * - uint32_t version
* - unsigned char dummy = 0x00
* - unsigned char flags (!= 0)
* - std::vector<CTxIn> vin
@@ -217,7 +217,7 @@ void UnserializeTransaction(TxType& tx, Stream& s, const TransactionSerParams& p
{
const bool fAllowWitness = params.allow_witness;
- s >> tx.nVersion;
+ s >> tx.version;
unsigned char flags = 0;
tx.vin.clear();
tx.vout.clear();
@@ -257,7 +257,7 @@ void SerializeTransaction(const TxType& tx, Stream& s, const TransactionSerParam
{
const bool fAllowWitness = params.allow_witness;
- s << tx.nVersion;
+ s << tx.version;
unsigned char flags = 0;
// Consistency check
if (fAllowWitness) {
@@ -296,7 +296,7 @@ class CTransaction
{
public:
// Default transaction version.
- static const int32_t CURRENT_VERSION=2;
+ static const uint32_t CURRENT_VERSION{2};
// The local variables are made const to prevent unintended modification
// without updating the cached hash value. However, CTransaction is not
@@ -305,7 +305,7 @@ public:
// structure, including the hash.
const std::vector<CTxIn> vin;
const std::vector<CTxOut> vout;
- const int32_t nVersion;
+ const uint32_t version;
const uint32_t nLockTime;
private:
@@ -378,7 +378,7 @@ struct CMutableTransaction
{
std::vector<CTxIn> vin;
std::vector<CTxOut> vout;
- int32_t nVersion;
+ uint32_t version;
uint32_t nLockTime;
explicit CMutableTransaction();
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index 2ecaeeaf40..f45c921c3c 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -1748,8 +1748,8 @@ static RPCHelpMan joinpsbts()
}
psbtxs.push_back(psbtx);
// Choose the highest version number
- if (static_cast<uint32_t>(psbtx.tx->nVersion) > best_version) {
- best_version = static_cast<uint32_t>(psbtx.tx->nVersion);
+ if (psbtx.tx->version > best_version) {
+ best_version = psbtx.tx->version;
}
// Choose the lowest lock time
if (psbtx.tx->nLockTime < best_locktime) {
@@ -1760,7 +1760,7 @@ static RPCHelpMan joinpsbts()
// Create a blank psbt where everything will be added
PartiallySignedTransaction merged_psbt;
merged_psbt.tx = CMutableTransaction();
- merged_psbt.tx->nVersion = static_cast<int32_t>(best_version);
+ merged_psbt.tx->version = best_version;
merged_psbt.tx->nLockTime = best_locktime;
// Merge
@@ -1795,7 +1795,7 @@ static RPCHelpMan joinpsbts()
PartiallySignedTransaction shuffled_psbt;
shuffled_psbt.tx = CMutableTransaction();
- shuffled_psbt.tx->nVersion = merged_psbt.tx->nVersion;
+ shuffled_psbt.tx->version = merged_psbt.tx->version;
shuffled_psbt.tx->nLockTime = merged_psbt.tx->nLockTime;
for (int i : input_indices) {
shuffled_psbt.AddInput(merged_psbt.tx->vin[i], merged_psbt.inputs[i]);
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index c969ce45f1..20a9830d0e 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -1321,8 +1321,8 @@ public:
/** Serialize txTo */
template<typename S>
void Serialize(S &s) const {
- // Serialize nVersion
- ::Serialize(s, txTo.nVersion);
+ // Serialize version
+ ::Serialize(s, txTo.version);
// Serialize vin
unsigned int nInputs = fAnyoneCanPay ? 1 : txTo.vin.size();
::WriteCompactSize(s, nInputs);
@@ -1512,7 +1512,7 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
ss << hash_type;
// Transaction level data
- ss << tx_to.nVersion;
+ ss << tx_to.version;
ss << tx_to.nLockTime;
if (input_type != SIGHASH_ANYONECANPAY) {
ss << cache.m_prevouts_single_hash;
@@ -1594,7 +1594,7 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
HashWriter ss{};
// Version
- ss << txTo.nVersion;
+ ss << txTo.version;
// Input prevouts/nSequence (none/all, depending on flags)
ss << hashPrevouts;
ss << hashSequence;
@@ -1743,7 +1743,7 @@ bool GenericTransactionSignatureChecker<T>::CheckSequence(const CScriptNum& nSeq
// Fail if the transaction's version number is not set high
// enough to trigger BIP 68 rules.
- if (static_cast<uint32_t>(txTo->nVersion) < 2)
+ if (txTo->version < 2)
return false;
// Sequence numbers with their most significant bit set are not
diff --git a/src/script/miniscript.h b/src/script/miniscript.h
index 4880f32410..c3b01aae7e 100644
--- a/src/script/miniscript.h
+++ b/src/script/miniscript.h
@@ -251,7 +251,7 @@ namespace internal {
//! The maximum size of a witness item for a Miniscript under Tapscript context. (A BIP340 signature with a sighash type byte.)
static constexpr uint32_t MAX_TAPMINISCRIPT_STACK_ELEM_SIZE{65};
-//! nVersion + nLockTime
+//! version + nLockTime
constexpr uint32_t TX_OVERHEAD{4 + 4};
//! prevout + nSequence + scriptSig
constexpr uint32_t TXIN_BYTES_NO_WITNESS{36 + 4 + 1};
diff --git a/src/signet.cpp b/src/signet.cpp
index ebf0de09d3..7c193a1d77 100644
--- a/src/signet.cpp
+++ b/src/signet.cpp
@@ -68,13 +68,13 @@ static uint256 ComputeModifiedMerkleRoot(const CMutableTransaction& cb, const CB
std::optional<SignetTxs> SignetTxs::Create(const CBlock& block, const CScript& challenge)
{
CMutableTransaction tx_to_spend;
- tx_to_spend.nVersion = 0;
+ tx_to_spend.version = 0;
tx_to_spend.nLockTime = 0;
tx_to_spend.vin.emplace_back(COutPoint(), CScript(OP_0), 0);
tx_to_spend.vout.emplace_back(0, challenge);
CMutableTransaction tx_spending;
- tx_spending.nVersion = 0;
+ tx_spending.version = 0;
tx_spending.nLockTime = 0;
tx_spending.vin.emplace_back(COutPoint(), CScript(), 0);
tx_spending.vout.emplace_back(0, CScript(OP_RETURN));
diff --git a/src/test/data/tx_invalid.json b/src/test/data/tx_invalid.json
index a47bc8f366..486469ddef 100644
--- a/src/test/data/tx_invalid.json
+++ b/src/test/data/tx_invalid.json
@@ -246,7 +246,7 @@
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x7c17aff532f22beb54069942f9bf567a66133eaf EQUAL"]],
"0200000001000100000000000000000000000000000000000000000000000000000000000000000000030251b2000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
-["Failure due to insufficient tx.nVersion (<2)"],
+["Failure due to insufficient tx.version (<2)"],
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKSEQUENCEVERIFY 1"]],
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "CHECKSEQUENCEVERIFY"],
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194304 CHECKSEQUENCEVERIFY"]],
diff --git a/src/test/fuzz/package_eval.cpp b/src/test/fuzz/package_eval.cpp
index 2df323cfa2..122543ebad 100644
--- a/src/test/fuzz/package_eval.cpp
+++ b/src/test/fuzz/package_eval.cpp
@@ -180,7 +180,7 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
// Create transaction to add to the mempool
const CTransactionRef tx = [&] {
CMutableTransaction tx_mut;
- tx_mut.nVersion = fuzzed_data_provider.ConsumeBool() ? TRUC_VERSION : CTransaction::CURRENT_VERSION;
+ tx_mut.version = fuzzed_data_provider.ConsumeBool() ? TRUC_VERSION : CTransaction::CURRENT_VERSION;
tx_mut.nLockTime = fuzzed_data_provider.ConsumeBool() ? 0 : fuzzed_data_provider.ConsumeIntegral<uint32_t>();
// Last tx will sweep all outpoints in package
const auto num_in = last_tx ? package_outpoints.size() : fuzzed_data_provider.ConsumeIntegralInRange<int>(1, mempool_outpoints.size());
diff --git a/src/test/fuzz/tx_pool.cpp b/src/test/fuzz/tx_pool.cpp
index 8925bc9190..85a2663cb9 100644
--- a/src/test/fuzz/tx_pool.cpp
+++ b/src/test/fuzz/tx_pool.cpp
@@ -233,7 +233,7 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
// Create transaction to add to the mempool
const CTransactionRef tx = [&] {
CMutableTransaction tx_mut;
- tx_mut.nVersion = fuzzed_data_provider.ConsumeBool() ? TRUC_VERSION : CTransaction::CURRENT_VERSION;
+ tx_mut.version = fuzzed_data_provider.ConsumeBool() ? TRUC_VERSION : CTransaction::CURRENT_VERSION;
tx_mut.nLockTime = fuzzed_data_provider.ConsumeBool() ? 0 : fuzzed_data_provider.ConsumeIntegral<uint32_t>();
const auto num_in = fuzzed_data_provider.ConsumeIntegralInRange<int>(1, outpoints_rbf.size());
const auto num_out = fuzzed_data_provider.ConsumeIntegralInRange<int>(1, outpoints_rbf.size() * 2);
diff --git a/src/test/fuzz/util.cpp b/src/test/fuzz/util.cpp
index 259b00fcae..92ded99917 100644
--- a/src/test/fuzz/util.cpp
+++ b/src/test/fuzz/util.cpp
@@ -43,9 +43,9 @@ CMutableTransaction ConsumeTransaction(FuzzedDataProvider& fuzzed_data_provider,
{
CMutableTransaction tx_mut;
const auto p2wsh_op_true = fuzzed_data_provider.ConsumeBool();
- tx_mut.nVersion = fuzzed_data_provider.ConsumeBool() ?
+ tx_mut.version = fuzzed_data_provider.ConsumeBool() ?
CTransaction::CURRENT_VERSION :
- fuzzed_data_provider.ConsumeIntegral<int32_t>();
+ fuzzed_data_provider.ConsumeIntegral<uint32_t>();
tx_mut.nLockTime = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
const auto num_in = fuzzed_data_provider.ConsumeIntegralInRange<int>(0, max_num_in);
const auto num_out = fuzzed_data_provider.ConsumeIntegralInRange<int>(0, max_num_out);
diff --git a/src/test/hash_tests.cpp b/src/test/hash_tests.cpp
index f0d2b9ed72..51f1d4c840 100644
--- a/src/test/hash_tests.cpp
+++ b/src/test/hash_tests.cpp
@@ -124,9 +124,9 @@ BOOST_AUTO_TEST_CASE(siphash)
HashWriter ss{};
CMutableTransaction tx;
- // Note these tests were originally written with tx.nVersion=1
+ // Note these tests were originally written with tx.version=1
// and the test would be affected by default tx version bumps if not fixed.
- tx.nVersion = 1;
+ tx.version = 1;
ss << TX_WITH_WITNESS(tx);
BOOST_CHECK_EQUAL(SipHashUint256(1, 2, ss.GetHash()), 0x79751e980c2a0a35ULL);
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp
index 042a8a9ba5..c4cf6f8a40 100644
--- a/src/test/miner_tests.cpp
+++ b/src/test/miner_tests.cpp
@@ -425,7 +425,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
std::vector<int> prevheights;
// relative height locked
- tx.nVersion = 2;
+ tx.version = 2;
tx.vin.resize(1);
prevheights.resize(1);
tx.vin[0].prevout.hash = txFirst[0]->GetHash(); // only 1 transaction
@@ -626,7 +626,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
pblock->nVersion = VERSIONBITS_TOP_BITS;
pblock->nTime = m_node.chainman->ActiveChain().Tip()->GetMedianTimePast()+1;
CMutableTransaction txCoinbase(*pblock->vtx[0]);
- txCoinbase.nVersion = 1;
+ txCoinbase.version = 1;
txCoinbase.vin[0].scriptSig = CScript{} << (m_node.chainman->ActiveChain().Height() + 1) << bi.extranonce;
txCoinbase.vout.resize(1); // Ignore the (optional) segwit commitment added by CreateNewBlock (as the hardcoded nonces don't account for this)
txCoinbase.vout[0].scriptPubKey = CScript();
diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp
index d08d5519a1..70a18835d2 100644
--- a/src/test/sighash_tests.cpp
+++ b/src/test/sighash_tests.cpp
@@ -92,7 +92,7 @@ void static RandomScript(CScript &script) {
void static RandomTransaction(CMutableTransaction& tx, bool fSingle)
{
- tx.nVersion = int(InsecureRand32());
+ tx.version = InsecureRand32();
tx.vin.clear();
tx.vout.clear();
tx.nLockTime = (InsecureRandBool()) ? InsecureRand32() : 0;
diff --git a/src/test/sigopcount_tests.cpp b/src/test/sigopcount_tests.cpp
index 2081acdf4d..aed67d5f3c 100644
--- a/src/test/sigopcount_tests.cpp
+++ b/src/test/sigopcount_tests.cpp
@@ -86,7 +86,7 @@ static ScriptError VerifyWithFlag(const CTransaction& output, const CMutableTran
*/
static void BuildTxs(CMutableTransaction& spendingTx, CCoinsViewCache& coins, CMutableTransaction& creationTx, const CScript& scriptPubKey, const CScript& scriptSig, const CScriptWitness& witness)
{
- creationTx.nVersion = 1;
+ creationTx.version = 1;
creationTx.vin.resize(1);
creationTx.vin[0].prevout.SetNull();
creationTx.vin[0].scriptSig = CScript();
@@ -94,7 +94,7 @@ static void BuildTxs(CMutableTransaction& spendingTx, CCoinsViewCache& coins, CM
creationTx.vout[0].nValue = 1;
creationTx.vout[0].scriptPubKey = scriptPubKey;
- spendingTx.nVersion = 1;
+ spendingTx.version = 1;
spendingTx.vin.resize(1);
spendingTx.vin[0].prevout.hash = creationTx.GetHash();
spendingTx.vin[0].prevout.n = 0;
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index 21ef5dec5c..a01ed67d38 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -412,7 +412,7 @@ BOOST_AUTO_TEST_CASE(test_Get)
static void CreateCreditAndSpend(const FillableSigningProvider& keystore, const CScript& outscript, CTransactionRef& output, CMutableTransaction& input, bool success = true)
{
CMutableTransaction outputm;
- outputm.nVersion = 1;
+ outputm.version = 1;
outputm.vin.resize(1);
outputm.vin[0].prevout.SetNull();
outputm.vin[0].scriptSig = CScript();
@@ -428,7 +428,7 @@ static void CreateCreditAndSpend(const FillableSigningProvider& keystore, const
assert(output->vout[0] == outputm.vout[0]);
CMutableTransaction inputm;
- inputm.nVersion = 1;
+ inputm.version = 1;
inputm.vin.resize(1);
inputm.vin[0].prevout.hash = output->GetHash();
inputm.vin[0].prevout.n = 0;
@@ -485,7 +485,7 @@ static void ReplaceRedeemScript(CScript& script, const CScript& redeemScript)
BOOST_AUTO_TEST_CASE(test_big_witness_transaction)
{
CMutableTransaction mtx;
- mtx.nVersion = 1;
+ mtx.version = 1;
CKey key = GenerateRandomKey(); // Need to use compressed keys in segwit or the signing will fail
FillableSigningProvider keystore;
@@ -779,21 +779,21 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
t.vout[0].nValue = nDustThreshold;
CheckIsStandard(t);
- // Disallowed nVersion
- t.nVersion = -1;
+ // Disallowed version
+ t.version = std::numeric_limits<uint32_t>::max();
CheckIsNotStandard(t, "version");
- t.nVersion = 0;
+ t.version = 0;
CheckIsNotStandard(t, "version");
- t.nVersion = TX_MAX_STANDARD_VERSION + 1;
+ t.version = TX_MAX_STANDARD_VERSION + 1;
CheckIsNotStandard(t, "version");
- // Allowed nVersion
- t.nVersion = 1;
+ // Allowed version
+ t.version = 1;
CheckIsStandard(t);
- t.nVersion = 2;
+ t.version = 2;
CheckIsStandard(t);
// Check dust with odd relay fee to verify rounding:
diff --git a/src/test/txpackage_tests.cpp b/src/test/txpackage_tests.cpp
index 55e0c5f285..d5f3412aed 100644
--- a/src/test/txpackage_tests.cpp
+++ b/src/test/txpackage_tests.cpp
@@ -523,7 +523,7 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
CKey child_key = GenerateRandomKey();
CScript child_locking_script = GetScriptForDestination(WitnessV0KeyHash(child_key.GetPubKey()));
CMutableTransaction mtx_child1;
- mtx_child1.nVersion = 1;
+ mtx_child1.version = 1;
mtx_child1.vin.resize(1);
mtx_child1.vin[0].prevout.hash = ptx_parent->GetHash();
mtx_child1.vin[0].prevout.n = 0;
@@ -651,7 +651,7 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
CTransactionRef ptx_grandparent2 = MakeTransactionRef(mtx_grandparent2);
CMutableTransaction mtx_parent2_v1;
- mtx_parent2_v1.nVersion = 1;
+ mtx_parent2_v1.version = 1;
mtx_parent2_v1.vin.resize(1);
mtx_parent2_v1.vin[0].prevout.hash = ptx_grandparent2->GetHash();
mtx_parent2_v1.vin[0].prevout.n = 0;
diff --git a/src/test/txvalidation_tests.cpp b/src/test/txvalidation_tests.cpp
index f36c245383..f429f94a2f 100644
--- a/src/test/txvalidation_tests.cpp
+++ b/src/test/txvalidation_tests.cpp
@@ -27,7 +27,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_reject_coinbase, TestChain100Setup)
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
CMutableTransaction coinbaseTx;
- coinbaseTx.nVersion = 1;
+ coinbaseTx.version = 1;
coinbaseTx.vin.resize(1);
coinbaseTx.vout.resize(1);
coinbaseTx.vin[0].scriptSig = CScript() << OP_11 << OP_EQUAL;
@@ -72,11 +72,11 @@ static inline std::vector<CPubKey> random_keys(size_t num_keys) {
return keys;
}
-// Creates a placeholder tx (not valid) with 25 outputs. Specify the nVersion and the inputs.
+// Creates a placeholder tx (not valid) with 25 outputs. Specify the version and the inputs.
static inline CTransactionRef make_tx(const std::vector<COutPoint>& inputs, int32_t version)
{
CMutableTransaction mtx = CMutableTransaction{};
- mtx.nVersion = version;
+ mtx.version = version;
mtx.vin.resize(inputs.size());
mtx.vout.resize(25);
for (size_t i{0}; i < inputs.size(); ++i) {
@@ -286,7 +286,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
script_multisig << OP_2 << OP_CHECKMULTISIG;
{
CMutableTransaction mtx_many_sigops = CMutableTransaction{};
- mtx_many_sigops.nVersion = TRUC_VERSION;
+ mtx_many_sigops.version = TRUC_VERSION;
for (const auto& outpoint : multisig_outpoints) {
mtx_many_sigops.vin.emplace_back(outpoint);
mtx_many_sigops.vin.back().scriptWitness.stack.emplace_back(script_multisig.begin(), script_multisig.end());
diff --git a/src/test/txvalidationcache_tests.cpp b/src/test/txvalidationcache_tests.cpp
index 790eabc7c1..78ef96a15d 100644
--- a/src/test/txvalidationcache_tests.cpp
+++ b/src/test/txvalidationcache_tests.cpp
@@ -46,7 +46,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, Dersig100Setup)
spends.resize(2);
for (int i = 0; i < 2; i++)
{
- spends[i].nVersion = 1;
+ spends[i].version = 1;
spends[i].vin.resize(1);
spends[i].vin[0].prevout.hash = m_coinbase_txns[0]->GetHash();
spends[i].vin[0].prevout.n = 0;
@@ -181,7 +181,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup)
// coinbase tx.
CMutableTransaction spend_tx;
- spend_tx.nVersion = 1;
+ spend_tx.version = 1;
spend_tx.vin.resize(1);
spend_tx.vin[0].prevout.hash = m_coinbase_txns[0]->GetHash();
spend_tx.vin[0].prevout.n = 0;
@@ -243,7 +243,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup)
// then test validity with P2SH.
{
CMutableTransaction invalid_under_p2sh_tx;
- invalid_under_p2sh_tx.nVersion = 1;
+ invalid_under_p2sh_tx.version = 1;
invalid_under_p2sh_tx.vin.resize(1);
invalid_under_p2sh_tx.vin[0].prevout.hash = spend_tx.GetHash();
invalid_under_p2sh_tx.vin[0].prevout.n = 0;
@@ -259,7 +259,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup)
// Test CHECKLOCKTIMEVERIFY
{
CMutableTransaction invalid_with_cltv_tx;
- invalid_with_cltv_tx.nVersion = 1;
+ invalid_with_cltv_tx.version = 1;
invalid_with_cltv_tx.nLockTime = 100;
invalid_with_cltv_tx.vin.resize(1);
invalid_with_cltv_tx.vin[0].prevout.hash = spend_tx.GetHash();
@@ -288,7 +288,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup)
// TEST CHECKSEQUENCEVERIFY
{
CMutableTransaction invalid_with_csv_tx;
- invalid_with_csv_tx.nVersion = 2;
+ invalid_with_csv_tx.version = 2;
invalid_with_csv_tx.vin.resize(1);
invalid_with_csv_tx.vin[0].prevout.hash = spend_tx.GetHash();
invalid_with_csv_tx.vin[0].prevout.n = 3;
@@ -319,7 +319,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup)
// for the same tx with a different witness.
{
CMutableTransaction valid_with_witness_tx;
- valid_with_witness_tx.nVersion = 1;
+ valid_with_witness_tx.version = 1;
valid_with_witness_tx.vin.resize(1);
valid_with_witness_tx.vin[0].prevout.hash = spend_tx.GetHash();
valid_with_witness_tx.vin[0].prevout.n = 1;
@@ -344,7 +344,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup)
// Test a transaction with multiple inputs.
CMutableTransaction tx;
- tx.nVersion = 1;
+ tx.version = 1;
tx.vin.resize(2);
tx.vin[0].prevout.hash = spend_tx.GetHash();
tx.vin[0].prevout.n = 0;
diff --git a/src/test/util/transaction_utils.cpp b/src/test/util/transaction_utils.cpp
index 7e5bb30a2c..300caa577c 100644
--- a/src/test/util/transaction_utils.cpp
+++ b/src/test/util/transaction_utils.cpp
@@ -9,7 +9,7 @@
CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey, int nValue)
{
CMutableTransaction txCredit;
- txCredit.nVersion = 1;
+ txCredit.version = 1;
txCredit.nLockTime = 0;
txCredit.vin.resize(1);
txCredit.vout.resize(1);
@@ -25,7 +25,7 @@ CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey, int n
CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CScriptWitness& scriptWitness, const CTransaction& txCredit)
{
CMutableTransaction txSpend;
- txSpend.nVersion = 1;
+ txSpend.version = 1;
txSpend.nLockTime = 0;
txSpend.vin.resize(1);
txSpend.vout.resize(1);
diff --git a/src/test/util/txmempool.cpp b/src/test/util/txmempool.cpp
index 4dfc09ef67..249ce9503c 100644
--- a/src/test/util/txmempool.cpp
+++ b/src/test/util/txmempool.cpp
@@ -118,7 +118,7 @@ void CheckMempoolV3Invariants(const CTxMemPool& tx_pool)
LOCK(tx_pool.cs);
for (const auto& tx_info : tx_pool.infoAll()) {
const auto& entry = *Assert(tx_pool.GetEntry(tx_info.tx->GetHash()));
- if (tx_info.tx->nVersion == TRUC_VERSION) {
+ if (tx_info.tx->version == TRUC_VERSION) {
// Check that special maximum virtual size is respected
Assert(entry.GetTxSize() <= V3_MAX_VSIZE);
@@ -133,12 +133,12 @@ void CheckMempoolV3Invariants(const CTxMemPool& tx_pool)
Assert(entry.GetTxSize() <= V3_CHILD_MAX_VSIZE);
// All v3 transactions must only have v3 unconfirmed parents.
const auto& parents = entry.GetMemPoolParentsConst();
- Assert(parents.begin()->get().GetSharedTx()->nVersion == TRUC_VERSION);
+ Assert(parents.begin()->get().GetSharedTx()->version == TRUC_VERSION);
}
} else if (entry.GetCountWithAncestors() > 1) {
// All non-v3 transactions must only have non-v3 unconfirmed parents.
for (const auto& parent : entry.GetMemPoolParentsConst()) {
- Assert(parent.get().GetSharedTx()->nVersion != TRUC_VERSION);
+ Assert(parent.get().GetSharedTx()->version != TRUC_VERSION);
}
}
}
diff --git a/src/validation.cpp b/src/validation.cpp
index b5f1d1a426..e066ee16cb 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -831,7 +831,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
//
// Replaceability signaling of the original transactions may be
// ignored due to node setting.
- const bool allow_rbf{m_pool.m_opts.full_rbf || SignalsOptInRBF(*ptxConflicting) || ptxConflicting->nVersion == TRUC_VERSION};
+ const bool allow_rbf{m_pool.m_opts.full_rbf || SignalsOptInRBF(*ptxConflicting) || ptxConflicting->version == TRUC_VERSION};
if (!allow_rbf) {
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "txn-mempool-conflict");
}
@@ -935,7 +935,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
// method of ensuring the tx remains bumped. For example, the fee-bumping child could disappear
// due to a replacement.
// The only exception is v3 transactions.
- if (!bypass_limits && ws.m_ptx->nVersion != TRUC_VERSION && ws.m_modified_fees < m_pool.m_opts.min_relay_feerate.GetFee(ws.m_vsize)) {
+ if (!bypass_limits && ws.m_ptx->version != TRUC_VERSION && ws.m_modified_fees < m_pool.m_opts.min_relay_feerate.GetFee(ws.m_vsize)) {
// Even though this is a fee-related failure, this result is TX_MEMPOOL_POLICY, not
// TX_RECONSIDERABLE, because it cannot be bypassed using package validation.
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "min relay fee not met",
@@ -1017,7 +1017,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
.descendant_count = maybe_rbf_limits.descendant_count + 1,
.descendant_size_vbytes = maybe_rbf_limits.descendant_size_vbytes + EXTRA_DESCENDANT_TX_SIZE_LIMIT,
};
- if (ws.m_vsize > EXTRA_DESCENDANT_TX_SIZE_LIMIT || ws.m_ptx->nVersion == TRUC_VERSION) {
+ if (ws.m_vsize > EXTRA_DESCENDANT_TX_SIZE_LIMIT || ws.m_ptx->version == TRUC_VERSION) {
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "too-long-mempool-chain", error_message);
}
if (auto ancestors_retry{m_pool.CalculateMemPoolAncestors(*entry, cpfp_carve_out_limits)}) {
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index 2322471402..7b86ad388d 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -132,7 +132,7 @@ static std::optional<int64_t> GetSignedTxinWeight(const CWallet* wallet, const C
// txouts needs to be in the order of tx.vin
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, const CCoinControl* coin_control)
{
- // nVersion + nLockTime + input count + output count
+ // version + nLockTime + input count + output count
int64_t weight = (4 + 4 + GetSizeOfCompactSize(tx.vin.size()) + GetSizeOfCompactSize(tx.vout.size())) * WITNESS_SCALE_FACTOR;
// Whether any input spends a witness program. Necessary to run before the next loop over the
// inputs in order to accurately compute the compactSize length for the witness data per input.
@@ -985,7 +985,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
CMutableTransaction txNew; // The resulting transaction that we make
if (coin_control.m_version) {
- txNew.nVersion = coin_control.m_version.value();
+ txNew.version = coin_control.m_version.value();
}
CoinSelectionParams coin_selection_params{rng_fast}; // Parameters for coin selection, init with dummy
@@ -1084,7 +1084,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
const auto change_spend_fee = coin_selection_params.m_discard_feerate.GetFee(coin_selection_params.change_spend_size);
coin_selection_params.min_viable_change = std::max(change_spend_fee + 1, dust);
- // Static vsize overhead + outputs vsize. 4 nVersion, 4 nLocktime, 1 input count, 1 witness overhead (dummy, flag, stack size)
+ // Static vsize overhead + outputs vsize. 4 version, 4 nLocktime, 1 input count, 1 witness overhead (dummy, flag, stack size)
coin_selection_params.tx_noinputs_size = 10 + GetSizeOfCompactSize(vecSend.size()); // bytes for output count
// vouts to the payees
@@ -1394,7 +1394,7 @@ util::Result<CreatedTransactionResult> FundTransaction(CWallet& wallet, const CM
coinControl.m_locktime = tx.nLockTime;
// Set the user desired version
- coinControl.m_version = tx.nVersion;
+ coinControl.m_version = tx.version;
// Acquire the locks to prevent races to the new locked unspents between the
// CreateTransaction call and LockCoin calls (when lockUnspents is true).