get10101 / itchysats

CFDs on Bitcoin.
https://itchysats.network
MIT License
61 stars 17 forks source link

Use `LargestFirstCoinSelection` algorithm for maker wallet to avoid UTXO starvation #1134

Closed thomaseizinger closed 2 years ago

bonomat commented 2 years ago

Not going forward with implementing this as it does not solve our problem:

The default coin selection algorithm is branch-and-bound.

The branch-and-bound coin selection algorithm is a little more sophisticated and more efficient than knapsack and the default in bitcoin-core. The idea here is to use effective value per UTXO and use efficient search for exact matches. It uses a binary tree to represent un-selected UTXOs. It does a depth-first search. One of the goals is to minimize a waste metric based on cost - long-term expected cost + excess amount.

Meaning, this is actually good and reduces on-chain cost and the chance of dust outputs.

Our problem is that we have not enough UTXOs available for serving multiple takers. Changing the coinslection do a predefined one does not help. We could however implement our own which always aims at having a certain amount of (change) outputs.