How do Bitcoin nodes select unspent output transactions when sending Bitcoin?
By default, Bitcoin Core only uses external inputs that have at least 6 confirmations and changes outputs that have at least 1 confirmation. If you want to use younger foreign input, you can use: minconf
Parameter exists (e.g. on) sendmany
.
Besides that, Bitcoin Core splits the UTXO pool by output type and then uses multiple algorithms for each output type to construct one set of input candidates. Among all these candidate input sets, we select the least wasteful one according to the waste metric.
The algorithm used in Bitcoin Core v25.1 is: knapsack algorithm, Single random drawingand branches and boundaries.
- Knapsack assembles a set of inputs that exceed the target by performing numerous random walks over all UTXOs that have less than the target.
target + min_change
choose the least lowest big If UTXO is closertarget + min_change
. - The SRD shuffles all UTXOs and selects from this shuffled list until it has raised enough funds to fund the transaction.
- BnB attempts to find a set of inputs that prevents the creation of changes. If there are multiple solutions, prefer the one with the least amount of waste.
None of the above algorithms actually minimize the input set weights. Therefore, I propose to add an algorithm for minimizing input set weights to PR#27877. This algorithm must run at least at high speed. The downside to these algorithms is that overusing them can inflate your wallet’s UTXO pool, but in the short term they can ensure optimal results. So far, this proposal has not received enough support to be added to Bitcoin Core.
There are currently no configuration options that directly affect normal coin selection behavior. To optimize your fee spend, you need to perform coin selection manually or externally and build raw transactions.