Bitcoin Forum
June 19, 2019, 10:12:09 AM *
News: Latest Bitcoin Core release: 0.18.0 [Torrent] (New!)
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How are inputs for transactions selected?  (Read 1086 times)
capsqrl
Sr. Member
****
Offline Offline

Activity: 450
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!

Mine RVN and with 0% mining fees and get paid in BTC, ETH, XMR or RVN.

www.cudominer.com Get Cudo Miner
Auto coin switching, third-party miners, overclocking and remote management (Win/Linux)
Run from a USB stick or install from an ISO image (Linux)
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1560939129
Hero Member
*
Offline Offline

Posts: 1560939129

View Profile Personal Message (Offline)

Ignore
1560939129
Reply with quote  #2

1560939129
Report to moderator
1560939129
Hero Member
*
Offline Offline

Posts: 1560939129

View Profile Personal Message (Offline)

Ignore
1560939129
Reply with quote  #2

1560939129
Report to moderator
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: 1001


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: 1001


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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!