2

Every time I restart my bitcoind, all the wallets will need to be reloaded:

$ bitcoin-cli listwallets
[
  ""
]
$ bitcoin-cli loadwallet test01
$ bitcoin-cli listwallets
[
  "",
  "test01"
]

So I was wondering that is there any ways to auto load all the wallet under path /home/ubuntu/.bitcoin/testnet3/wallets when startup? I have tried adding some config in bitcoin.config, but all didn't work for me:

wallet=/home/ubuntu/.bitcoin/testnet3/wallets
wallet=/home/ubuntu/.bitcoin/testnet3/wallets/test01
wallet=1

bitcoin core version: v0.18.1

2

If you're using a systemd service, here's a way to auto load wallets using ExecStartPost.
This is what I added to my bitcoind.service file:

ExecStartPost=/bin/bash -c "sleep 60 && ls PATH_TO_YOUR_WALLETS_FOLDER -I database -I wallet.dat -I db.log | xargs -r -L 1 PATH_TO_YOUR_BITCON_CLI/bitcoin-cli loadwallet"

It waits 60 seconds after bitcoind starts, to give it a chance to load the block index first. Then looks for wallet directories and loads each one using bitcoin-cli loadwallet WALLET_NAME command.


Alternatively, if you just want to load specific wallets on Bitcoin Core restart, add this to bitcoin.conf before restarting:

wallet=
wallet=wallet_name
wallet=another_wallet

Full path isn't required if you created the wallets in the default directory (aka datadir).
A wallet name is the name of the directory the corresponding wallet.dat is in.
The wallet= line is needed to also load the default wallet.
Make sure to add the lines in the [test] section if you're on testnet.

1

You can specify the wallet options multiple times.

I.e. specifying:

wallet=/home/ubuntu/.bitcoin/testnet3/wallets/wallet01
wallet=/home/ubuntu/.bitcoin/testnet3/wallets/wallet02
wallet=/home/ubuntu/.bitcoin/testnet3/wallets/wallet03

in your bitcoin.conf will load wallet01, wallet02, wallet03.

3
  • This doesn't works for me. Dec 24 '19 at 4:41
  • Hmm that's weird in this case I think you should post an issue on GIthub as that's the intended behavior (see the manpage).
    – darosior
    Dec 24 '19 at 21:31
  • I just tested out of curiosity and I can't reproduce, did you open an issue. If so could you point me to it ?
    – darosior
    Dec 29 '19 at 15:38
0

If we suppose that the count of wallets are a lot, we can't load them manually. I use a Python script which loads wallets:

import subprocess
import os

def load_wallets():
    wallets = os.listdir(wallets_dir)
    for wallet in wallets:
        try:
            x = subprocess.check_output('bitcoin-cli -testnet loadwallet ' + wallet, shell=True)
        except Exception:
            pass

Some files may be in the wallets directory which are not wallet dirs and script will pass them inside except block.

Change -testnet parameter if needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.