aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/coinselection.cpp
diff options
context:
space:
mode:
authorMurch <murch@murch.one>2024-01-08 15:26:21 -0500
committerMurch <murch@murch.one>2024-02-09 10:50:53 +0100
commit5f84f3cc043c5fb15072f5072fee752eaa01a2ec (patch)
treea4d35045af18ffddb37313fb06fc6385dfe78447 /src/wallet/coinselection.cpp
parentd68bc74fb2e3ae4ae775ab544fe5b4ab46025abb (diff)
downloadbitcoin-5f84f3cc043c5fb15072f5072fee752eaa01a2ec.tar.xz
opt: Skip branches with worse weight
Once we exceed the weight of the current best selection, we can always shift as adding more inputs can never yield a better solution.
Diffstat (limited to 'src/wallet/coinselection.cpp')
-rw-r--r--src/wallet/coinselection.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp
index abd710d56d..cf666e7459 100644
--- a/src/wallet/coinselection.cpp
+++ b/src/wallet/coinselection.cpp
@@ -413,6 +413,9 @@ util::Result<SelectionResult> CoinGrinder(std::vector<OutputGroup>& utxo_pool, c
// max_weight exceeded: SHIFT
max_tx_weight_exceeded = true;
should_shift = true;
+ } else if (curr_weight > best_selection_weight) {
+ // Worse weight than best solution. More UTXOs only increase weight: SHIFT
+ should_shift = true;
} else if (curr_amount >= total_target) {
// Success, adding more weight cannot be better: SHIFT
should_shift = true;