bitcoinjs / coinselect

An unspent transaction output (UTXO) selection module for bitcoin.
MIT License
177 stars 100 forks source link

Rationale for the blackjack strategy #9

Closed karelbilek closed 7 years ago

karelbilek commented 7 years ago

What is the rationale for using blackjack strategy, for selecting the exact match?

It might create a lower fee, but will it create longer fees long-term?

karelbilek commented 7 years ago

It seems the code for the simulation PDF is here - https://github.com/Xekyo/CoinSelectionSimulator - I will look it up and try to run some experiments, to have something to reason with here :)

dcousens commented 7 years ago

@runn1ng there is an in-repo fee simulator: https://github.com/bitcoinjs/coinselect/tree/master/stats

I optimized the default export to be the lowest fees over time, but it'd be great to see your take on the approach taken.

dcousens commented 7 years ago

What is the rationale for using blackjack strategy, for selecting the exact match?

My approach assumes a descending by-value UTXO set, with an accumulative exact match strategy to attempt fee minimisation. It isn't perfect.

karelbilek commented 7 years ago

Thanks for comments!

I have tried to run the scala simulation code from @xekyo with the gambling hot wallet data (the simulation has a starting UTXO set and a set of value changes) - it actually seems that the strategies all return more or less the same fees, if you add total fees + cost to spend the remaining UTXOs.

The strategy that seem to work the best for the simulation (when total fees+cost to spend the rest is optimized) is Branch and Bound.

I will try to now run your simulation, plus try to understand @xekyo's Branch and Bound algorithm and port it into JS and into this code.

karelbilek commented 7 years ago

I am closing this, since BnB is a different strategy