diff options
author | Andrew Chow <achow101-github@achow101.com> | 2020-11-16 14:31:45 -0500 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-12-05 13:39:51 -0500 |
commit | 60d2ca72e3f4c56433c63b929a88e7a2def06399 (patch) | |
tree | 80ff962de3f9f1e99ee14d6261b38aaf218dcaa6 /src/wallet/spend.cpp | |
parent | a339add471717623915cd1a846ade4dab2c89deb (diff) |
Return SelectionResult from SelectCoinsBnB
Removes coins_out and value_ret has SelectCoinsBnB return a
std::optional<SelectionResult>
Diffstat (limited to 'src/wallet/spend.cpp')
-rw-r--r-- | src/wallet/spend.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 5470177440..022420c57d 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -385,11 +385,9 @@ bool AttemptSelection(const CWallet& wallet, const CAmount& nTargetValue, const // Note that unlike KnapsackSolver, we do not include the fee for creating a change output as BnB will not create a change output. std::vector<OutputGroup> positive_groups = GroupOutputs(wallet, coins, coin_selection_params, eligibility_filter, true /* positive_only */); - std::set<CInputCoin> bnb_coins; - CAmount bnb_value; - if (SelectCoinsBnB(positive_groups, nTargetValue, coin_selection_params.m_cost_of_change, bnb_coins, bnb_value)) { - const auto waste = GetSelectionWaste(bnb_coins, /* cost of change */ CAmount(0), nTargetValue, !coin_selection_params.m_subtract_fee_outputs); - results.emplace_back(std::make_tuple(waste, std::move(bnb_coins), bnb_value)); + if (auto bnb_result{SelectCoinsBnB(positive_groups, nTargetValue, coin_selection_params.m_cost_of_change)}) { + bnb_result->ComputeAndSetWaste(CAmount(0)); + results.emplace_back(std::make_tuple(bnb_result->GetWaste(), bnb_result->GetInputSet(), bnb_result->GetSelectedValue())); } // The knapsack solver has some legacy behavior where it will spend dust outputs. We retain this behavior, so don't filter for positive only here. |