Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: sturle on March 18, 2013, 09:49:53 AM



Title: Collecting dust -- input selection in bitcoind/bitcoin-qt
Post by: sturle on March 18, 2013, 09:49:53 AM
After having used a wallet for a while, my list of unspent outputs grow larger and larger.  Small outputs with thousands of confirmations.  To me it's dust, because I rarely send a payment of less than 1 BTC.  The reason for this is IMHO bad selection of inputs.  The client tries to find the transaction which spends the least inputs, instead of making the transaction with the highest priority.  This costs unnecessary fees as well.

E.g. I recently sent a payment of 3 BTC.  The client found a 3 BTC input with seven confirmations, decided it needed to add a fee and selected an extra input to pay the fee.  The extra input made a change output necessary, and I ended up with a rather low priority transaction with two inputs, two outputs (one very small), and a fee.

The client had many larger and older outputs to choose from, which would have genereated a higher prioirity transaction with one input and two outputs, no output smaller than 1 BTC.  This could have been sent without a fee.

Another possibility is to collect some of the dust (possible inputs < 1 BTC) with thousands of confirmations, adding up to 3.  If the resulting amount is larger, see if it can be reduced to exact by removing inputs.  If not leave a change, or possibly a fee if the extra output would require a fee > change amount.

I think the use-oldest-first method has a few benefits.
1) It is very simple and predictable.
2) Old dust will be collected.
3) In most cases it will generate a higher priority transaction due to higher age of inputs, making the transaction confirm faster.

Comments?