A call to loadwallet
while bitcoin-qt
is starting will cause a crash:
0Process 77611 launched: '/Users/michael/github/bitcoin/src/qt/bitcoin-qt' (x86_64)
12019-09-23 07:40:29.799378+0800 bitcoin-qt[77611:495185] MessageTracer: Falling back to default whitelist
2Process 77611 stopped
3* thread [#12](/bitcoin-bitcoin/12/), name = 'bitcoin-httpworker.0', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
4 frame [#0](/bitcoin-bitcoin/0/): 0x00000001001faaa0 bitcoin-qt`WalletController::getOrCreateWallet(this=0x000000011a5a1670, wallet=unique_ptr<interfaces::Wallet, std::__1::default_delete<interfaces::Wallet> > @ 0x0000700009586200) at walletcontroller.cpp:96:36
5 93
6 94 // Return model instance if exists.
7 95 if (!m_wallets.empty()) {
8-> 96 std::string name = wallet->getWalletName();
9 97 for (WalletModel* wallet_model : m_wallets) {
10 98 if (wallet_model->wallet().getWalletName() == name) {
11 99 return wallet_model;
12Target 0: (bitcoin-qt) stopped.
0import argparse
1import time
2import os
3import sys
4
5from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
6
7# lldb src/qt/bitcoin-qt -- -debug -regtest
8# python3 crash.py <datadir>
9
10parser = argparse.ArgumentParser()
11parser.add_argument('datadir')
12args = parser.parse_args()
13
14cookie: str = args.datadir + '/regtest/.cookie'
15wallet_name: str = 'hello'
16
17# Wait for cookie file to be created
18while not os.path.exists(cookie):
19 time.sleep(0.5)
20# Read .cookie file to get user and pass
21with open(cookie) as f:
22 userpass: str = f.readline().lstrip().rstrip()
23rpc = AuthServiceProxy('http://{}@127.0.0.1:18443'.format(userpass))
24
25# Wait for bitcoin-qt to be ready
26ready: bool = False
27while not ready:
28 print('waiting...')
29 try:
30 rpc.getblockchaininfo()
31 ready = True
32 except Exception:
33 time.sleep(0.5)
34 pass
35rpc.loadwallet(wallet_name)