Experimentally, this seems to be the case, but is it always like this or depends on some details? Also, does it generate a new address each time this is done, or first searches the wallet if there is an empty address there already? (And uses that in that case) Is it likely that this behaviour will change in a later version of the satoshi client?
-
possible duplicate of Why does Bitcoin send the "change" to a different address?– Stephen GornickCommented Apr 29, 2013 at 2:50
-
Not a duplicate: he didn't ask "why", he asked "when"(does it do that), and he asked "if"(will it change in future).– o0'.Commented Apr 29, 2013 at 8:53
2 Answers
When you generate a wallet, then the wallet contains by default 100 bitcoin addresses. This is good for many reasons, e.g. old backups of your wallet might be able to recover all loses in case of a harddrive failure, etc.
The "privacy reason" is that someone looking at the blockchain can't see which bitcoin go to the receiver and which is the change of the inputs.
And last but not least, the "security reason" is because every bitcoin addresses is just a hash of a public key, so someone with a working quantum computer can't attack the public key (as he can only see a hash of the key, not the key itself). But whenever you need to spend bitcoins, you need to reveal the public key, so all addresses that have previously spend bitcoins will be "vulnerable" (but new addresses wont).
-
2So the answer to the question in the title is "Yes". Commented Mar 7, 2013 at 11:22
-
1How about "does it generate a new address each time this is done, or first searches the wallet if there is an empty address there already?" I am specifically interested in whether externally imported keys will be eventually used for the change (if unused before) or if the change always comes to an address previously non-existing in the wallet?– TibetCommented Mar 8, 2013 at 20:56
-
That "public key" explanation doesn't make much sense: public keys are public, private keys are private, and there's no reason (nor way) to "protect" public keys.– o0'.Commented Apr 29, 2013 at 8:56
-
I did not say that public keys ain't public, I said that bitcoin addresses are hashes of public keys. And attacking the hash of the key is much harder than attacking the key (i.e. you "protect" the public key by not revealing it). When you spend bitcoins, you need to reveal the public key, but at the same time you move all bitcoins on the address to a new address with a new undisclosed public key. So any attackers will only have a very small timeframe to attack your public key (vs having as much time as a reused address has bitcoins on it)– NicolaiCommented Apr 29, 2013 at 15:09
Yes, if there is change then it is sent to a new address. See https://en.bitcoin.it/wiki/Change
Of course if the sum of all output transactions used for the one input address (the receiver) is exactly the correct amount then no change is needed thus nothing is sent to a new address.
This will not change in future versions of the client because it is part of the Bitcoin design.