Skip to content

Commit 5a2bc45

Browse files
committed
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.
1 parent 2d11258 commit 5a2bc45

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

src/wallet/spend.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -590,21 +590,9 @@ util::Result<SelectionResult> ChooseSelectionResult(const CAmount& nTargetValue,
590590
return errors.empty() ? util::Error() : errors.front();
591591
}
592592

593-
std::vector<SelectionResult> eligible_results;
594-
std::copy_if(results.begin(), results.end(), std::back_inserter(eligible_results), [coin_selection_params](const SelectionResult& result) {
595-
const auto initWeight{coin_selection_params.tx_noinputs_size * WITNESS_SCALE_FACTOR};
596-
return initWeight + result.GetWeight() <= static_cast<int>(MAX_STANDARD_TX_WEIGHT);
597-
});
598-
599-
if (eligible_results.empty()) {
600-
return util::Error{_("The inputs size exceeds the maximum weight. "
601-
"Please try sending a smaller amount or manually consolidating your wallet's UTXOs")};
602-
}
603-
604593
// Choose the result with the least waste
605594
// If the waste is the same, choose the one which spends more inputs.
606-
auto& best_result = *std::min_element(eligible_results.begin(), eligible_results.end());
607-
return best_result;
595+
return *std::min_element(results.begin(), results.end());
608596
}
609597

610598
util::Result<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& available_coins, const PreSelectedInputs& pre_set_inputs,

0 commit comments

Comments
 (0)