Bitcoin Forum
May 13, 2024, 10:33:51 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Questions about wallet.dat  (Read 950 times)
Bowjob (OP)
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250



View Profile
January 19, 2013, 08: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?

It seemed like a good idea at the time.
"I'm sure that in 20 years there will either be very large transaction volume or no volume." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715639631
Hero Member
*
Offline Offline

Posts: 1715639631

View Profile Personal Message (Offline)

Ignore
1715639631
Reply with quote  #2

1715639631
Report to moderator
yogi
Legendary
*
Offline Offline

Activity: 947
Merit: 1042


Hamster ate my bitcoin


View Profile
January 19, 2013, 08: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.

Bowjob (OP)
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250



View Profile
January 19, 2013, 08: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?

It seemed like a good idea at the time.
Gabi
Legendary
*
Offline Offline

Activity: 1148
Merit: 1008


If you want to walk on water, get out of the boat


View Profile
January 19, 2013, 09:02:59 PM
 #4

Wallet.dat hold the keys. The backup is obsolete only if you have new addresses in the other wallet.dat.

21after2
Member
**
Offline Offline

Activity: 112
Merit: 16



View Profile
January 19, 2013, 09: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.
Bowjob (OP)
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250



View Profile
January 19, 2013, 09: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?

It seemed like a good idea at the time.
Gabi
Legendary
*
Offline Offline

Activity: 1148
Merit: 1008


If you want to walk on water, get out of the boat


View Profile
January 19, 2013, 09: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)

DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
January 19, 2013, 11: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.
21after2
Member
**
Offline Offline

Activity: 112
Merit: 16



View Profile
January 19, 2013, 11: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?
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
January 19, 2013, 11: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.
yogi
Legendary
*
Offline Offline

Activity: 947
Merit: 1042


Hamster ate my bitcoin


View Profile
January 20, 2013, 07: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.

BC12345
Newbie
*
Offline Offline

Activity: 57
Merit: 0


View Profile
January 20, 2013, 08: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.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
January 20, 2013, 08: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.
BC12345
Newbie
*
Offline Offline

Activity: 57
Merit: 0


View Profile
January 20, 2013, 08: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...
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!