Bitcoin Forum
July 11, 2024, 02:47:52 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How are inputs for transactions selected?  (Read 1185 times)
capsqrl (OP)
Sr. Member
****
Offline Offline

Activity: 444
Merit: 250



View Profile
September 30, 2012, 07: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.

Norsk Bitcoin-bruker? Kom til /r/BitcoinNO på reddit!
Revalin
Hero Member
*****
Offline Offline

Activity: 728
Merit: 500


165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g


View Profile
September 30, 2012, 07:45:15 PM
Last edit: September 30, 2012, 07:57:42 PM by Revalin
 #2

It favors small, old ones to minimize fees and to consolidate the dust in your wallet.

Edit: Wrong, see below.

      War is God's way of teaching Americans geography.  --Ambrose Bierce
Bitcoin is the Devil's way of teaching geeks economics.  --Revalin 165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
Stephen Gornick
Legendary
*
Offline Offline

Activity: 2506
Merit: 1010


View Profile
September 30, 2012, 07: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.

Unichange.me

            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █


Stephen Gornick
Legendary
*
Offline Offline

Activity: 2506
Merit: 1010


View Profile
September 30, 2012, 07: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

Unichange.me

            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █


Revalin
Hero Member
*****
Offline Offline

Activity: 728
Merit: 500


165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g


View Profile
September 30, 2012, 07:58:32 PM
 #5

Post updated for truthlessness.

      War is God's way of teaching Americans geography.  --Ambrose Bierce
Bitcoin is the Devil's way of teaching geeks economics.  --Revalin 165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!