mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
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.
This commit is contained in:
parent
0fefcbb776
commit
14e50746f6
2 changed files with 9 additions and 0 deletions
|
@ -93,6 +93,8 @@ public:
|
|||
FlatSigningProvider m_external_provider;
|
||||
//! Locktime
|
||||
std::optional<uint32_t> m_locktime;
|
||||
//! Version
|
||||
std::optional<uint32_t> m_version;
|
||||
|
||||
CCoinControl();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue