arrow_back
Back

Bitcoin Core wallets: createwallet, addresses, labels, and backup

Andrew Dorokhov Andrew Dorokhov schedule 2 min read
menu_book Table of Contents

List wallets

bitcoin-cli listwallets:

[
  "andrew",
  "anna",
  "john"
]

Creating a wallet

bitcoin-cli createwallet "andrew" — create a wallet named andrew.

{
  "name": "andrew",
  "warning": ""
}

Encrypting a wallet

Encrypt the wallet: bitcoin-cli encryptwallet "password":

wallet encrypted; The keypool has been flushed and a new HD seed was generated (if you are using HD). You need to make a new backup.

If there are several wallets:

bitcoin-cli -rpcwallet=andrew encryptwallet "passphrase"

Using wallets

For security, wallets should stay encrypted. Before you operate on them, unlock with:

bitcoin-cli walletpassphrase mypassword 360

walletpassphrase takes two parameters — the passphrase and the number of seconds until the wallet locks itself again (a timer).

Info about a wallet

bitcoin-cli getwalletinfo
bitcoin-cli -rpcwallet=andrew getwalletinfo
{
  "walletname": "andrew",
  "walletversion": 169900,
  "format": "bdb",
  "balance": 0.00000000,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 0.00000000,
  "txcount": 0,
  "keypoololdest": 1637442196,
  "keypoolsize": 1000,
  "hdseedid": "5481b05205b1f421d0e51e5b55b370006d92663b",
  "keypoolsize_hd_internal": 1000,
  "unlocked_until": 1637442723,
  "paytxfee": 0.00000000,
  "private_keys_enabled": true,
  "avoid_reuse": false,
  "scanning": false,
  "descriptors": false
}

The "unlocked_until": 1637442723 field shows until when the wallet stays unlocked. If it is 0, the wallet is locked.

Backups

Backup

Create a wallet backup with:

bitcoin-cli backupwallet wallet.backup

In practice this copies the file from ~/.bitcoin/wallets/andrew/wallet.dat under a new name.

You may also see a line in the daemon log:

2021-11-20T21:51:06Z copied wallet.dat to andrew.backup

Dump

dumpwallet writes the wallet to a human-readable text file:

bitcoin-cli dumpwallet wallet.txt
$ more wallet.txt
# Wallet dump created by Bitcoin v0.9.0rc1-beta (2014-01-31 09:30:15 +0100)
# * Created on 2014-02- 8dT20:34:55Z
# * Best block at time of backup was 286234
(0000000000000000f74f0bc9d3c186267bc45c7b91c49a0386538ac24c0d3a44),
#
mined on 2014-02- 8dT20:24:01Z
KzTg2wn6Z8s7ai5NA9MVX4vstHRsqP26QKJCzLg4JvFrp6mMaGB9 2013-07- 4dT04:30:27Z change=1 #
addr=16pJ6XkwSQv5ma5FSXMRPaXEYrENCEg47F
Kz3dVz7R6mUpXzdZy4gJEVZxXJwA15f198eVui4CUivXotzLBDKY 2013-07- 4dT04:30:27Z change=1 #
addr=17oJds8kaN8LP8kuAkWTco6ZM7BGXFC3gk
[... many more keys ...]
$

Import

bitcoin-cli importwallet wallet.backup
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Bitcoin explorers and APIs: UTXOs and blockchain.info

arrow_forward