From 0026b330c4abbbbdb96e4f0c4d380d70d8e592ab Mon Sep 17 00:00:00 2001 From: furszy Date: Fri, 20 Mar 2026 21:07:03 -0400 Subject: [PATCH] wallet: fix amount computed as boolean in coin selection The comparison is evaluated before the assignment, so total_amount ends up holding a boolean instead of the actual amount: total_amount = (a - b < c) which is not what we want here. This has been working by accident. --- src/wallet/spend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 3db42d1b162..3d150426404 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -939,7 +939,7 @@ util::Result AutomaticCoinSelection(const CWallet& wallet, Coin if (group.m_ancestors >= max_ancestors || group.m_max_cluster_count >= max_cluster_count) total_unconf_long_chain += group.GetSelectionAmount(); } - if (CAmount total_amount = available_coins.GetTotalAmount() - total_discarded < value_to_select) { + if (CAmount total_amount = available_coins.GetTotalAmount() - total_discarded; total_amount < value_to_select) { // Special case, too-long-mempool cluster. if (total_amount + total_unconf_long_chain > value_to_select) { return util::Error{_("Unconfirmed UTXOs are available, but spending them creates a chain of transactions that will be rejected by the mempool")};