Skip to content

Commit fbabe86

Browse files
committed
Merge bitcoin/bitcoin#34870: wallet: feebumper, fix crash when combined bump fee is unavailable
6072a2a wallet: feebumper, fix crash when combined bump fee is unavailable (furszy) Pull request description: When a large cluster of unconfirmed transactions exceeds the limit, `calculateCombinedBumpFee()` returns `std::nullopt`. Previously, we continued executing and the optional value was accessed unconditionally, leading to a `std::bad_optional_access` exception (https://en.cppreference.com/w/cpp/utility/optional/value.html). Fix this by returning early when the bumped fee is null. Note: This is a crash for the GUI, and an uncaught exception for the RPC `bumpfee` and `psbtbumpfee`. ACKs for top commit: achow101: ACK 6072a2a luke-jr: utACK 6072a2a rkrux: crACK 6072a2a based on returning before accessing the null optional. Tree-SHA512: f863ace1426b2e743e2281e5c624b523de7317c1f305f88f369e77d60005460e4af58b424bc784304fd1ac30a3bfa575137537ec334fa6e449c827daeb262a99
2 parents 696b545 + 6072a2a commit fbabe86

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/wallet/feebumper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CMutableTrans
8080
reused_inputs.push_back(txin.prevout);
8181
}
8282

83-
std::optional<CAmount> combined_bump_fee = wallet.chain().calculateCombinedBumpFee(reused_inputs, newFeerate);
83+
const std::optional<CAmount> combined_bump_fee = wallet.chain().calculateCombinedBumpFee(reused_inputs, newFeerate);
8484
if (!combined_bump_fee.has_value()) {
8585
errors.push_back(Untranslated(strprintf("Failed to calculate bump fees, because unconfirmed UTXOs depend on an enormous cluster of unconfirmed transactions.")));
86+
return feebumper::Result::WALLET_ERROR;
8687
}
8788
CAmount new_total_fee = newFeerate.GetFee(maxTxSize) + combined_bump_fee.value();
8889

0 commit comments

Comments
 (0)