From 5a2bc45ee0b123e461c5191322ed0b43524c3d82 Mon Sep 17 00:00:00 2001 From: furszy Date: Sun, 18 Dec 2022 21:10:07 -0300 Subject: [PATCH] wallet: clean post coin selection max weight filter Now the coin selection algorithms contemplate the maximum allowed weight internally and return std::nullopt if their result exceeds it. --- src/wallet/spend.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 57fb7202bb..140b7720c7 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -590,21 +590,9 @@ util::Result ChooseSelectionResult(const CAmount& nTargetValue, return errors.empty() ? util::Error() : errors.front(); } - std::vector eligible_results; - std::copy_if(results.begin(), results.end(), std::back_inserter(eligible_results), [coin_selection_params](const SelectionResult& result) { - const auto initWeight{coin_selection_params.tx_noinputs_size * WITNESS_SCALE_FACTOR}; - return initWeight + result.GetWeight() <= static_cast(MAX_STANDARD_TX_WEIGHT); - }); - - if (eligible_results.empty()) { - return util::Error{_("The inputs size exceeds the maximum weight. " - "Please try sending a smaller amount or manually consolidating your wallet's UTXOs")}; - } - // Choose the result with the least waste // If the waste is the same, choose the one which spends more inputs. - auto& best_result = *std::min_element(eligible_results.begin(), eligible_results.end()); - return best_result; + return *std::min_element(results.begin(), results.end()); } util::Result SelectCoins(const CWallet& wallet, CoinsResult& available_coins, const PreSelectedInputs& pre_set_inputs,