Skip to content

Commit 14e5074

Browse files
committed
wallet: Explicitly preserve transaction version in CreateTransaction
We provide the preset nVersion to CCoinControl so that CreateTransactionInternal can be aware of it and set it in the produced transaction.
1 parent 0fefcbb commit 14e5074

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/wallet/coincontrol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ class CCoinControl
9393
FlatSigningProvider m_external_provider;
9494
//! Locktime
9595
std::optional<uint32_t> m_locktime;
96+
//! Version
97+
std::optional<uint32_t> m_version;
9698

9799
CCoinControl();
98100

src/wallet/spend.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,10 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
977977
FastRandomContext rng_fast;
978978
CMutableTransaction txNew; // The resulting transaction that we make
979979

980+
if (coin_control.m_version) {
981+
txNew.nVersion = coin_control.m_version.value();
982+
}
983+
980984
CoinSelectionParams coin_selection_params{rng_fast}; // Parameters for coin selection, init with dummy
981985
coin_selection_params.m_avoid_partial_spends = coin_control.m_avoid_partial_spends;
982986
coin_selection_params.m_include_unsafe_inputs = coin_control.m_include_unsafe_inputs;
@@ -1349,6 +1353,9 @@ bool FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& nFeeRet,
13491353
// Set the user desired locktime
13501354
coinControl.m_locktime = tx.nLockTime;
13511355

1356+
// Set the user desired version
1357+
coinControl.m_version = tx.nVersion;
1358+
13521359
// Acquire the locks to prevent races to the new locked unspents between the
13531360
// CreateTransaction call and LockCoin calls (when lockUnspents is true).
13541361
LOCK(wallet.cs_wallet);

0 commit comments

Comments
 (0)