diff options
author | Andrew Chow <achow101-github@achow101.com> | 2022-06-01 14:14:17 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-12-08 14:55:14 -0500 |
commit | 14e50746f683361f4d511d384d6f1dc44ed2bf10 (patch) | |
tree | 387ef67ab3661f02ea8b4b5d09f4f8e6936981f5 /src/wallet/spend.cpp | |
parent | 0fefcbb776063b7fcc03c28e544d830a2f540250 (diff) | |
download | bitcoin-14e50746f683361f4d511d384d6f1dc44ed2bf10.tar.xz |
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.
Diffstat (limited to 'src/wallet/spend.cpp')
-rw-r--r-- | src/wallet/spend.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 9dfc8c2879..c560c71137 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -977,6 +977,10 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal( FastRandomContext rng_fast; CMutableTransaction txNew; // The resulting transaction that we make + if (coin_control.m_version) { + txNew.nVersion = coin_control.m_version.value(); + } + 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; 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, // Set the user desired locktime coinControl.m_locktime = tx.nLockTime; + // Set the user desired version + coinControl.m_version = tx.nVersion; + // Acquire the locks to prevent races to the new locked unspents between the // CreateTransaction call and LockCoin calls (when lockUnspents is true). LOCK(wallet.cs_wallet); |