mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
wallet: Explicitly preserve transaction locktime in CreateTransaction
We provide the preset nLockTime to CCoinControl so that CreateTransactionInternal can be aware of it and set it in the produced transaction.
This commit is contained in:
parent
4d335bb1e0
commit
0fefcbb776
2 changed files with 10 additions and 0 deletions
|
@ -91,6 +91,8 @@ 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;
|
||||
//! Locktime
|
||||
std::optional<uint32_t> m_locktime;
|
||||
|
||||
CCoinControl();
|
||||
|
||||
|
|
|
@ -1160,6 +1160,11 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
|
|||
}
|
||||
txNew.vin.emplace_back(coin->outpoint, CScript(), sequence.value_or(default_sequence));
|
||||
}
|
||||
if (coin_control.m_locktime) {
|
||||
txNew.nLockTime = coin_control.m_locktime.value();
|
||||
// If we have a locktime set, we can't use anti-fee-sniping
|
||||
use_anti_fee_sniping = false;
|
||||
}
|
||||
if (use_anti_fee_sniping) {
|
||||
DiscourageFeeSniping(txNew, rng_fast, wallet.chain(), wallet.GetLastBlockHash(), wallet.GetLastBlockHeight());
|
||||
}
|
||||
|
@ -1341,6 +1346,9 @@ bool FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& nFeeRet,
|
|||
vecSend.push_back(recipient);
|
||||
}
|
||||
|
||||
// Set the user desired locktime
|
||||
coinControl.m_locktime = tx.nLockTime;
|
||||
|
||||
// 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