What information does a wallet contain?

16

6

What information does the Bitcoin wallet file used by the Bitcoin.org client contain?

Is the owner's Bitcoin balance written in the wallet.dat file, or does it contain a list of transactions that have been made since the beginning of wallet creation? Does the wallet's filesize grow bigger as more transactions are made?

uray

Posted 2012-03-15T13:19:23.460

Reputation: 547

The one important thing contained in the wallet is the secret (private key or keys) needed to access your Bitcoin address(es), one for each. Everything else depends on your specific client. Also note that clients may or may not preallocate future Bitcoin addresses for you in your wallet file, and may or may not update that in the future (hence possibly requiring regular rather than one-off backups).pyramids 2013-11-13T14:31:57.677

Now that there are clients with their own wallet formats, I clarified the question by specifying that it is referring to the Bitcoin.org client.Stephen Gornick 2012-03-15T19:38:40.913

Answers

13

From looking at the code, the wallet.dat can contain entries of the following types:

  • name - an address book name
  • tx - a transaction
  • acentry - an accounting entry
  • key - a pair of public and private keys
  • mkey - a master key
  • ckey - an encrypted key
  • defaultkey - the default receiving address' key
  • pool - a keypool entry
  • version - the version of the software that wrote this wallet
  • minversion - the earliest version of the software that can read this wallet
  • cscript - a script
  • bestblock - a pointer to the end of the best blockchain seen
  • wkey - a private key (no longer used)
  • setting - used to store user interface settings (no longer used, except to hold an invalid setting to stop pre-0.4.0 versions of the client which don't understand minversion from loading wallets that are too new for them)

See also this answer.

Chris Moore

Posted 2012-03-15T13:19:23.460

Reputation: 13 952

wkey is not used anymore, afaik, it is a private key with some metadata. key contains both public and private key. There is also 'bestblock' with a locator of the last seen tip of the blockchain.Pieter Wuille 2012-03-15T18:15:38.877

2

A default bitcoin wallet contains a list of private and pub key pairs. A number of keys are created on generation this is to allow for "swap" as you send money from it, these are not visible directly. This does not affect your balance which you use.

Your transactions are stored within the blockchain. If you generate new address to receive to then your wallet size will grow. If your wallet is moved to a new computer, with no blockchain, it will appear empty until you download blocks up until your transactions are known by the client.

MaxSan

Posted 2012-03-15T13:19:23.460

Reputation: 3 680

Yes, but the wallet also contains a copy of the transactions that affect your balance. If you restore an old backup of wallet.dat you'll find it is missing transactions that happened after the backup until you use the -rescan command line option to get it to look through the blockchain and copy the relevant new transactions into the wallet.dat.Chris Moore 2012-03-15T15:23:26.237

Not all clients store this information as far as im aware.MaxSan 2012-03-15T15:24:48.090

I guess I assumed the question was about the Satoshi client. Is there another one which keeps its wallet in "wallet.dat" and rescans the entire blockchain every time you run it?Chris Moore 2012-03-15T17:30:16.927

Your correct. I took wallet as generic rather than the specific client. Il modify my answer.MaxSan 2012-03-15T19:01:13.007