mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
Merge #20611: Move TX_MAX_STANDARD_VERSION to policy
fade6195b1
Move TX_MAX_STANDARD_VERSION to policy (MarcoFalke) Pull request description: `primitives` should only be used for the raw datastructures (parsing and format). It is not the right place to document relay policy. ACKs for top commit: laanwj: Code review ACKfade6195b1
lontivero: Concept ACKfade6195b1
Tree-SHA512: f809c4aecd14d7e9feaa7b50b9c0697232991eef36190cd960bcfb0ad6e20c71a4f6aab48c7747cf8a681eb14feda60c55b09a37f128673d519567224f29cd97
This commit is contained in:
commit
dff0f6f753
4 changed files with 28 additions and 25 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <consensus/consensus.h>
|
#include <consensus/consensus.h>
|
||||||
#include <core_io.h>
|
#include <core_io.h>
|
||||||
#include <key_io.h>
|
#include <key_io.h>
|
||||||
|
#include <policy/policy.h>
|
||||||
#include <policy/rbf.h>
|
#include <policy/rbf.h>
|
||||||
#include <primitives/transaction.h>
|
#include <primitives/transaction.h>
|
||||||
#include <script/script.h>
|
#include <script/script.h>
|
||||||
|
@ -196,8 +197,9 @@ static CAmount ExtractAndValidateValue(const std::string& strValue)
|
||||||
static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
|
static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
|
||||||
{
|
{
|
||||||
int64_t newVersion;
|
int64_t newVersion;
|
||||||
if (!ParseInt64(cmdVal, &newVersion) || newVersion < 1 || newVersion > CTransaction::MAX_STANDARD_VERSION)
|
if (!ParseInt64(cmdVal, &newVersion) || newVersion < 1 || newVersion > TX_MAX_STANDARD_VERSION) {
|
||||||
throw std::runtime_error("Invalid TX version requested: '" + cmdVal + "'");
|
throw std::runtime_error("Invalid TX version requested: '" + cmdVal + "'");
|
||||||
|
}
|
||||||
|
|
||||||
tx.nVersion = (int) newVersion;
|
tx.nVersion = (int) newVersion;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType)
|
||||||
|
|
||||||
bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, std::string& reason)
|
bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, std::string& reason)
|
||||||
{
|
{
|
||||||
if (tx.nVersion > CTransaction::MAX_STANDARD_VERSION || tx.nVersion < 1) {
|
if (tx.nVersion > TX_MAX_STANDARD_VERSION || tx.nVersion < 1) {
|
||||||
reason = "version";
|
reason = "version";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,13 @@ CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee);
|
||||||
bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee);
|
bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee);
|
||||||
|
|
||||||
bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType);
|
bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType);
|
||||||
|
|
||||||
|
|
||||||
|
// 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{2};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for standard transaction types
|
* Check for standard transaction types
|
||||||
* @return True if all outputs (scriptPubKeys) use only standard transaction forms
|
* @return True if all outputs (scriptPubKeys) use only standard transaction forms
|
||||||
|
|
|
@ -262,12 +262,6 @@ public:
|
||||||
// Default transaction version.
|
// Default transaction version.
|
||||||
static const int32_t CURRENT_VERSION=2;
|
static const int32_t CURRENT_VERSION=2;
|
||||||
|
|
||||||
// Changing the default transaction version requires a two step process: first
|
|
||||||
// adapting relay policy by bumping MAX_STANDARD_VERSION, and then later date
|
|
||||||
// bumping the default CURRENT_VERSION at which point both CURRENT_VERSION and
|
|
||||||
// MAX_STANDARD_VERSION will be equal.
|
|
||||||
static const int32_t MAX_STANDARD_VERSION=2;
|
|
||||||
|
|
||||||
// The local variables are made const to prevent unintended modification
|
// The local variables are made const to prevent unintended modification
|
||||||
// without updating the cached hash value. However, CTransaction is not
|
// without updating the cached hash value. However, CTransaction is not
|
||||||
// actually immutable; deserialization and assignment are implemented,
|
// actually immutable; deserialization and assignment are implemented,
|
||||||
|
|
Loading…
Add table
Reference in a new issue