From cc155226fee1f5c9a40ec37f6276e45c9c42b26a Mon Sep 17 00:00:00 2001 From: ishaanam Date: Wed, 23 Jul 2025 10:36:38 -0400 Subject: [PATCH] wallet: set m_version in coin control to default value In future commits we assume that coin_control.m_version has a value when making sure that we follow truc rules, so we should give it a default value of CTransaction::CURRENT_VERSION. --- src/wallet/coincontrol.h | 4 ++-- src/wallet/spend.cpp | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h index d7075bc8d6..1cba19af6b 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 m_locktime; - //! Version - std::optional m_version; //! Caps weight of resulting tx std::optional m_max_tx_weight{std::nullopt}; diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index a44cc40913..91cdc4a894 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -1032,9 +1032,7 @@ static util::Result 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;