Author

Topic: Questions about wallet.dat (Read 969 times)

newbie
Activity: 57
Merit: 0
January 20, 2013, 03:26:49 PM
#14
Another thing that might be good to know (correct me if I'm wrong):

When you encrypt your wallet, the keypool with your spare private keys is flushed and a new set of spare addresses is created.
This means that you should update your backups immediately if you encrypt your wallet, otherwise you might loose some/all of your coins when you send a transaction and try to recover/restore your wallet with your backups.

Nope. You're not wrong.

As a matter of fact, this other guy mentioned it a few posts back in this thread:

. . . Also be aware that when you encrypt your wallet, it tosses out the entire 100 address pool, and generates a new set of 100 addresses.  If you create a backup before encrypting, it won't be good for very long after encrypting.

Whoops, sorry...
legendary
Activity: 3472
Merit: 4801
January 20, 2013, 03:23:43 PM
#13
Another thing that might be good to know (correct me if I'm wrong):

When you encrypt your wallet, the keypool with your spare private keys is flushed and a new set of spare addresses is created.
This means that you should update your backups immediately if you encrypt your wallet, otherwise you might loose some/all of your coins when you send a transaction and try to recover/restore your wallet with your backups.

Nope. You're not wrong.

As a matter of fact, this other guy mentioned it a few posts back in this thread:

. . . Also be aware that when you encrypt your wallet, it tosses out the entire 100 address pool, and generates a new set of 100 addresses.  If you create a backup before encrypting, it won't be good for very long after encrypting.
newbie
Activity: 57
Merit: 0
January 20, 2013, 03:03:26 PM
#12
Another thing that might be good to know (correct me if I'm wrong):

When you encrypt your wallet, the keypool with your spare private keys is flushed and a new set of spare addresses is created.
This means that you should update your backups immediately if you encrypt your wallet, otherwise you might loose some/all of your coins when you send a transaction and try to recover/restore your wallet with your backups.
legendary
Activity: 947
Merit: 1042
Hamster ate my bitcoin
January 20, 2013, 02:44:06 PM
#11
If you want a wallet that you only ever have to backup once you should look at using a deterministic wallet. All private keys and addresses are generated from a seed, as long as you have the seed backed up, you can recreate your wallet if it gets deleted.
hero member
Activity: 812
Merit: 1000
January 19, 2013, 06:57:58 PM
#10
So it's wisest to backup a wallet, say, once a week or so to insure that the private keys are up to date?

yes, if you do 100 transactions per week.

if you do 100 transactions per year, then back up once per year.

different for everybody.
member
Activity: 112
Merit: 16
January 19, 2013, 06:53:42 PM
#9
Whoa!  Hang on!  You are getting some advice that can get you into trouble, since you don't have the full picture.

It is correct that all the transactions (both to you and from you) are stored in the public blockchain that all full nodes have a complete copy of.  So as long as you have the correct private keys in your wallet.dat file, it will sync up no matter how old the wallet.dat file is.

However, what nobody has explained clearly to you yet is that the wallet.dat file has a limited number of private keys in it.

Each of your bitcoin addresses is associated with exactly one private key in your wallet.dat.  However, every time you create a transaction to send bitcoins, your client also may create a special bitcoin address that it keeps hidden from you and sends some of your coins there.  Those coins still show up in your wallet balance because your client stores these hidden addresses and their private keys in your wallet.dat.  This means that even if you only have 5 bitcoin addresses in your "receive coins" tab in the user interface, if you have sent bitcoins 10 times, you probably actually have 15 addresses in your wallet.dat file (1 for each address in "receive coins, AND one for each transaction when you sent coins).

The client file pre-generates 100 addresses along with the associated private keys. So when you request a new address from the client (or when it needs a new address for the "change" in a transaction where you sent bitcoins), rather than generating a new one for you it grabs the next one from this pool of pre-generated addresses and then generates a new one to take its place in the pool.

This means that when you back-up wallet.dat, you are backing up all of the private keys that you are currently using AND the next 100 addresses that the client will use in the future.  If you generate a bunch of new addresses and/or create a bunch of transactions to send bitcoins, you'll need to make sure that you backup the wallet.dat again before you've used up 100 addresses or you could lose your bitcoins permanently.

As an example:

User has Bitcoin-QT client and only has the original address when he starts it up.
User backs up wallet.dat.
User receives 100 BTC in a single transaction output to that address and never receives any other bitcoins to this wallet.
User performs 110 transactions sending 0.01 BTC each time
User's wallet shows a balance of 98.9 BTC
User deletes and re-installs the client, then replaces wallet.dat with the backup.
User waits for the client to sync.
User discovers the wallet shows a balance of 0 BTC, and has permanently lost all access to the 98.9 BTC.

So keep in mind that you will want to have a recent copy of the wallet.dat.  It isn't enough to just have an old copy.  How recent it needs to be depends on how many addresses you generate and how many transactions you send.

Also be aware that when you encrypt your wallet, it tosses out the entire 100 address pool, and generates a new set of 100 addresses.  If you create a backup before encrypting, it won't be good for very long after encrypting.

+1 for an excellent post. I didn't know any of that. So it's wisest to backup a wallet, say, once a week or so to insure that the private keys are up to date?
legendary
Activity: 3472
Merit: 4801
January 19, 2013, 06:35:57 PM
#8
Whoa!  Hang on!  You are getting some advice that can get you into trouble, since you don't have the full picture.

It is correct that all the transactions (both to you and from you) are stored in the public blockchain that all full nodes have a complete copy of.  So as long as you have the correct private keys in your wallet.dat file, it will sync up no matter how old the wallet.dat file is.

However, what nobody has explained clearly to you yet is that the wallet.dat file has a limited number of private keys in it.

Each of your bitcoin addresses is associated with exactly one private key in your wallet.dat.  However, every time you create a transaction to send bitcoins, your client also may create a special bitcoin address that it keeps hidden from you and sends some of your coins there.  Those coins still show up in your wallet balance because your client stores these hidden addresses and their private keys in your wallet.dat.  This means that even if you only have 5 bitcoin addresses in your "receive coins" tab in the user interface, if you have sent bitcoins 10 times, you probably actually have 15 addresses in your wallet.dat file (1 for each address in "receive coins, AND one for each transaction when you sent coins).

The client file pre-generates 100 addresses along with the associated private keys. So when you request a new address from the client (or when it needs a new address for the "change" in a transaction where you sent bitcoins), rather than generating a new one for you it grabs the next one from this pool of pre-generated addresses and then generates a new one to take its place in the pool.

This means that when you back-up wallet.dat, you are backing up all of the private keys that you are currently using AND the next 100 addresses that the client will use in the future.  If you generate a bunch of new addresses and/or create a bunch of transactions to send bitcoins, you'll need to make sure that you backup the wallet.dat again before you've used up 100 addresses or you could lose your bitcoins permanently.

As an example:

User has Bitcoin-QT client and only has the original address when he starts it up.
User backs up wallet.dat.
User receives 100 BTC in a single transaction output to that address and never receives any other bitcoins to this wallet.
User performs 110 transactions sending 0.01 BTC each time
User's wallet shows a balance of 98.9 BTC
User deletes and re-installs the client, then replaces wallet.dat with the backup.
User waits for the client to sync.
User discovers the wallet shows a balance of 0 BTC, and has permanently lost all access to the 98.9 BTC.

So keep in mind that you will want to have a recent copy of the wallet.dat.  It isn't enough to just have an old copy.  How recent it needs to be depends on how many addresses you generate and how many transactions you send.

Also be aware that when you encrypt your wallet, it tosses out the entire 100 address pool, and generates a new set of 100 addresses.  If you create a backup before encrypting, it won't be good for very long after encrypting.
legendary
Activity: 1148
Merit: 1008
If you want to walk on water, get out of the boat
January 19, 2013, 04:12:26 PM
#7
Yeah. Just make sure you never lose the right wallet.dat. Note that when you send coins the change for that transaction is put in a new address, so a backup wallet can get outdated (since it would not have that new address)
sr. member
Activity: 294
Merit: 250
January 19, 2013, 04:08:33 PM
#6
All right thanks. Last question. Suppose I delete the whole Bitcoin program and I reinstall it. All I have to do is replace wallet.dat with my backup wallet.dat and everything is gravy, right?
member
Activity: 112
Merit: 16
January 19, 2013, 04:04:28 PM
#5
Suppose you back up your wallet.dat, and someone sends bitcoins to one of your addresses, will that backup be rendered obsolete?

No, transactions are recorded in the blockchain, not your wallet.

How about lets say I have 80 btc backup, then I spend some of that btc.. backup be obsolete then?

No, for the same reason as the last answer. Your transactions are recorded in the blockchain online. The wallet file just gives you access to your funds: it does not actually hold the amount of BitCoins. If you made a back up wallet a year ago and opened it today, it would sync with the blockchain to reflect the current amount in the wallet, regardless of how much BTC you had at the time of the back up.
legendary
Activity: 1148
Merit: 1008
If you want to walk on water, get out of the boat
January 19, 2013, 04:02:59 PM
#4
Wallet.dat hold the keys. The backup is obsolete only if you have new addresses in the other wallet.dat.
sr. member
Activity: 294
Merit: 250
January 19, 2013, 03:59:17 PM
#3
Suppose you back up your wallet.dat, and someone sends bitcoins to one of your addresses, will that backup be rendered obsolete?

No, transactions are recorded in the blockchain, not your wallet.

How about lets say I have 80 btc backup, then I spend some of that btc.. backup be obsolete then?
legendary
Activity: 947
Merit: 1042
Hamster ate my bitcoin
January 19, 2013, 03:56:34 PM
#2
Suppose you back up your wallet.dat, and someone sends bitcoins to one of your addresses, will that backup be rendered obsolete?

No, transactions are recorded in the blockchain, not your wallet.
sr. member
Activity: 294
Merit: 250
January 19, 2013, 03:54:50 PM
#1
Suppose you back up your wallet.dat, and someone sends bitcoins to one of your addresses, will that backup be rendered obsolete?
Jump to: