aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/spend.cpp
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2022-12-18 21:10:07 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2023-04-05 09:32:39 -0300
commit5a2bc45ee0b123e461c5191322ed0b43524c3d82 (patch)
treea0cbca043706b08c1f2bb5f82b62387092bf00a9 /src/wallet/spend.cpp
parent2d112584e384de10021c64e4700455d71326824e (diff)
downloadbitcoin-5a2bc45ee0b123e461c5191322ed0b43524c3d82.tar.xz
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.
Diffstat (limited to 'src/wallet/spend.cpp')
-rw-r--r--src/wallet/spend.cpp14
1 files changed, 1 insertions, 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<SelectionResult> ChooseSelectionResult(const CAmount& nTargetValue,
return errors.empty() ? util::Error() : errors.front();
}
- std::vector<SelectionResult> 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<int>(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<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& available_coins, const PreSelectedInputs& pre_set_inputs,