0src/bitcoind -daemon -regtest
1src/bitcoin-cli -regtest stop
2cp ~/.bitcoin/wallet/wallet.dat ~/.bitcoin/wallet/wallet2.dat
3src/bitcoind -daemon -regtest
4src/bitcoin-cli -regtest loadwallet wallet2.dat # The first time it would fail to load wallet
5src/bitcoin-cli -regtest loadwallet wallet2.dat # The second time it would succeed to load wallet, but this would cause error because of duplicate fileid
It would flush wallet.dat
and close Db*
in mapDb['wallet.dat'].second
, so mapDb['wallet.dat'].second
would be nullptr
. Then there is no available Db*
to detect if the wallet fileid is duplicated.
I’m not sure if the issue is related to #14163, but I found this while debugging it.