Author

Topic: How are inputs for transactions selected? (Read 1204 times)

hero member
Activity: 728
Merit: 500
165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
September 30, 2012, 02:58:32 PM
#5
Post updated for truthlessness.
legendary
Activity: 2506
Merit: 1010
September 30, 2012, 02:55:37 PM
#4
It favors small, old ones to minimize fees and to consolidate the dust in your wallet.

The coin selection is "fee blind", meaning it is not choosing the coins that results in the lowest amount of fees.  It also does not try to consolidate dust.

Quote
The reference client uses a heuristic subset-sum knapsack solver to try to minimize transaction size. It is fee blind, though it is run multiple times excluding less confirmed coins which may sometimes help avoid fees if there are many larger inputs available and minimizing sizes helps with fees (but does not guarantee low fees). Minimizing the current transaction size also does nothing to reduce the amount of data a pruning bitcoin node needs to keep around, in fact it usually does the opposite.

 - http://en.bitcoin.it/wiki/User:Gmaxwell/coin_selection
legendary
Activity: 2506
Merit: 1010
September 30, 2012, 02:48:08 PM
#3
I was wondering how bitcoin clients (and bitcoin-qt in particular) select inputs for transactions. Are they selected by age (oldest/newest first), to minimize the number of inputs, to minimize the change output, or some other criteria?

Just curious.

The algorithm for the client generally aims to come up with the combination of coins that results in the least amount of change.

There are some factors also taking into account.  If the coins haven't confirmed yet, they will not be automatically chosen.

But after a short while, the age of the coins is no longer a factor.

Use the oldest first might give away information and thus take from Bitcoin's privacy, so the "minimize change" is essentially the only goal when choosing which coins to spend.
hero member
Activity: 728
Merit: 500
165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
September 30, 2012, 02:45:15 PM
#2
It favors small, old ones to minimize fees and to consolidate the dust in your wallet.

Edit: Wrong, see below.
sr. member
Activity: 444
Merit: 250
September 30, 2012, 02:20:59 PM
#1
I was wondering how bitcoin clients (and bitcoin-qt in particular) select inputs for transactions. Are they selected by age (oldest/newest first), to minimize the number of inputs, to minimize the change output, or some other criteria?

Just curious.
Jump to: