Author

Topic: question: change addresses, multiple transactions, wallet backups in bitcoin-QT (Read 2928 times)

legendary
Activity: 3472
Merit: 4801
Sorry to dredge up this old thread, but it is the top google hit for wallet backup change address because it addresses the important issue of wallet security for non-technical people who are smart enough to keep backups.

I just wanted to call out DannyHamilton for this excellent explanation:
Quote
Anytime it needs a new address (for change, or because you clicked the "New Address" button), it takes it from this queue of addresses that are already stored in the wallet.dat and then adds a new address on to the end of the file.

It would be a simple matter to record the timestamp each time the "backup wallet" function was used.  This would allow the client to indicate "X bitcoin addresses left before a new backup is required."

If I don't see a reply that someone has proposed this to the development team (or implemented it and pushed the change to github), I may get around to it myself someday.  If I do, well, include a bitcoin address so I can thank you!

I'm not certain, but I think I read that the latest version 0.9.x takes an address from the pool, but doesn't generate the replacement address right away.  Replacement addresses are only generated in situations where the user is already being asked to enter their password.

If the pool becomes empty, then the user is prompted to enter their password so the wallet can rebuild the entire pool.

Of course, many people choose to create copies of the wallet.dat file directly, and even automate that process.  This wouldn't trigger the recording of the timestamp, so it might be nice to have some way to override (or turn off) the indicator if you add it.
sr. member
Activity: 444
Merit: 250
I prefer evolution to revolution.
Sorry to dredge up this old thread, but it is the top google hit for wallet backup change address because it addresses the important issue of wallet security for non-technical people who are smart enough to keep backups.

I just wanted to call out DannyHamilton for this excellent explanation:
Quote
Anytime it needs a new address (for change, or because you clicked the "New Address" button), it takes it from this queue of addresses that are already stored in the wallet.dat and then adds a new address on to the end of the file.

It would be a simple matter to record the timestamp each time the "backup wallet" function was used.  This would allow the client to indicate "X bitcoin addresses left before a new backup is required."

If I don't see a reply that someone has proposed this to the development team (or implemented it and pushed the change to github), I may get around to it myself someday.  If I do, well, include a bitcoin address so I can thank you!
sr. member
Activity: 332
Merit: 250
AwesomeDice.net
That's inherent of using any backup. Between a current copy and a backup, things have changed. So between those, information always is lost. But maybe it can't hurt to tell people that that should be done before someone used up 100 addresses. But Bitcoin-QT isn't perfect, and because you run it yourself it's your responsibility. With online wallets you don't have this problem, except you have to trust the company behind it.
newbie
Activity: 14
Merit: 0

It seems that Bitcoin-Qt was created with the assumption that people would install it and use it.  (Not play around with deleting some of its data files, moving pieces to other drives, and importing and exporting keys)

For the average user that expects to be able to send and receive money like they do with a bank account, it would only add confusion to show these "change" addresses.  This is a protocol layer technical detail, and the wallet is designed to add a layer of abstraction so the user only needs to think about where they want to send the money, and how much they want to send (without needing to know all the intricate technical details about how such a transaction is handled at the protocol level).

Those who intend to use the software in advanced technical ways, are expected to know what they are doing.

As an alanogy: If I want to drive my car, I put the key in, turn it, move the lever to the "D" position and push the pedal near the floor.  I don't need to understand gear ratios, compression ratios, fueal air mixtures, torque, valve timing, etc.  If I decide that I want to play around with modfying valve timing, or replacing the fuel with an alternative fuel, then I'm expected to either understand fully what I am doing, or suffer the consequences.


Thanks for the helpful answers, but I don't agree your above analogy.
The bitcoin-qt client expects users to make backups of the wallet.dat file, it offers a 'backup wallet' option in the menu.  So I would say it expects that this particular data file will be stored on other drives for future restoration.

There's nothing 'advanced' about restoring a backed up wallet file.

But there is no warning in the software that, as you've explained, any backup will only be good as long as it doesn't get older than 100 addresses/transactions behind the live wallet, after which any change the user receives will be going into addresses that the backup knows nothing about and can never access.

That means lost coins, possibly amounting to a huge sum of money, and there's no warning of that in the software. If bitcoin wants mass adoption and wants to be taken seriously for handling large sums, the official wallet client has to either show all the addresses coins are being stored in, so the user knows exactly where their money is, or it should warn (and warn in very big letters) that backups older than 100 transactions will lose some of your coins.
legendary
Activity: 3472
Merit: 4801
For security, say I am normally storing my wallet.dat in an encrypted folder on external USB sticks, and don't keep it on the hard drive, having created addresses in this wallet previously.  So I let bitcoin-qt client start up, and sync with network to catch up with the blockchain.  The wallet.dat that bitcoin-qt sees at this point is an empty one, the one it creates by default.

Now to make a payment I disconnect from the net, quit bitcoin client, and copy my backed up wallet.dat onto hard drive, overwriting the empty wallet.dat.  Start bitcoin client, bitcoin-qt sees my real wallet and knows my balance, I enter all the payment details, re-connect to the net and hit send.  Disconnect from net.  This means my actual wallet is exposed to an online machine for the minimum time, for security.

If you're really going to go through all that effort, you should seriously consider getting a cheap second computer to keep offline at all times and just running Armory.

Q1 - is best practice that I should now make a backup of the wallet.dat I just used, rather than just delete it and rely upon my earlier backups?   I'm thinking that the (hidden) change address that bitcoin created to arrange for my 0.4995 to be sent back to me will be one that my earlier backed up wallets will not know about, so would I lose the change if I don't make fresh backups every time I send BTC in this way?

By default, Bitcoin-Qt pre-generates 100 private keys / addresses when it creates a new wallet.dat.  Anytime it needs a new address (for change, or because you clicked the "New Address" button), it takes it from this queue of addresses that are already stored in the wallet.dat and then adds a new address on to the end of the file.

As such, the backup that you have already has the "change" address in it as long as you created the backup less than 100 addresses/transactions ago.

Q2 - if I want to simultaneously send the 1.0005 BTC out, and at the same time clear out all remaining funds in that address by doing another transaction that sends 0.4995 BTC to another address of mine, is that possible right away, or do I have to wait?

It is possible to do right away.  In the "send" tab, you can choose to "Add Recipient" to send to more than one person/address with a single transaction.

I'm thinking here that my first transaction has effectively used up all my 1.5 BTC, and until the change comes back (i.e. until the blocks are created that confirm the transaction), I don't have any more funds to send?  Is that correct?

