Skip to content

Wallet Backup

Rick edited this page May 3, 2021 · 13 revisions

Overview

Backing up your Zero wallet and/or private keys is an important part of managing your valuable digital asset and the best way to prevent loss of access to your Zero coins. Computer or storage device failures, operator errors or bugs in the code may result in loss or corruption of your wallet (and the private keys required to spend Zero from your addresses). We highly recommend backups on a regular basis, and specifically after a new transparent or shielded address is generated.

These instructions are specific to the official Zero Wallet. For backing up third-party wallets, please consult their user guides and support channels.

All Zero Mobile wallets provide your secret phrase & private keys in the settings menu! Make sure to backup both.


Copy wallet file

Zero wallet file, named wallet.zero, is located in the same data directory as the configuration file zero.conf, with all the Zero blockchain data and execution log. It is highly recommended that you stop zerod, your Zero full node process, before making a copy of the wallet file.

Specific default for the data directory location depends on your system type, unless it has been set explicitly with the datadir option.

Linux	$HOME/.zero/

Windows	%APPDATA%\Zero\

MacOS	$HOME/Library/Application Support/Zero/

Backup wallet file

A proper method to make an archival copy of the wallet file while zerod is running involves using backupwallet command. First you need to set an export directory path for the backup wallet file, via option exportdir=<path> in your zero.conf configuration file.

Note: zerod needs to be restarted, for the edits in the configuration file to take effect.

Invoke the command below and make a copy of the resulting file:

zero-cli backupwallet <backupname>


Restore wallet file

Having stopped zerod process, place the wallet backup file into the data directory, ~/.zero on Linux by default, under the name wallet.zero. Restart zerod, and check that the wallet is operational.


Sapling addresses and keys

Sapling shielded addresses (starting with zs) are natively generated from an HD seed. Import of this seed is not yet supported fully by the RPC interface. Sapling keys can be exported and later re-imported using the options below, but will be treated as standard (non-HD) shielded private keys.

If you generate new addresses after using backupwallet, they will not be reflected in the backup file. Yet, for Sapling addresses, due to the deterministic nature of HD wallets, restoring the wallet file and calling z_getnewaddress repeatedly will generate keys in the same order they were created originally. We recommend afterwards starting the zerod full node process with -rescan option, to force a check of the transactions and an update of the balances.


Export private keys as text

To export and later import private keys in a human-readable format, use z_exportwallet & z_importwallet commands:

zero-cli z_exportwallet <backupname>

This generates a text file in the export directory, with all transparent and shielded private keys and their associated addresses. Shielded private keys are separated into Sprout keys under the title Zkeys and Sapling keys. It also includes the Sapling HD wallet seed and associated fingerprint, as hex strings.

To re-import:

zero-cli z_importwallet <exportdir>/<backupname>


Individual keys

To display or to import a single private key for a transparent address, use commands dumpprivkey & importprivkey, inherited from Bitcoin:

zero-cli dumpprivkey <address>

And

zero-cli importprivkey <key>

For a single shielded address and its private key use z_exportkey, z_importkey:

zero-cli z_exportkey <z-address>

And

zero-cli z_importkey <z-key>

This will add the private key and its shielded address to the wallet, and if it was not already there, will rescan the wallet for associated transactions. The rescanning process for a new private key can take a few minutes, so to skip rescan:

zero-cli z_importkey <z-key> no


dumpwallet command - deprecated

Inherited from Bitcoin, dumpwallet command will export private keys similarly to backupwallet, but only for transparent addresses, so it may be deprecated in the future. The export file will include the HD wallet seed and associated fingerprint.