Friday, December 5, 2025
HomeBitcoincoin choice - Why is KnapsackSolver nonetheless in Bitcoin Core?

coin choice – Why is KnapsackSolver nonetheless in Bitcoin Core?

KnapsackSolver:

  • Finds a changeless options the place a range candidate’s quantity precisely matches goal to the satoshi
  • Falls again to the bottom bigger UTXO when all UTXOs smaller than the choice goal don’t exceed goal+min_change in sum
  • Returns from its 1000 random walks on smaller UTXOs the choice candidate that exceeds the goal+min_change the least

Typically, I think about this method suboptimal, as a result of minimizing the overshoot over the choice goal could also be helpful, it’s by far much less necessary than different aims (e.g., charges, UTXO administration, privateness). KnapsackSolver tends to generate many change outputs of comparable worth, aggressively consolidates the pockets’s small UTXOs at any feerate, and subsequently will increase total lifetime value of the pockets. KnapsackSolver is making an attempt to do too many issues in a single algorithm which makes it needlessly difficult, whereas the massive rely of random walks is computationally inefficient and sluggish on giant wallets. These downsides are partially mitigated already by operating a number of completely different coin choice methods and utilizing the waste metric to choose from the choice candidates returned by the completely different methods, however presently, the general method falls again to operating KnapsackSolver with the minimal change set to 0 if producing a KnapsackSolver answer with a change output fails and not one of the different algorithms return an enter set candidate.

I’ve lengthy had the objective to take away KnapsackSolver, however simply dropping KnapsackSolver causes the UTXO pool of wallets to usually settle at bigger UTXO counts. Subsequently, it appears that evidently one other algorithm that creates consolidatory options at low feerates ought to be added to assist cut back this UTXO pool enhance and cut back the general lifetime value of wallets. (SRD will be consolidatory, however unreliably so. CG is by no means, BnB is just barely consolidatory.) I’ve experimented with a variety of completely different approaches, however haven’t settled on a suggestion but.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments