Workaround: restart bitcoind.
Problem:
/usr/bin $ ./bitcoin-cli createwallet hello true
error code: -1
error message:
BerkeleyBatch: Error 2, can't open database wallet.dat
That's the end result, but before the error, here's what I did...
Steps to reproduce:
/usr/bin $ ./bitcoin-cli createwallet hello true
{
"name": "hello",
"warning": ""
}
/usr/bin $ ./bitcoin-cli createwallet hello true
error code: -4
error message:
Wallet hello already exists.
/usr/bin $ ./bitcoin-cli unloadwallet hello
/usr/bin $ ./bitcoin-cli createwallet hello true
error code: -4
error message:
Wallet hello already exists.
/usr/bin $ rm -rf /.bitcoin/testnet3/wallets/hello
/usr/bin $ ./bitcoin-cli createwallet hello true
error code: -1
error message:
BerkeleyBatch: Error 2, can't open database wallet.dat
/usr/bin $ ./bitcoin-cli --version
Bitcoin Core RPC client version v0.17.0
I was working in an Alpine docker container on an OSX host.
Pertinent debug.log:
2019-02-07T00:13:44Z UpdateTip: new best=000000000000007358c3ae2fdc8e18f5ff5ea44bb736106a3d6fe9e977cc5e80 height=1456002 version=0x3fffe000 log2_work=71.910296 tx=48779126 date='2019-02-07T00:13:43Z' progress=1.000000 cache=0.5MiB(3600txo) warning='47 of last 100 blocks have unexpected version'
2019-02-07T00:15:52Z Using BerkeleyDB version Berkeley DB 4.8.30: (April 9, 2010)
2019-02-07T00:15:52Z Using wallet wallet.dat
2019-02-07T00:15:52Z BerkeleyEnvironment::Open: LogDir=/.bitcoin/testnet3/wallets/hello/database ErrorFile=/.bitcoin/testnet3/wallets/hello/db.log
2019-02-07T00:15:53Z init message: Loading wallet...
2019-02-07T00:15:53Z [hello] nFileVersion = 170000
2019-02-07T00:15:53Z [hello] Keys: 0 plaintext, 0 encrypted, 0 w/ metadata, 0 total. Unknown wallet records: 0
2019-02-07T00:15:53Z [hello] Performing wallet upgrade to 169900
2019-02-07T00:15:53Z [hello] Wallet completed loading in 34ms
2019-02-07T00:15:53Z [hello] setKeyPool.size() = 0
2019-02-07T00:15:53Z [hello] mapWallet.size() = 0
2019-02-07T00:15:53Z [hello] mapAddressBook.size() = 0
2019-02-07T00:16:15Z [hello] Releasing wallet
2019-02-07T00:17:02Z Using BerkeleyDB version Berkeley DB 4.8.30: (April 9, 2010)
2019-02-07T00:17:02Z Using wallet wallet.dat
2019-02-07T00:17:02Z init message: Loading wallet...
2019-02-07T00:17:02Z [hello] Releasing wallet
2019-02-07T00:19:58Z UpdateTip: new best=00000000000000e37b2a67230b87e31bdfe55534d96eb918ce46794e9471baa1 height=1456003 version=0x20000000 log2_work=71.910316 tx=48779158 date='2019-02-07T00:19:29Z' progress=1.000000 cache=0.5MiB(3626txo) warning='46 of last 100 blocks have unexpected version'
Thanks!