diff options
author | glozow <gloriajzhao@gmail.com> | 2022-03-11 12:20:36 +0000 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2022-03-11 12:22:34 +0000 |
commit | ec7d73628a6397fca3b5b852d4e97ff918b6d3a6 (patch) | |
tree | 2a71a2352f8b29cfa94eeb154e852033bd73488a /src | |
parent | ce1fabe5454dfd01fe95b4a948704fcd3a155859 (diff) | |
download | bitcoin-ec7d73628a6397fca3b5b852d4e97ff918b6d3a6.tar.xz |
[wallet] assert BnB internally calculated waste is the same as GetSelectionWaste()
These two implementations of waste calculation should never deviate.
Still keep the SelectCoinsBnB internal calculation because incremental
calculate-as-you-go is much more performant than calling
GetSelectionWaste() over and over again.
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/coinselection.cpp | 2 | ||||
-rw-r--r-- | src/wallet/spend.cpp | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp index 23faad027f..513572da45 100644 --- a/src/wallet/coinselection.cpp +++ b/src/wallet/coinselection.cpp @@ -163,6 +163,8 @@ std::optional<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_poo result.AddInput(utxo_pool.at(i)); } } + result.ComputeAndSetWaste(CAmount{0}); + assert(best_waste == result.GetWaste()); return result; } diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 83eaececc1..582464c5b8 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -379,7 +379,6 @@ std::optional<SelectionResult> AttemptSelection(const CWallet& wallet, const CAm // 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 */); if (auto bnb_result{SelectCoinsBnB(positive_groups, nTargetValue, coin_selection_params.m_cost_of_change)}) { - bnb_result->ComputeAndSetWaste(CAmount(0)); results.push_back(*bnb_result); } |