Context:
SelectCoinsBnB
uses cost_of_change
as the upper bound for the search of changeless solution. However when building a tx the actual range for dropping change is determined by min_viable_change
and change_fee
(see SelectionResult::GetChange
).
0min_viable_change = std::max(change_spend_fee + 1, dust);
1cost_of_change = change_spend_fee + change_fee;
That means that BnB forgoes some of the changeless solutions in cases when dust threshold is higher than change_spend_fee
.
Proposal: Update BnB upper bound to be consistent with tx building, i.e. it should use exactly the same threshold for when the change is viable.