From 3ae3a94f2bdc572cdf1b5223419a25650291ab56 Mon Sep 17 00:00:00 2001 From: Pol Espinasa Date: Wed, 1 Jul 2026 16:42:39 +0200 Subject: [PATCH] wallet: avoid call bumpfeediscount with negative values ChooseSelectionResult computes the bump-fee discount as: summed_bump_fees - combined_bump_fee Where summed_bump_fees is the sum of per-UTXO ancestor bump fees and combined_bump_fee is the true combined cost taking into account shared ancestors. Both variables use creates a fresh MiniMiner snapshot of the mempool. Because of that the two snapshots of the mempool might be different. An artificial feerate decrease of an ancestor using prioritizesettransaction can make combined_bump_fee > summed_bump_fees. This cause calling bumpfeediscount with a negative vaule triggering an assertion >= 0. This commit fixes this by only calling bumpfeediscount when the discount is strictly positive. Co-authored-by: dergoegge --- src/wallet/spend.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index dba7b882959..e92546db1a9 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -796,7 +796,8 @@ util::Result ChooseSelectionResult(interfaces::Chain& chain, co return util::Error{_("Failed to calculate bump fees, because unconfirmed UTXOs depend on an enormous cluster of unconfirmed transactions.")}; } CAmount bump_fee_overestimate = summed_bump_fees - combined_bump_fee.value(); - if (bump_fee_overestimate) { + // Avoid negative discount if mempool changed between the two bump fee snapshots. + if (bump_fee_overestimate > 0) { result.SetBumpFeeDiscount(bump_fee_overestimate); } result.RecalculateWaste(coin_selection_params.min_viable_change, coin_selection_params.m_cost_of_change, coin_selection_params.m_change_fee);