Friday, November 22, 2024

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

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

Past that, Bitcoin Core will break up its UTXO pool by output sort, after which for every output sort 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 checklist 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’ll desire 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 may bloat a pockets’s UTXO pool when used excessively, however it could guarantee an optimum end result within the short-term. Thus far, this proposal has not gotten enough help to be added to Bitcoin Core.

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

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles