Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: dabura667 on January 12, 2015, 11:45:55 AM



Title: [Discussion] Best algorithm for utxo selection for sending.
Post by: dabura667 on January 12, 2015, 11:45:55 AM
Hi all.

I would like to ask the opinion of the dev community about utxo selection when sending.

I see a lot of wallets use the following method.

Code:
1st priority: block height - ascending
2nd priority: value - ascending

I am wondering what the benefits and drawbacks of this method are.

Also, I am wondering if there are alternative utxo selection methods that have different properties.

Using the kind of defacto standard utxo selection:

So if we had 8 BTC in block 4 and 1.5 AND 0.5 BTC utxos in block 6...

For any value (even 0.5 BTC) up to 8 BTC, it will always use the 8 BTC utxo first.
Then up to 8.5 BTC it will use the 8 BTC input and the 0.5 BTC input.
Then up to 10 BTC it will use all three utxos.

So as an alternative example:
Using the above example, up to 0.5 BTC should use the 0.5 BTC input, from > 0.5 to 1.5 should use only the 1.5 BTC input, and Something > 8.5 and up to 9.5 should only use 8 BTC and the 1.5 BTC utxo.


How would my selection method differ in benefits and demerits?


Title: Re: [Discussion] Best algorithm for utxo selection for sending.
Post by: DannyHamilton on January 12, 2015, 12:58:11 PM
When choosing a UTXO selection method, it is probably a good idea to determine what the goal is?

Some possible goals (each that might have a different UTXO selection algorithm):
  • Minimize transaction fees for current transaction
  • Minimize estimated total transaction fees for future transactions
  • Maximize bitcoin days destroyed
  • Minimize bitcoin days destroyed
  • Minimize address connections as inputs to transactions
  • Minimize total unspent outputs
  • Minimize transaction change


Title: Re: [Discussion] Best algorithm for utxo selection for sending.
Post by: grau on January 12, 2015, 02:52:02 PM
I'd add one that comes up if dealing with HD wallets:
- compact key index range used

If wallet is busy, then you'd also aim to preserve optimal coin fragmentation, that is some logarithmic scale as if handling traditional cash.