No.  Bitcoin-Qt is aware of the transactions that it creates.  It trusts itself not to double spend a transaction that it is sending to itself, so it allows you to use the outputs of that transaction that are sent back to yourself immediately in another transaction (although that next transaction will likely require a transaction fee since the inputs won't have built up enough priority yet).

So I have to wait 10 mins for the first block, and longer for confirmations to be safe, before I can then send the 0.4995 anywhere?

Generally, most users won't run into such a problem.  However, if you are swapping wallet.dat files in and out, and you are sending a transaction with one wallet.dat to an address that is only in some other wallet.dat, then yes you'll have to wait for confirmations before Bitcoin-Qt will let you use the bitcoins.

Q3 - I am wondering why the default behaviour of bitcoin-qt client is that change is sent back to a hidden address?  I'm sure there must be some reason which I haven't understood.  Isn't hiding the change address going to result in a lot of ppl not realising it's in a hidden address, and what if they lose access to it through not realising they need to know the private keys of not only the addresses they have openly created, but the private keys of these hidden change addresses that the client has secretly created as well?

It seems that Bitcoin-Qt was created with the assumption that people would install it and use it.  (Not play around with deleting some of its data files, moving pieces to other drives, and importing and exporting keys)

For the average user that expects to be able to send and receive money like they do with a bank account, it would only add confusion to show these "change" addresses.  This is a protocol layer technical detail, and the wallet is designed to add a layer of abstraction so the user only needs to think about where they want to send the money, and how much they want to send (without needing to know all the intricate technical details about how such a transaction is handled at the protocol level).

Those who intend to use the software in advanced technical ways, are expected to know what they are doing.

As an alanogy: If I want to drive my car, I put the key in, turn it, move the lever to the "D" position and push the pedal near the floor.  I don't need to understand gear ratios, compression ratios, fueal air mixtures, torque, valve timing, etc.  If I decide that I want to play around with modfying valve timing, or replacing the fuel with an alternative fuel, then I'm expected to either understand fully what I am doing, or suffer the consequences.
hero member
Activity: 619
Merit: 500
Q3 makes a very good point.
I did loose some bitcoins in the very beginning because of this.
sr. member
Activity: 332
Merit: 250
AwesomeDice.net
A1 - I know the wallet.dat file contains a pool of addresses, so if you don't use a lot of addresses it wouldn't be necessary to backup. But I would do it anyway if I were you, because it could happen. Also your new wallet.dat file contains previous transactions, that way you know what your balance is.
A2 - You can do that right away, because you own the change address.
A3 - For the ones not tech savvy, they shouldn't be bothered dealing with different addresses I think. Maybe it isn't perfect yet, still waiting for some killer app.
newbie
Activity: 14
Merit: 0
Hi there. Total newbie questions, I've done lots of googling & youtube-ing about bitcoin, but am not clear about the following issues.  Would like to be clear before I start trying to actually move any funds.  Could someone advise please?  Sorry about length of my questions.


I've installed the bitcoin-qt client.  
Say I have 1.5 BTC in my confirmed balance, that all came from one single receipt of 1.5 BTC.  So this is all on one address in my wallet.
Say I want to send 1 BTC to some address.
I enter the details to make the payment, incl. say a 0.0005 transaction fee for the miners, and send.  My remaining balance would be  0.4995 BTC.

I understand that when I send bitcoins to some other address, in the above case the client will send out the 1.5 BTC from my previous transaction balance, sending 1 BTC to the address I am paying, plus the 0.0005 BTC transaction fee, and send the change of 0.4995 BTC back to me, to a 'change address' that is hidden in the client.  

For security, say I am normally storing my wallet.dat in an encrypted folder on external USB sticks, and don't keep it on the hard drive, having created addresses in this wallet previously.  So I let bitcoin-qt client start up, and sync with network to catch up with the blockchain.  The wallet.dat that bitcoin-qt sees at this point is an empty one, the one it creates by default.

Now to make a payment I disconnect from the net, quit bitcoin client, and copy my backed up wallet.dat onto hard drive, overwriting the empty wallet.dat.  Start bitcoin client, bitcoin-qt sees my real wallet and knows my balance, I enter all the payment details, re-connect to the net and hit send.  Disconnect from net.  This means my actual wallet is exposed to an online machine for the minimum time, for security.    

Q1 - is best practice that I should now make a backup of the wallet.dat I just used, rather than just delete it and rely upon my earlier backups?   I'm thinking that the (hidden) change address that bitcoin created to arrange for my 0.4995 to be sent back to me will be one that my earlier backed up wallets will not know about, so would I lose the change if I don't make fresh backups every time I send BTC in this way?

Q2 - if I want to simultaneously send the 1.0005 BTC out, and at the same time clear out all remaining funds in that address by doing another transaction that sends 0.4995 BTC to another address of mine, is that possible right away, or do I have to wait?

I'm thinking here that my first transaction has effectively used up all my 1.5 BTC, and until the change comes back (i.e. until the blocks are created that confirm the transaction), I don't have any more funds to send?  Is that correct?  So I have to wait 10 mins for the first block, and longer for confirmations to be safe, before I can then send the 0.4995 anywhere?

Q3 - I am wondering why the default behaviour of bitcoin-qt client is that change is sent back to a hidden address?  I'm sure there must be some reason which I haven't understood.  Isn't hiding the change address going to result in a lot of ppl not realising it's in a hidden address, and what if they lose access to it through not realising they need to know the private keys of not only the addresses they have openly created, but the private keys of these hidden change addresses that the client has secretly created as well?

Thanks for your help in understanding the above.
Jump to: