Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: stepkrav on August 26, 2012, 02:21:58 PM



Title: How bitcoins are spent from different addresses, official bitcoin client
Post by: stepkrav on August 26, 2012, 02:21:58 PM
Hello there. I'm using the official bitcoin client and i have a question.

Say i have 1 btc in address A and 2 btc in address B, in my wallet.
Then i want to make a payment of 2 btc to a friend of mine.

Will the client take the 2 btc in address B, and spend them? Is it possible to take 1 btc from both address A and B?

Thanks!

ps : hope this is the appropriate board for my question. if not, moderators please take care.


Title: Re: How bitcoins are spent from different addresses, official bitcoin client
Post by: Strider Hiryu on August 26, 2012, 02:26:32 PM
While in that case it probably will, you can't really rely on it.  It's some behind the scenes black magic.


Title: Re: How bitcoins are spent from different addresses, official bitcoin client
Post by: Revalin on August 26, 2012, 02:30:25 PM
It uses the oldest and smallest coins available.  There is no way to select specific coins in the standard client, but you can with the coderr patch:
http://coderrr.wordpress.com/2011/06/30/patching-the-bitcoin-client-to-make-it-more-anonymous/


Title: Re: How bitcoins are spent from different addresses, official bitcoin client
Post by: bitcats on August 26, 2012, 03:03:26 PM
You can do it with electrum.


Title: Re: How bitcoins are spent from different addresses, official bitcoin client
Post by: stepkrav on August 26, 2012, 03:43:09 PM
You can do it with electrum.

is it easy to transfer my keys from one client to another ?


Title: Re: How bitcoins are spent from different addresses, official bitcoin client
Post by: bitcats on August 26, 2012, 04:57:59 PM
You can do it with electrum.

is it easy to transfer my keys from one client to another ?
Yes it is quite easy. You dont need to transfer the keys, you just import your private keys into the electrum wallet. You can have the same keys in different clients/wallets.
http://dre.redmartian.org/elecwin.htm
Of course you should read the "howto" first.


Title: Re: How bitcoins are spent from different addresses, official bitcoin client
Post by: Pieter Wuille on August 26, 2012, 07:47:53 PM
Bitcoin-the-system does not keep balances per address, that's just an authentication layer on top. The only thing that exists are coins, each potentially assigned to an address, and each transaction explicitly referring to the coins it consumes.

So, given that you have a 2 BTC coin and a 1 BTC coin (assigned to separate addresses, or to the same, doesn't matter), and you send 2 BTC somewhere, it will just take the 2 BTC coin, as that suffices. If you'd send 2.1 BTC somewhere, it will use both coins, and send 0.9 BTC back to a change address of yourself.

The GUI does not allow you to select inputs specifically, although the 0.7 release will allow you to do so when using the RPC interface.