Wednesday, December 25, 2024

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

By default, Bitcoin Core will solely spend overseas inputs which have not less than six confirmations, and alter outputs which have not less than one affirmation. If you wish to use youthful overseas inputs, you should utilize the minconf parameter current e.g. on sendmany.

Past that, Bitcoin Core will cut 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 choose the lowest bigger UTXO if that’s nearer to goal + min_change.
  • SRD will shuffle all UTXOs and choose from this shuffled checklist till it has collected sufficient funds to fund the transaction
  • BnB will try to search out an enter set that avoids creating change. If there are a number of options, it should favor the least wasteful.

Not one of the above algorithms truly decrease 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 ought to 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 end result within the short-term. To date, this proposal has not gotten ample help to be added to Bitcoin Core.

There are at the moment no configuration choices that straight 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 payment expenditure.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles