mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
refactor: Rename CTransaction::nVersion to version
In order to ensure that the change of nVersion to a uint32_t in the previous commit has no effect, rename nVersion to version in this commit so that reviewers can easily spot if a spot was missed or if there is a check somewhere whose semantics have changed.
This commit is contained in:
parent
27e70f1f5b
commit
429ec1aaaa
45 changed files with 139 additions and 139 deletions
|
@ -58,14 +58,14 @@ def signet_txs(block, challenge):
|
|||
sd += block.nTime.to_bytes(4, "little")
|
||||
|
||||
to_spend = CTransaction()
|
||||
to_spend.nVersion = 0
|
||||
to_spend.version = 0
|
||||
to_spend.nLockTime = 0
|
||||
to_spend.vin = [CTxIn(COutPoint(0, 0xFFFFFFFF), b"\x00" + CScriptOp.encode_op_pushdata(sd), 0)]
|
||||
to_spend.vout = [CTxOut(0, challenge)]
|
||||
to_spend.rehash()
|
||||
|
||||
spend = CTransaction()
|
||||
spend.nVersion = 0
|
||||
spend.version = 0
|
||||
spend.nLockTime = 0
|
||||
spend.vin = [CTxIn(COutPoint(to_spend.sha256, 0), b"", 0)]
|
||||
spend.vout = [CTxOut(0, b"\x6a")]
|
||||
|
|
|
@ -12,7 +12,7 @@ other consensus and policy rules, each of the following conditions are met:
|
|||
|
||||
1. The directly conflicting transactions all signal replaceability explicitly. A transaction is
|
||||
signaling BIP125 replaceability if any of its inputs have an nSequence number less than (0xffffffff - 1).
|
||||
A transaction also signals replaceability if its nVersion field is set to 3.
|
||||
A transaction also signals replaceability if its version field is set to 3.
|
||||
|
||||
*Rationale*: See [BIP125
|
||||
explanation](https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki#motivation).
|
||||
|
|
|
@ -208,7 +208,7 @@ static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
|
|||
throw std::runtime_error("Invalid TX version requested: '" + cmdVal + "'");
|
||||
}
|
||||
|
||||
tx.nVersion = newVersion;
|
||||
tx.version = newVersion;
|
||||
}
|
||||
|
||||
static void MutateTxLocktime(CMutableTransaction& tx, const std::string& cmdVal)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -48,7 +48,7 @@ std::pair<int, int64_t> CalculateSequenceLocks(const CTransaction &tx, int flags
|
|||
int nMinHeight = -1;
|
||||
int64_t nMinTime = -1;
|
||||
|
||||
bool fEnforceBIP68 = 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
|
||||
|
|
|
@ -174,7 +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());
|
||||
entry.pushKV("version", 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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ std::string CTransaction::ToString() const
|
|||
std::string str;
|
||||
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);
|
||||
|
|
|
@ -197,13 +197,13 @@ static constexpr TransactionSerParams TX_NO_WITNESS{.allow_witness = false};
|
|||
|
||||
/**
|
||||
* Basic transaction serialization format:
|
||||
* - uint32_t nVersion
|
||||
* - uint32_t version
|
||||
* - std::vector<CTxIn> vin
|
||||
* - std::vector<CTxOut> vout
|
||||
* - uint32_t nLockTime
|
||||
*
|
||||
* Extended transaction serialization format:
|
||||
* - uint32_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) {
|
||||
|
@ -305,7 +305,7 @@ public:
|
|||
// structure, including the hash.
|
||||
const std::vector<CTxIn> vin;
|
||||
const std::vector<CTxOut> vout;
|
||||
const uint32_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;
|
||||
uint32_t nVersion;
|
||||
uint32_t version;
|
||||
uint32_t nLockTime;
|
||||
|
||||
explicit CMutableTransaction();
|
||||
|
|
|
@ -1748,8 +1748,8 @@ static RPCHelpMan joinpsbts()
|
|||
}
|
||||
psbtxs.push_back(psbtx);
|
||||
// Choose the highest version number
|
||||
if (psbtx.tx->nVersion > best_version) {
|
||||
best_version = 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 = 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]);
|
||||
|
|
|
@ -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 (txTo->nVersion < 2)
|
||||
if (txTo->version < 2)
|
||||
return false;
|
||||
|
||||
// Sequence numbers with their most significant bit set are not
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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"]],
|
||||
|
|
|
@ -173,7 +173,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());
|
||||
|
|
|
@ -226,7 +226,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);
|
||||
|
|
|
@ -43,7 +43,7 @@ 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<uint32_t>();
|
||||
tx_mut.nLockTime = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -421,7 +421,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
|
||||
|
@ -622,7 +622,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();
|
||||
|
|
|
@ -92,7 +92,7 @@ void static RandomScript(CScript &script) {
|
|||
|
||||
void static RandomTransaction(CMutableTransaction& tx, bool fSingle)
|
||||
{
|
||||
tx.nVersion = InsecureRand32();
|
||||
tx.version = InsecureRand32();
|
||||
tx.vin.clear();
|
||||
tx.vout.clear();
|
||||
tx.nLockTime = (InsecureRandBool()) ? InsecureRand32() : 0;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 = std::numeric_limits<uint32_t>::max();
|
||||
// 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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)}) {
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -78,8 +78,8 @@ class BIP68Test(BitcoinTestFramework):
|
|||
self.log.info("Activating BIP68 (and 112/113)")
|
||||
self.activateCSV()
|
||||
|
||||
self.log.info("Verifying nVersion=2 transactions are standard.")
|
||||
self.log.info("Note that nVersion=2 transactions are always standard (independent of BIP68 activation status).")
|
||||
self.log.info("Verifying version=2 transactions are standard.")
|
||||
self.log.info("Note that version=2 transactions are always standard (independent of BIP68 activation status).")
|
||||
self.test_version2_relay()
|
||||
|
||||
self.log.info("Passed")
|
||||
|
@ -107,7 +107,7 @@ class BIP68Test(BitcoinTestFramework):
|
|||
# This transaction will enable sequence-locks, so this transaction should
|
||||
# fail
|
||||
tx2 = CTransaction()
|
||||
tx2.nVersion = 2
|
||||
tx2.version = 2
|
||||
sequence_value = sequence_value & 0x7fffffff
|
||||
tx2.vin = [CTxIn(COutPoint(tx1_id, 0), nSequence=sequence_value)]
|
||||
tx2.wit.vtxinwit = [CTxInWitness()]
|
||||
|
@ -119,7 +119,7 @@ class BIP68Test(BitcoinTestFramework):
|
|||
|
||||
# Setting the version back down to 1 should disable the sequence lock,
|
||||
# so this should be accepted.
|
||||
tx2.nVersion = 1
|
||||
tx2.version = 1
|
||||
|
||||
self.wallet.sendrawtransaction(from_node=self.nodes[0], tx_hex=tx2.serialize().hex())
|
||||
|
||||
|
@ -159,7 +159,7 @@ class BIP68Test(BitcoinTestFramework):
|
|||
using_sequence_locks = False
|
||||
|
||||
tx = CTransaction()
|
||||
tx.nVersion = 2
|
||||
tx.version = 2
|
||||
value = 0
|
||||
for j in range(num_inputs):
|
||||
sequence_value = 0xfffffffe # this disables sequence locks
|
||||
|
@ -228,7 +228,7 @@ class BIP68Test(BitcoinTestFramework):
|
|||
# Anyone-can-spend mempool tx.
|
||||
# Sequence lock of 0 should pass.
|
||||
tx2 = CTransaction()
|
||||
tx2.nVersion = 2
|
||||
tx2.version = 2
|
||||
tx2.vin = [CTxIn(COutPoint(tx1.sha256, 0), nSequence=0)]
|
||||
tx2.vout = [CTxOut(int(tx1.vout[0].nValue - self.relayfee * COIN), SCRIPT_W0_SH_OP_TRUE)]
|
||||
self.wallet.sign_tx(tx=tx2)
|
||||
|
@ -246,7 +246,7 @@ class BIP68Test(BitcoinTestFramework):
|
|||
sequence_value |= SEQUENCE_LOCKTIME_TYPE_FLAG
|
||||
|
||||
tx = CTransaction()
|
||||
tx.nVersion = 2
|
||||
tx.version = 2
|
||||
tx.vin = [CTxIn(COutPoint(orig_tx.sha256, 0), nSequence=sequence_value)]
|
||||
tx.wit.vtxinwit = [CTxInWitness()]
|
||||
tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])]
|
||||
|
@ -360,7 +360,7 @@ class BIP68Test(BitcoinTestFramework):
|
|||
|
||||
# Make an anyone-can-spend transaction
|
||||
tx2 = CTransaction()
|
||||
tx2.nVersion = 1
|
||||
tx2.version = 1
|
||||
tx2.vin = [CTxIn(COutPoint(tx1.sha256, 0), nSequence=0)]
|
||||
tx2.vout = [CTxOut(int(tx1.vout[0].nValue - self.relayfee * COIN), SCRIPT_W0_SH_OP_TRUE)]
|
||||
|
||||
|
@ -376,7 +376,7 @@ class BIP68Test(BitcoinTestFramework):
|
|||
sequence_value = 100 # 100 block relative locktime
|
||||
|
||||
tx3 = CTransaction()
|
||||
tx3.nVersion = 2
|
||||
tx3.version = 2
|
||||
tx3.vin = [CTxIn(COutPoint(tx2.sha256, 0), nSequence=sequence_value)]
|
||||
tx3.wit.vtxinwit = [CTxInWitness()]
|
||||
tx3.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])]
|
||||
|
|
|
@ -110,7 +110,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
|||
|
||||
def create_bip112special(self, input, txversion):
|
||||
tx = self.create_self_transfer_from_utxo(input)
|
||||
tx.nVersion = txversion
|
||||
tx.version = txversion
|
||||
self.miniwallet.sign_tx(tx)
|
||||
tx.vin[0].scriptSig = CScript([-1, OP_CHECKSEQUENCEVERIFY, OP_DROP] + list(CScript(tx.vin[0].scriptSig)))
|
||||
tx.rehash()
|
||||
|
@ -118,7 +118,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
|||
|
||||
def create_bip112emptystack(self, input, txversion):
|
||||
tx = self.create_self_transfer_from_utxo(input)
|
||||
tx.nVersion = txversion
|
||||
tx.version = txversion
|
||||
self.miniwallet.sign_tx(tx)
|
||||
tx.vin[0].scriptSig = CScript([OP_CHECKSEQUENCEVERIFY] + list(CScript(tx.vin[0].scriptSig)))
|
||||
tx.rehash()
|
||||
|
@ -136,7 +136,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
|||
for i, (sdf, srhb, stf, srlb) in enumerate(product(*[[True, False]] * 4)):
|
||||
locktime = relative_locktime(sdf, srhb, stf, srlb)
|
||||
tx = self.create_self_transfer_from_utxo(bip68inputs[i])
|
||||
tx.nVersion = txversion
|
||||
tx.version = txversion
|
||||
tx.vin[0].nSequence = locktime + locktime_delta
|
||||
self.miniwallet.sign_tx(tx)
|
||||
txs.append({'tx': tx, 'sdf': sdf, 'stf': stf})
|
||||
|
@ -154,7 +154,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
|||
tx.vin[0].nSequence = BASE_RELATIVE_LOCKTIME + locktime_delta
|
||||
else: # vary nSequence instead, OP_CSV is fixed
|
||||
tx.vin[0].nSequence = locktime + locktime_delta
|
||||
tx.nVersion = txversion
|
||||
tx.version = txversion
|
||||
self.miniwallet.sign_tx(tx)
|
||||
if varyOP_CSV:
|
||||
tx.vin[0].scriptSig = CScript([locktime, OP_CHECKSEQUENCEVERIFY, OP_DROP] + list(CScript(tx.vin[0].scriptSig)))
|
||||
|
@ -257,10 +257,10 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
|||
# BIP113 test transaction will be modified before each use to put in appropriate block time
|
||||
bip113tx_v1 = self.create_self_transfer_from_utxo(bip113input)
|
||||
bip113tx_v1.vin[0].nSequence = 0xFFFFFFFE
|
||||
bip113tx_v1.nVersion = 1
|
||||
bip113tx_v1.version = 1
|
||||
bip113tx_v2 = self.create_self_transfer_from_utxo(bip113input)
|
||||
bip113tx_v2.vin[0].nSequence = 0xFFFFFFFE
|
||||
bip113tx_v2.nVersion = 2
|
||||
bip113tx_v2.version = 2
|
||||
|
||||
# For BIP68 test all 16 relative sequence locktimes
|
||||
bip68txs_v1 = self.create_bip68txs(bip68inputs, 1)
|
||||
|
|
|
@ -1408,10 +1408,10 @@ class TaprootTest(BitcoinTestFramework):
|
|||
|
||||
left = done
|
||||
while left:
|
||||
# Construct CTransaction with random nVersion, nLocktime
|
||||
# Construct CTransaction with random version, nLocktime
|
||||
tx = CTransaction()
|
||||
tx.nVersion = random.choice([1, 2, random.getrandbits(32)])
|
||||
min_sequence = (tx.nVersion != 1 and tx.nVersion != 0) * 0x80000000 # The minimum sequence number to disable relative locktime
|
||||
tx.version = random.choice([1, 2, random.getrandbits(32)])
|
||||
min_sequence = (tx.version != 1 and tx.version != 0) * 0x80000000 # The minimum sequence number to disable relative locktime
|
||||
if random.choice([True, False]):
|
||||
tx.nLockTime = random.randrange(LOCKTIME_THRESHOLD, self.lastblocktime - 7200) # all absolute locktimes in the past
|
||||
else:
|
||||
|
@ -1502,8 +1502,8 @@ class TaprootTest(BitcoinTestFramework):
|
|||
is_standard_tx = (
|
||||
fail_input is None # Must be valid to be standard
|
||||
and (all(utxo.spender.is_standard for utxo in input_utxos)) # All inputs must be standard
|
||||
and tx.nVersion >= 1 # The tx version must be standard
|
||||
and tx.nVersion <= 2)
|
||||
and tx.version >= 1 # The tx version must be standard
|
||||
and tx.version <= 2)
|
||||
tx.rehash()
|
||||
msg = ','.join(utxo.spender.comment + ("*" if n == fail_input else "") for n, utxo in enumerate(input_utxos))
|
||||
if is_standard_tx:
|
||||
|
@ -1530,7 +1530,7 @@ class TaprootTest(BitcoinTestFramework):
|
|||
# Deterministically mine coins to OP_TRUE in block 1
|
||||
assert_equal(self.nodes[0].getblockcount(), 0)
|
||||
coinbase = CTransaction()
|
||||
coinbase.nVersion = 1
|
||||
coinbase.version = 1
|
||||
coinbase.vin = [CTxIn(COutPoint(0, 0xffffffff), CScript([OP_1, OP_1]), SEQUENCE_FINAL)]
|
||||
coinbase.vout = [CTxOut(5000000000, CScript([OP_1]))]
|
||||
coinbase.nLockTime = 0
|
||||
|
@ -1622,7 +1622,7 @@ class TaprootTest(BitcoinTestFramework):
|
|||
for i, spk in enumerate(old_spks + tap_spks):
|
||||
val = 42000000 * (i + 7)
|
||||
tx = CTransaction()
|
||||
tx.nVersion = 1
|
||||
tx.version = 1
|
||||
tx.vin = [CTxIn(COutPoint(lasttxid, i & 1), CScript([]), SEQUENCE_FINAL)]
|
||||
tx.vout = [CTxOut(val, spk), CTxOut(amount - val, CScript([OP_1]))]
|
||||
if i & 1:
|
||||
|
@ -1679,7 +1679,7 @@ class TaprootTest(BitcoinTestFramework):
|
|||
|
||||
# Construct a deterministic transaction spending all outputs created above.
|
||||
tx = CTransaction()
|
||||
tx.nVersion = 2
|
||||
tx.version = 2
|
||||
tx.vin = []
|
||||
inputs = []
|
||||
input_spks = [tap_spks[0], tap_spks[1], old_spks[0], tap_spks[2], tap_spks[5], old_spks[2], tap_spks[6], tap_spks[3], tap_spks[4]]
|
||||
|
|
|
@ -287,7 +287,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
|||
|
||||
self.log.info('Some nonstandard transactions')
|
||||
tx = tx_from_hex(raw_tx_reference)
|
||||
tx.nVersion = 4 # A version currently non-standard
|
||||
tx.version = 4 # A version currently non-standard
|
||||
self.check_mempool_result(
|
||||
result_expected=[{'txid': tx.rehash(), 'allowed': False, 'reject-reason': 'version'}],
|
||||
rawtxs=[tx.serialize().hex()],
|
||||
|
|
|
@ -55,7 +55,7 @@ class MutatedBlocksTest(BitcoinTestFramework):
|
|||
# Create mutated version of the block by changing the transaction
|
||||
# version on the self-transfer.
|
||||
mutated_block = copy.deepcopy(block)
|
||||
mutated_block.vtx[1].nVersion = 4
|
||||
mutated_block.vtx[1].version = 4
|
||||
|
||||
# Announce the new block via a compact block through the honest relayer
|
||||
cmpctblock = HeaderAndShortIDs()
|
||||
|
|
|
@ -1164,7 +1164,7 @@ class SegWitTest(BitcoinTestFramework):
|
|||
if not self.wit.is_null():
|
||||
flags |= 1
|
||||
r = b""
|
||||
r += self.nVersion.to_bytes(4, "little")
|
||||
r += self.version.to_bytes(4, "little")
|
||||
if flags:
|
||||
dummy = []
|
||||
r += ser_vector(dummy)
|
||||
|
@ -1975,7 +1975,7 @@ class SegWitTest(BitcoinTestFramework):
|
|||
def serialize_with_bogus_witness(tx):
|
||||
flags = 3
|
||||
r = b""
|
||||
r += tx.nVersion.to_bytes(4, "little")
|
||||
r += tx.version.to_bytes(4, "little")
|
||||
if flags:
|
||||
dummy = []
|
||||
r += ser_vector(dummy)
|
||||
|
|
|
@ -394,7 +394,7 @@ class RPCPackagesTest(BitcoinTestFramework):
|
|||
peer = node.add_p2p_connection(P2PTxInvStore())
|
||||
txs = self.wallet.create_self_transfer_chain(chain_length=2)
|
||||
bad_child = tx_from_hex(txs[1]["hex"])
|
||||
bad_child.nVersion = 0xffffffff
|
||||
bad_child.version = 0xffffffff
|
||||
hex_partial_acceptance = [txs[0]["hex"], bad_child.serialize().hex()]
|
||||
res = node.submitpackage(hex_partial_acceptance)
|
||||
assert_equal(res["package_msg"], "transaction failed")
|
||||
|
|
|
@ -465,28 +465,28 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
# Test the minimum transaction version number that fits in a signed 32-bit integer.
|
||||
# As transaction version is serialized unsigned, this should convert to its unsigned equivalent.
|
||||
tx = CTransaction()
|
||||
tx.nVersion = 0x80000000
|
||||
tx.version = 0x80000000
|
||||
rawtx = tx.serialize().hex()
|
||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
|
||||
assert_equal(decrawtx['version'], 0x80000000)
|
||||
|
||||
# Test the maximum transaction version number that fits in a signed 32-bit integer.
|
||||
tx = CTransaction()
|
||||
tx.nVersion = 0x7fffffff
|
||||
tx.version = 0x7fffffff
|
||||
rawtx = tx.serialize().hex()
|
||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
|
||||
assert_equal(decrawtx['version'], 0x7fffffff)
|
||||
|
||||
# Test the minimum transaction version number that fits in an unsigned 32-bit integer.
|
||||
tx = CTransaction()
|
||||
tx.nVersion = 0
|
||||
tx.version = 0
|
||||
rawtx = tx.serialize().hex()
|
||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
|
||||
assert_equal(decrawtx['version'], 0)
|
||||
|
||||
# Test the maximum transaction version number that fits in an unsigned 32-bit integer.
|
||||
tx = CTransaction()
|
||||
tx.nVersion = 0xffffffff
|
||||
tx.version = 0xffffffff
|
||||
rawtx = tx.serialize().hex()
|
||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
|
||||
assert_equal(decrawtx['version'], 0xffffffff)
|
||||
|
|
|
@ -560,12 +560,12 @@ class CTxWitness:
|
|||
|
||||
|
||||
class CTransaction:
|
||||
__slots__ = ("hash", "nLockTime", "nVersion", "sha256", "vin", "vout",
|
||||
__slots__ = ("hash", "nLockTime", "version", "sha256", "vin", "vout",
|
||||
"wit")
|
||||
|
||||
def __init__(self, tx=None):
|
||||
if tx is None:
|
||||
self.nVersion = 2
|
||||
self.version = 2
|
||||
self.vin = []
|
||||
self.vout = []
|
||||
self.wit = CTxWitness()
|
||||
|
@ -573,7 +573,7 @@ class CTransaction:
|
|||
self.sha256 = None
|
||||
self.hash = None
|
||||
else:
|
||||
self.nVersion = tx.nVersion
|
||||
self.version = tx.version
|
||||
self.vin = copy.deepcopy(tx.vin)
|
||||
self.vout = copy.deepcopy(tx.vout)
|
||||
self.nLockTime = tx.nLockTime
|
||||
|
@ -582,7 +582,7 @@ class CTransaction:
|
|||
self.wit = copy.deepcopy(tx.wit)
|
||||
|
||||
def deserialize(self, f):
|
||||
self.nVersion = int.from_bytes(f.read(4), "little")
|
||||
self.version = int.from_bytes(f.read(4), "little")
|
||||
self.vin = deser_vector(f, CTxIn)
|
||||
flags = 0
|
||||
if len(self.vin) == 0:
|
||||
|
@ -605,7 +605,7 @@ class CTransaction:
|
|||
|
||||
def serialize_without_witness(self):
|
||||
r = b""
|
||||
r += self.nVersion.to_bytes(4, "little")
|
||||
r += self.version.to_bytes(4, "little")
|
||||
r += ser_vector(self.vin)
|
||||
r += ser_vector(self.vout)
|
||||
r += self.nLockTime.to_bytes(4, "little")
|
||||
|
@ -617,7 +617,7 @@ class CTransaction:
|
|||
if not self.wit.is_null():
|
||||
flags |= 1
|
||||
r = b""
|
||||
r += self.nVersion.to_bytes(4, "little")
|
||||
r += self.version.to_bytes(4, "little")
|
||||
if flags:
|
||||
dummy = []
|
||||
r += ser_vector(dummy)
|
||||
|
@ -677,8 +677,8 @@ class CTransaction:
|
|||
return math.ceil(self.get_weight() / WITNESS_SCALE_FACTOR)
|
||||
|
||||
def __repr__(self):
|
||||
return "CTransaction(nVersion=%i vin=%s vout=%s wit=%s nLockTime=%i)" \
|
||||
% (self.nVersion, repr(self.vin), repr(self.vout), repr(self.wit), self.nLockTime)
|
||||
return "CTransaction(version=%i vin=%s vout=%s wit=%s nLockTime=%i)" \
|
||||
% (self.version, repr(self.vin), repr(self.vout), repr(self.wit), self.nLockTime)
|
||||
|
||||
|
||||
class CBlockHeader:
|
||||
|
|
|
@ -738,7 +738,7 @@ def SegwitV0SignatureMsg(script, txTo, inIdx, hashtype, amount):
|
|||
hashOutputs = uint256_from_str(hash256(serialize_outputs))
|
||||
|
||||
ss = bytes()
|
||||
ss += txTo.nVersion.to_bytes(4, "little")
|
||||
ss += txTo.version.to_bytes(4, "little")
|
||||
ss += ser_uint256(hashPrevouts)
|
||||
ss += ser_uint256(hashSequence)
|
||||
ss += txTo.vin[inIdx].prevout.serialize()
|
||||
|
@ -817,7 +817,7 @@ def TaprootSignatureMsg(txTo, spent_utxos, hash_type, input_index = 0, scriptpat
|
|||
in_type = hash_type & SIGHASH_ANYONECANPAY
|
||||
spk = spent_utxos[input_index].scriptPubKey
|
||||
ss = bytes([0, hash_type]) # epoch, hash_type
|
||||
ss += txTo.nVersion.to_bytes(4, "little")
|
||||
ss += txTo.version.to_bytes(4, "little")
|
||||
ss += txTo.nLockTime.to_bytes(4, "little")
|
||||
if in_type != SIGHASH_ANYONECANPAY:
|
||||
ss += BIP341_sha_prevouts(txTo)
|
||||
|
|
|
@ -321,7 +321,7 @@ class MiniWallet:
|
|||
tx = CTransaction()
|
||||
tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']), nSequence=seq) for utxo_to_spend, seq in zip(utxos_to_spend, sequence)]
|
||||
tx.vout = [CTxOut(amount_per_output, bytearray(self._scriptPubKey)) for _ in range(num_outputs)]
|
||||
tx.nVersion = version
|
||||
tx.version = version
|
||||
tx.nLockTime = locktime
|
||||
|
||||
self.sign_tx(tx)
|
||||
|
|
|
@ -111,7 +111,7 @@ class CreateTxWalletTest(BitcoinTestFramework):
|
|||
test_wallet.unloadwallet()
|
||||
|
||||
def test_version3(self):
|
||||
self.log.info('Check wallet does not create transactions with nVersion=3 yet')
|
||||
self.log.info('Check wallet does not create transactions with version=3 yet')
|
||||
wallet_rpc = self.nodes[0].get_wallet_rpc(self.default_wallet_name)
|
||||
|
||||
self.nodes[0].createwallet("v3")
|
||||
|
@ -124,7 +124,7 @@ class CreateTxWalletTest(BitcoinTestFramework):
|
|||
# While v3 transactions are standard, the CURRENT_VERSION is 2.
|
||||
# This test can be removed if CURRENT_VERSION is changed, and replaced with tests that the
|
||||
# wallet handles v3 rules properly.
|
||||
assert_equal(tx_current_version.nVersion, 2)
|
||||
assert_equal(tx_current_version.version, 2)
|
||||
wallet_v3.unloadwallet()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue