Skip to content

Commit 31dd3dc

Browse files
committed
bumpfee: Clear scriptSigs and scriptWitnesses before calculated max size
The max size calculation expects some inputs to have empty scriptSigs and witnesses, so we need to clear these before doing that calculation.
1 parent a0c3afb commit 31dd3dc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/wallet/feebumper.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,13 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
242242
if (coin_control.m_feerate) {
243243
// The user provided a feeRate argument.
244244
// We calculate this here to avoid compiler warning on the cs_wallet lock
245-
const int64_t maxTxSize{CalculateMaximumSignedTxSize(*wtx.tx, &wallet, &new_coin_control).vsize};
245+
// We need to make a temporary transaction with no input witnesses as the dummy signer expects them to be empty for external inputs
246+
CMutableTransaction mtx{*wtx.tx};
247+
for (auto& txin : mtx.vin) {
248+
txin.scriptSig.clear();
249+
txin.scriptWitness.SetNull();
250+
}
251+
const int64_t maxTxSize{CalculateMaximumSignedTxSize(CTransaction(mtx), &wallet, &new_coin_control).vsize};
246252
Result res = CheckFeeRate(wallet, wtx, *new_coin_control.m_feerate, maxTxSize, old_fee, errors);
247253
if (res != Result::OK) {
248254
return res;

0 commit comments

Comments
 (0)