Bitcoin Forum

Bitcoin => Bitcoin Discussion => Topic started by: gigabytecoin on June 16, 2011, 06:22:13 AM



Title: What data exactly is stored in a wallet.dat file?
Post by: gigabytecoin on June 16, 2011, 06:22:13 AM
And why is it not necessary to backup any of the other files in your bitcoin folder in order to re-create your wallet?

Also: will the "format" of a wallet ever change? Will it ever need to? Even in 50+ years?


Title: Re: What data exactly is stored in a wallet.dat file?
Post by: imperi on June 16, 2011, 06:30:44 AM
And why is it not necessary to backup any of the other files in your bitcoin folder in order to re-create your wallet?

Also: will the "format" of a wallet ever change? Will it ever need to? Even in 50+ years?

The wallet contains the public/private key pairs. The public keys are your addresses. These key pairs are matched with the blocks the client downloads from the network, I believe, to see how much money you have.

The format could change if everyone "agrees" on a new one and all the clients are modified. It might need to because SHA-2 could be broken, or other maybe there are other protocol deficiencies we don't know about yet.


Title: Re: What data exactly is stored in a wallet.dat file?
Post by: gigabytecoin on June 16, 2011, 07:04:10 AM
Thanks for that.

O.K. so I just loaded up my "backed up" wallet to a new ubuntu install and began downloading the blockchain.

How does my bitcoin client "know" that I have a balance on that wallet but that it is still "unconfirmed"? Doesn't it need to download the block chain to know that first? Or is individual transaction information associated with each address encoded in the wallet.dat file each time a transaction is made?


Title: Re: What data exactly is stored in a wallet.dat file?
Post by: NetTecture on June 16, 2011, 07:17:41 AM
Thanks for that.

O.K. so I just loaded up my "backed up" wallet to a new ubuntu install and began downloading the blockchain.

How does my bitcoin client "know" that I have a balance on that wallet but that it is still "unconfirmed"? Doesn't it need to download the block chain to know that first? Or is individual transaction information associated with each address encoded in the wallet.dat file each time a transaction is made?

You dont ahve any balance on the wallet. You have addresses. What the addresses contain is visible for everyonne in the blockchain.


Title: Re: What data exactly is stored in a wallet.dat file?
Post by: Stephen Gornick on June 16, 2011, 07:18:19 AM
Quote
What data exactly is stored in a wallet.dat file? )
 - http://en.bitcoin.it/wiki/Wallet

Also: will the "format" of a wallet ever change? Will it ever need to? Even in 50+ years?

We can't know what will happen in the future but we know that software changes and improves.  There will likely always be a way to import either the binary wallet data file itself or to export wallet data and import that data into the new system.

Related:
  - http://forum.bitcoin.org/?topic=2348.0


Title: Re: What data exactly is stored in a wallet.dat file?
Post by: mmortal03 on June 16, 2011, 07:26:58 AM
How does one read the wallet.dat in plain text?  Say I wanted to print out the keys and recreate it later in digital form, is that possible?


Title: Re: What data exactly is stored in a wallet.dat file?
Post by: gigabytecoin on June 16, 2011, 08:24:45 AM
How does one read the wallet.dat in plain text?  Say I wanted to print out the keys and recreate it later in digital form, is that possible?

It is possible to do. You have to encode the wallet.dat file to some kind of alpha-numeric format first however instead of binary code I believe.


Title: Re: What data exactly is stored in a wallet.dat file?
Post by: willphase on June 16, 2011, 08:30:09 AM
get db_dump from e.g. here (http://tortoisesvn.tigris.org/source/browse/tortoisesvn/trunk/ext/berkeley-db/db4.3-win32/bin/?pathrev=4019#dirlist) (or Google it)

then you can dump your database as hex strings, but you'll want to massage the data a bit to make it anything meaningful.  Be very careful when playing with your wallet.dat as it contains all your keys and you will lose all your BTC sent to those keys if you corrupt your wallet (always take backups!)

Will


Title: Re: What data exactly is stored in a wallet.dat file?
Post by: titeuf_87 on June 16, 2011, 09:32:25 AM
The bitcointools (https://github.com/gavinandresen/bitcointools) made by Gavin has an utility to parse your wallet.dat and parse the data stored in there.


Title: Re: What data exactly is stored in a wallet.dat file?
Post by: jerfelix on June 16, 2011, 11:50:29 AM
https://en.bitcoin.it/wiki/Wallet

A Bitcoin wallet contains[1]:

    your keypairs for each addresses
    transactions done from/to your addresses
    user preferences
    default key
    reserve keys
    accounts
    a version number
    Key pool
    Since 0.3.21: information about the current best chain, to be able to rescan automatically when restoring from a backup.


So a Wallet file contains all your transaction history (which is also stored in the Block Chain).  Of course, the Block Chain's version is the "official" version of the transaction history (so people can't modify their wallet to suddenly have more money).

It's possible to run bitcoin with the -rescan option to recreate your transaction history (a great way to recover lost coins), but this will only work based on what keypairs you have in your wallet.  So if you execute 200 transactions and then restore an old wallet, and then -rescan, you could be missing a lot of Bitcoins.