Bitcoin Forum

Other => Beginners & Help => Topic started by: danster82 on July 30, 2012, 08:37:35 PM



Title: What happens when you load an old .dat?
Post by: danster82 on July 30, 2012, 08:37:35 PM
What happens when you load an old wallet.dat into a new client where some bitcoins still exist but some dont, does the network simply work out the new balance and correct the .dat?


Title: Re: What happens when you load an old .dat?
Post by: someguy123 on July 30, 2012, 09:10:38 PM
Where some bitcoins exist, but some don't?
I'm confused, do you mean you've spent bitcoins from a newer wallet, and you're wishing to restore a wallet from before you've spent them?
Generally, with the latest bitcoin, it will automatically re-scan the blockchain in order to correct the balance displayed. If not, you can append the "-rescan" switch to your Bitcoin shortcut.


Title: Re: What happens when you load an old .dat?
Post by: Gabi on July 30, 2012, 09:14:40 PM
Wallet.dat just contain your private keys, then the client check the blockchain and check how many bitcoins do these keys have.

(yes it contains more info than that, but what matter are the private keys, the rest are useful things to speed up things if i'm right)


Title: Re: What happens when you load an old .dat?
Post by: Epoch on July 30, 2012, 09:27:14 PM
What happens when you load an old wallet.dat into a new client where some bitcoins still exist but some dont, does the network simply work out the new balance and correct the .dat?
Short answer: yes. However, there is nothing to 'correct'.

The wallet.dat file does not record your coin balance; it contains (secret) keys associated with your public bitcoin addresses. The transaction history of all bitcoins (and, by extension, your current balance) is kept in the public blockchain, separate from your wallet.dat file.

Simply, the bitcoin client scans the blockchain and finds transactions associated with the keys in your wallet.dat. It then 'knows' your current balance and transaction history.

Loading an old wallet.dat into a new client will not affect any of this, since both new and old wallet.dat files contain the same keys. Thus the client will come to the same result when it scans the blockchain.

One caveat is that if you had generated many (100+) new addresses in your new wallet.dat, some of those new addresses may not exist in your old wallet.dat file. Thus if you were to load the old one, transactions associated with the new addresses would not be counted properly. My details may be off, but it works something like this: a 'fresh' wallet.dat contains keys for 100 or so addresses. After you exhaust those, another block of 100 keys/addresses is automatically generated. If this is triggered, the new wallet.dat file will contain the new addresses, but your old one won't.

Thus it is good practice to regularly backup your wallet.dat file to ensure you always have all your addresses.


Title: Re: What happens when you load an old .dat?
Post by: danster82 on July 30, 2012, 10:47:22 PM
Ok got it, so all bitcoins are stored on the network, the .dat stores your keys to the associated bitcoins. If I load an old .dat with keys to bitcoins ive spent those keys are now useless and so it will automativccaly readjust the client wallet balance?

I assume it deletes the useless keys also?


Title: Re: What happens when you load an old .dat?
Post by: Gabi on July 30, 2012, 10:52:49 PM
useless keys? spent keys?

no key is "useless" and it will never automatically delete a key! An empty key can still be used as a receiving address, so if you delete it and someone you previously gave that address send you bitcoins to that address, bad bad thing, you don't have the key to use them...

If you have a chest and empty it, you don't trash it, or trash its key  :D it can still be useful...


Title: Re: What happens when you load an old .dat?
Post by: Epoch on July 30, 2012, 11:48:32 PM
Ok got it, so all bitcoins are stored on the network, the .dat stores your keys to the associated bitcoins. If I load an old .dat with keys to bitcoins ive spent those keys are now useless and so it will automativccaly readjust the client wallet balance?

I assume it deletes the useless keys also?
Keys are not associated with bitcoins directly; they are associated with your receiving addresses. The Client uses those keys to determine which addresses in the blockchain (and thus which transactions) belong to your wallet.dat. You can have numerous transactions going to (or coming from) the same address. Whether you have sent, or received, however many bitcoins in the past does not affect those keys. You will always have them.


Title: Re: What happens when you load an old .dat?
Post by: FAKE daniel daniel on July 31, 2012, 02:59:42 AM
good question i was wonder same thing


Title: Re: What happens when you load an old .dat?
Post by: Dargo on July 31, 2012, 03:56:47 AM
Whatever happens, I'm pretty sure it's better than when you date and old load.


Title: Re: What happens when you load an old .dat?
Post by: DanielVG on July 31, 2012, 05:46:40 AM
good info, thanks guys


Title: Re: What happens when you load an old .dat?
Post by: stepkrav on July 31, 2012, 09:35:54 AM
if i download a new client version, does it overwrite the old .dat file or just use the existing?


Title: Re: What happens when you load an old .dat?
Post by: John (John K.) on July 31, 2012, 09:38:03 AM
if i download a new client version, does it overwrite the old .dat file or just use the existing?
Not too sure about that, but it's a good practice that you backup your wallet.dat file religiously, and keep it encrypted. If a new wallet.dat file is installed, just overwrite it with your existing one.


Title: Re: What happens when you load an old .dat?
Post by: DanielVG on August 01, 2012, 05:29:27 PM
pretty obvious