mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-22 20:58:09 +02:00
refactor coin selection for parameterizable change target
no behavior changes, since the target is always MIN_CHANGE
This commit is contained in:
@@ -389,7 +389,8 @@ std::optional<SelectionResult> AttemptSelection(const CWallet& wallet, const CAm
|
||||
std::vector<OutputGroup> all_groups = GroupOutputs(wallet, coins, coin_selection_params, eligibility_filter, false /* positive_only */);
|
||||
// While nTargetValue includes the transaction fees for non-input things, it does not include the fee for creating a change output.
|
||||
// So we need to include that for KnapsackSolver as well, as we are expecting to create a change output.
|
||||
if (auto knapsack_result{KnapsackSolver(all_groups, nTargetValue + coin_selection_params.m_change_fee, coin_selection_params.rng_fast)}) {
|
||||
if (auto knapsack_result{KnapsackSolver(all_groups, nTargetValue + coin_selection_params.m_change_fee,
|
||||
coin_selection_params.m_min_change_target, coin_selection_params.rng_fast)}) {
|
||||
knapsack_result->ComputeAndSetWaste(coin_selection_params.m_cost_of_change);
|
||||
results.push_back(*knapsack_result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user