Bitcoin Forum
November 17, 2017, 07:53:25 PM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Questions about wallet.dat  (Read 875 times)
Bowjob
Sr. Member
****
Offline Offline

Activity: 294



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.
1510948405
Hero Member
*
Offline Offline

Posts: 1510948405

View Profile Personal Message (Offline)

Ignore
1510948405
Reply with quote  #2

1510948405
Report to moderator
Coinlancer is Disrupting the Freelance marketplace!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1510948405
Hero Member
*
Offline Offline

Posts: 1510948405

View Profile Personal Message (Offline)

Ignore
1510948405
Reply with quote  #2

1510948405
Report to moderator
yogi
Legendary
*
Offline Offline

Activity: 947


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
Sr. Member
****
Offline Offline

Activity: 294



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: 1078


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



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
Sr. Member
****
Offline Offline

Activity: 294



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: 1078


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
*
Online Online

Activity: 1974



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



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



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


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
Jr. Member
*
Offline Offline

Activity: 57


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
*
Online Online

Activity: 1974



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
Jr. Member
*
Offline Offline

Activity: 57


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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!