aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/spend.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2022-06-01 12:35:00 -0400
committerAndrew Chow <github@achow101.com>2023-12-08 14:55:14 -0500
commit0fefcbb776063b7fcc03c28e544d830a2f540250 (patch)
treee044f7aeb276eb6e3cfddc187d21094d45442269 /src/wallet/spend.cpp
parent4d335bb1e00a414a4740007d5a192a73179b2262 (diff)
downloadbitcoin-0fefcbb776063b7fcc03c28e544d830a2f540250.tar.xz
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.
Diffstat (limited to 'src/wallet/spend.cpp')
-rw-r--r--src/wallet/spend.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index 7ec2775fb1..9dfc8c2879 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -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);