Been thinking about this and pushed some refactoring that you might like a bit more.
The idea was based on try to not mix the Coin Selection code with the inputs fetching while still be able to remove the manual coins selection stuff from the automatic coin selection, the extra loops for the pre-set inputs and the FetchCoins wrapper function.
So, have decoupled the SelectCoins into two functions:
AutomaticCoinSelection: Which is basically the previously called
SelectCoinswithout the manually selected inputs stuff. So, it will purely receive a set of coins and be in charge of selecting the best subset of them to cover the target amount.SelectCoins: In charge of selecting all the user manually selected coins first ("pre-set inputs"), and if coin_control 'm_allow_other_inputs=true', call 'AutomaticCoinSelection' to select a set of coins such that the target - pre_set_inputs.total_amount is met. Then merge both results.
_Originally posted by @furszy in #25685 (review) _