wallet: set m_version in coin control to default value
What changed, and why it matters
This Bitcoin Core commit changes how transaction version numbers are handled when a user creates a transaction through the wallet. Previously, the version was optional and only set if the user explicitly provided one. Now it always defaults to the current standard transaction version. The commit message says this is needed so future code can rely on the version field when enforcing new 'TRUC' transaction rules. On its own, this is a small defensive cleanup, not a fix for an active exploit, but it prevents a class of future bugs where an unset version could lead to incorrect rule checks.
Treat as a low-risk hardening/preparatory change. Reviewers should verify that downstream TRUC-related commits correctly interpret m_version and that no code path still expects the old std::optional behavior. No immediate user or operator action is required.
Security signals we found
Change removes optional/nullable transaction version in wallet coin control
Default version now set to CTransaction::CURRENT_VERSION
Commit message references future TRUC rule enforcement
Prevents undefined/unset version from being used in transaction creation logic
No explicit bug, CVE, or exploit described in commit or supplied references
Evidence from the diff
The patch modifies CCoinControl in src/wallet/coincontrol.h so that m_version is no longer std::optional
Changed components
src/wallet/coincontrol.hsrc/wallet/spend.cppBitcoin Core wallet transaction creationCCoinControl transaction version handlingInspect captured patch +3 / −5
diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h
index d7075bc8..1cba19af 100644
--- a/src/wallet/coincontrol.h
+++ b/src/wallet/coincontrol.h
@@ -109,10 +109,10 @@ public:
int m_max_depth = DEFAULT_MAX_DEPTH;
//! SigningProvider that has pubkeys and scripts to do spend size estimation for external inputs
FlatSigningProvider m_external_provider;
+ //! Version
+ uint32_t m_version = CTransaction::CURRENT_VERSION;
//! Locktime
std::optional<uint32_t> m_locktime;
- //! Version
- std::optional<uint32_t> m_version;
//! Caps weight of resulting tx
std::optional<int> m_max_tx_weight{std::nullopt};
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index a44cc409..91cdc4a8 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -1032,9 +1032,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
FastRandomContext rng_fast;
CMutableTransaction txNew; // The resulting transaction that we make
- if (coin_control.m_version) {
- txNew.version = coin_control.m_version.value();
- }
+ txNew.version = coin_control.m_version;
CoinSelectionParams coin_selection_params{rng_fast}; // Parameters for coin selection, init with dummy
coin_selection_params.m_avoid_partial_spends = coin_control.m_avoid_partial_spends;
Why this scored 32/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.