Coin selection algorithm in Python to optimally select UTXO

3

1

Does anyone know of a good coin selection algorithm in Python that's perhaps similar to the one in Bitcoin Core (currently this: github/bitcoin/src/wallet.cpp (per guidance from stackexchange/1077))?

I see the popular python libraries: pybitcointools and pycoin both seem to be selecting all existing UTXOs which might not be optimal, and might fail @over 100 utxos. Andreas Antonopoulos' "greedy selection algo" is not as efficient as that in wallet.cpp of Bitcoin Core, am I right?

kumarz

Posted 2016-07-26T12:50:32.480

Reputation: 231

Just a note, there is no 'optimal' coin selection algorithm. There are trade-offs between privacy, UTXO set size, and a few other things, as is described well here: http://bitcoin.stackexchange.com/q/32145/18196.

morsecoder 2016-07-26T20:55:06.667

I'm currently compiling a master thesis on the topic of coin selection and I'm not aware of a Python implementation of Bitcoin Core's coin selection algorithm. I am however not up-to-date whether there are more Bitcoin wallet implementations in Python.Murch 2016-07-27T06:11:55.153

thanks so much @StephenM347 , Murch 's response: http://bitcoin.stackexchange.com/a/32445/15567 alludes to what I am after, but as he pointed out, there is no such implementation in Python yet. Since I am looking to replicate what Bitcoin Core does(admittedly not optimal), I will code it up in Python from guidance on that post and paste on here later.

kumarz 2016-07-30T10:49:09.610

Answers

1

I'm currently compiling a master thesis on the topic of coin selection and I'm not aware of a Python implementation of Bitcoin Core's coin selection algorithm.

Murch

Posted 2016-07-26T12:50:32.480

Reputation: 41 609

thanks @Murch ! Your response: bitcoin.stackexchange.com/a/32445/15567 alludes to what I am after, but as you pointed out, there is no such implementation in Python yet. Since I am looking to replicate what Bitcoin Core does(admittedly not optimal), I will code it up in Python from guidance on that post and paste on here later.kumarz 2016-07-30T10:50:21.720