@@ -1150,11 +1150,19 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
1150
1150
// to avoid conflicting with other possible uses of nSequence,
1151
1151
// and in the spirit of "smallest possible change from prior
1152
1152
// behavior."
1153
- const uint32_t nSequence{coin_control.m_signal_bip125_rbf .value_or (wallet.m_signal_rbf ) ? MAX_BIP125_RBF_SEQUENCE : CTxIn::MAX_SEQUENCE_NONFINAL};
1153
+ bool use_anti_fee_sniping = true ;
1154
+ const uint32_t default_sequence{coin_control.m_signal_bip125_rbf .value_or (wallet.m_signal_rbf ) ? MAX_BIP125_RBF_SEQUENCE : CTxIn::MAX_SEQUENCE_NONFINAL};
1154
1155
for (const auto & coin : selected_coins) {
1155
- txNew.vin .emplace_back (coin->outpoint , CScript (), nSequence);
1156
+ std::optional<uint32_t > sequence = coin_control.GetSequence (coin->outpoint );
1157
+ if (sequence) {
1158
+ // If an input has a preset sequence, we can't do anti-fee-sniping
1159
+ use_anti_fee_sniping = false ;
1160
+ }
1161
+ txNew.vin .emplace_back (coin->outpoint , CScript (), sequence.value_or (default_sequence));
1162
+ }
1163
+ if (use_anti_fee_sniping) {
1164
+ DiscourageFeeSniping (txNew, rng_fast, wallet.chain (), wallet.GetLastBlockHash (), wallet.GetLastBlockHeight ());
1156
1165
}
1157
- DiscourageFeeSniping (txNew, rng_fast, wallet.chain (), wallet.GetLastBlockHash (), wallet.GetLastBlockHeight ());
1158
1166
1159
1167
// Calculate the transaction fee
1160
1168
TxSize tx_sizes = CalculateMaximumSignedTxSize (CTransaction (txNew), &wallet, &coin_control);
@@ -1357,6 +1365,7 @@ bool FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& nFeeRet,
1357
1365
// The input was not in the wallet, but is in the UTXO set, so select as external
1358
1366
preset_txin.SetTxOut (coins[outPoint].out );
1359
1367
}
1368
+ preset_txin.SetSequence (txin.nSequence );
1360
1369
}
1361
1370
1362
1371
auto res = CreateTransaction (wallet, vecSend, nChangePosInOut, coinControl, false );
0 commit comments