rpc: Add transaction min standard version parameter
What changed, and why it matters
This commit is a small code cleanup in Bitcoin Core's transaction acceptance rules. It replaces a hard-coded minimum transaction version check (the number 1) with a named constant TX_MIN_STANDARD_VERSION, which is also set to 1. By itself, this change does not alter network behavior or fix a known security bug; it only makes the code easier to read and maintain.
No security action required. Treat as normal code-quality/maintenance review. If evaluating a larger PR or release, verify whether this constant is intended to be exposed through RPC later and review the accompanying tests, but this commit alone is not security relevant.
Security signals we found
No functional policy change: minimum version remains 1 and maximum remains 3
No consensus code modified
No RPC interface changes in this diff
No bug fix or vulnerability remediation described in commit message
Evidence from the diff
The patch introduces a new policy constant TX_MIN_STANDARD_VERSION{1} in src/policy/policy.h and uses it in IsStandardTx() in src/policy/policy.cpp instead of the literal 1. The existing maximum-version constant TX_MAX_STANDARD_VERSION remains 3. The functional rule is unchanged: transactions with version < 1 or > 3 are still non-standard. This is a refactor/preparatory change with no observable consensus or mempool policy effect.
Changed components
src/policy/policy.cppsrc/policy/policy.hInspect captured patch +2 / −1
diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp
index fdb6bc5f..3da6cb74 100644
--- a/src/policy/policy.cpp
+++ b/src/policy/policy.cpp
@@ -98,7 +98,7 @@ bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType)
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.version > TX_MAX_STANDARD_VERSION || tx.version < 1) {
+ if (tx.version > TX_MAX_STANDARD_VERSION || tx.version < TX_MIN_STANDARD_VERSION) {
reason = "version";
return false;
}
diff --git a/src/policy/policy.h b/src/policy/policy.h
index ce8bfc6a..23993dd7 100644
--- a/src/policy/policy.h
+++ b/src/policy/policy.h
@@ -145,6 +145,7 @@ std::vector<uint32_t> GetDust(const CTransaction& tx, CFeeRate dust_relay_rate);
// 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::version) TX_MIN_STANDARD_VERSION{1};
static constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3};
/**
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.