How bitcoin node selects the output unspent transactions when sending bitcoin?


By default, Bitcoin Core will solely spend international inputs which have at the least six confirmations, and alter outputs which have at the least one affirmation. If you wish to use youthful international inputs, you need to use the minconf parameter current e.g. on sendmany.

Past that, Bitcoin Core will break up its UTXO pool by output kind, after which for every output kind makes use of a number of algorithms to assemble one enter set candidate. Amongst all of those candidate enter units, it chooses the least wasteful per the waste metric.

The algorithms in use in Bitcoin Core v25.1 are knapsack algorithm, single random draw, and department and certain.

  • Knapsack will carry out quite a few random walks on all UTXOs with quantities decrease than the goal to assemble an enter set that overshoots goal + min_change the least, or decide the lowest bigger UTXO if that’s nearer to goal + min_change.
  • SRD will shuffle all UTXOs and decide from this shuffled record till it has collected sufficient funds to fund the transaction
  • BnB will try to seek out an enter set that avoids creating change. If there are a number of options, it can want the least wasteful.

Not one of the above algorithms truly reduce the enter set weight. Therefore, I’m proposing that we add an algorithm that minimizes the enter set weight in PR#27877, which on the very least must be run at excessive feerates. The draw back of such an algorithm can be that it might bloat a pockets’s UTXO pool when used excessively, however it will guarantee an optimum consequence within the short-term. To date, this proposal has not gotten adequate assist to be added to Bitcoin Core.

There are at the moment no configuration choices that instantly have an effect on the overall coin choice habits. You would need to carry out coin choice manually or externally and construct uncooked transactions to optimize charge expenditure.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top