AFAIK there isn't any documentation of
dumpwallet's output. You need to read the source code to know. I suppose I can just document it here though.
dumpwallet output contains comments. Comments are prefixed by a
#. This can be found at the beginning of a line or in the middle. Anything on that line following the
# is a comment and will not be parsed by
importwallet. Comments are used to provide additional information to the user reading the
dumpwallet output but prevent the
importwallet parser from doing anything with the data in the comment.
The first 4 lines are just some extra information to the user to know which version created the dump and at what time. It includes the current clock time as well as the time and hash of the current best block.
For HD wallets, this is followed by the extended master private key.
After that, each line lists out an individual private key and some metadata about that private key. The private key will be encoded using the Wallet Import Format.
The private key will then be followed by a timestamp. This timestamp is in UTC time and is the time that the private key was created and added to the wallet.
Each private key will have one of the following metadata fields:
inactivehdseed, or `change.
label: This is a label assigned to one of the addresses for this private key. Since a single private key can have multiple addresses, and each of those addresses a different label, this just gets one of this labels. It's a holdover from when one private key corresponded to one address. All receiving addresses will have a
label even if it does not have a label. For those addresses, the label is the empty string so you may see
label= a lot.
hdseed: This private keys is the current active HD seed. You will always see this field as
hdseed=1. The HD seed is a BIP 32 seed. Bitcoin Core stores this as a private key and it is therefore indistinguishable from other private keys. This HD seed is used to produce the extended master private key found earlier. It may also be used to derive many of the other private keys in this wallet. There should only be one key with
reserve: This indicates that the private key is part of the keypool. You will always see this as
reserve=1. The key has not been requested for use as a receiving address nor as a change address, it is in reserve in the keypool.
inactivehdseed: This private key was a HD seed previously used by the wallet but is no longer the currently active HD seed. You will always see this as
inactivehdseed=1. It is the same meaning as the key with
hdseed=1 except it is not currently active.
change: This key is no longer in the keypool and it's address is not a receiving address. The assumption is that such addresses are change addresses. So this key is marked as being change by having this metadata field. You will always see it as
Following the metadata, on the same line, will be a comment with some additional metadata that may be useful to the user but will not be parsed by
importwallet. This will have 2 fields:
addr: This is a comma separate list of addresses that have been used for this private key. Since a single private key can have multiple addresses, you may see multiple addresses in this field.
hdkeypath: This is a string representing the BIP 32 derivation path for this private key. In cases where there is only one key marked as
hdseed=1, you can derive this private key by using the extended master private key at the top of the file and then deriving from it the key with this derivation path. When there are multiple HD seeds in a wallet (i.e. when there are
inactivehdseed=1 keys), it is not possible to know which seed this key was derived from without trying to derive from them all.
After each of the private keys is listed, you will see lines for scripts stored in the wallet. This is similar to how private keys are listed.
Each script is written out in hexadecimal. The script is then followed by a timestamp indicating the time that the script was added to the wallet. It will then be followed by
script=1 to indicate that this line is for a script. Lastly there will be a comment containing an
addr field. This address will be the P2SH address for this script.
At the end of the file is a comment
End of dump to indicate the end of the wallet dump.
When you use
dumpwallet, you should expect to see several thousand lines. This is because Bitcoin Core, by default, has a keypool of 1000 receiving keys and 1000 change keys. For a newly created wallet, there will be 2000 key lines.
If you have not imported any scripts, you should have the same number of key lines as script lines. This is because each key has a segwit script. This is an artifact of how the Bitcoin Core wallet supports segwit.
If you have imported any scripts such as multisig scripts or addresses which are not yours, then you will see those scripts in the script lines as well.