Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet file verification failure on npm run bitcoin #276

Open
dredozubov opened this issue Jun 16, 2022 · 16 comments
Open

Wallet file verification failure on npm run bitcoin #276

dredozubov opened this issue Jun 16, 2022 · 16 comments

Comments

@dredozubov
Copy link

I'm following installation instruction to get a working testnet ION node. I have a single instance of bitcoind, mongodb and ipfs running and then I get this:

$ npm run build && npm run bitcoin

...

Collection 'transactions' found.
Sending jRPC request: id: 5mq6r6sfrah, method: createwallet
Wallet with name sidetreeDefaultWallet already exists.
Sending jRPC request: id: 3624m93nnhi, method: loadwallet
Sidetree-Bitcoin node initialization failed with error: {"stack":"Error: Unexpected fetch HTTP response: [500]: {\"result\":null,\"error\":{\"code\":-4,\"message\":\"Wallet file verification failed. SQLiteDatabase: Unable to obtain an exclusive lock on the database, is it being used by another instance of Bitcoin Core?\\n\"},\"id\":\"3624m93nnhi\"}\n\n    at BitcoinClient.<anonymous> (/home/dr/ion/node_modules/@decentralized-identity/sidetree/dist/lib/bitcoin/BitcoinClient.js:815:27)\n    at Generator.next (<anonymous>)\n    at fulfilled (/home/dr/ion/node_modules/@decentralized-identity/sidetree/dist/lib/bitcoin/BitcoinClient.js:5:58)\n    at process._tickCallback (internal/process/next_tick.js:68:7)","message":"Unexpected fetch HTTP response: [500]: {\"result\":null,\"error\":{\"code\":-4,\"message\":\"Wallet file verification failed. SQLiteDatabase: Unable to obtain an exclusive lock on the database, is it being used by another instance of Bitcoin Core?\\n\"},\"id\":\"3624m93nnhi\"}\n","code":"bitcoin_client_fetch_unexpected_error"}
@coffnix
Copy link

coffnix commented Jun 16, 2022

You need downgrade your bitcoin-core to v0.20.1 to work with ion. Take a look on my bug report:

#275

@coffnix
Copy link

coffnix commented Jun 16, 2022

su - bitcoin

git clone https://github.com/bitcoin/bitcoin.git

cd bitcoin

git checkout v0.20.1

./autogen.sh

./contrib/install_db4.sh `pwd`

export BDB_PREFIX='/home/bitcoin/bitcoin/db4'

./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include"

make -j $(nproc)

@dredozubov
Copy link
Author

Is there a specific need for these configuration parameters in particular? I think I'll try finding the binaries to try downgrading it.

I've been following the installation guide and there was no mention of upper-bound bitcoin version. So it if reproduces it makes sense to add a note.

@dredozubov
Copy link
Author

Using it with 0.20.1 bitcoind binary gives me:

Collection 'transactions' found.
Sending jRPC request: id: 2jup4vl9hhc, method: createwallet
Wallet with name sidetreeDefaultWallet already exists.
Sending jRPC request: id: rikpk1hr96, method: loadwallet
Sidetree-Bitcoin node initialization failed with error: {"stack":"Error: Unexpected fetch HTTP response: [500]: {\"result\":null,\"error\":{\"code\":-1,\"message\":\"loadwallet \\\"filename\\\"\\n\\nLoads a wallet from a wallet file or directory.\\nNote that all wallet command-line options used when starting bitcoind will be\\napplied to the new wallet (eg -zapwallettxes, upgradewallet, rescan, etc).\\n\\nArguments:\\n1. filename    (string, required) The wallet directory or .dat file.\\n\\nResult:\\n{                       (json object)\\n  \\\"name\\\" : \\\"str\\\",       (string) The wallet name if loaded successfully.\\n  \\\"warning\\\" : \\\"str\\\"     (string) Warning message if wallet was not loaded cleanly.\\n}\\n\\nExamples:\\n> bitcoin-cli loadwallet \\\"test.dat\\\"\\n> curl --user myusername --data-binary '{\\\"jsonrpc\\\": \\\"1.0\\\", \\\"id\\\": \\\"curltest\\\", \\\"method\\\": \\\"loadwallet\\\", \\\"params\\\": [\\\"test.dat\\\"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\\n\"},\"id\":\"rikpk1hr96\"}\n\n    at BitcoinClient.<anonymous> (/home/dr/ion/node_modules/@decentralized-identity/sidetree/dist/lib/bitcoin/BitcoinClient.js:815:27)\n    at Generator.next (<anonymous>)\n    at fulfilled (/home/dr/ion/node_modules/@decentralized-identity/sidetree/dist/lib/bitcoin/BitcoinClient.js:5:58)\n    at process._tickCallback (internal/process/next_tick.js:68:7)","message":"Unexpected fetch HTTP response: [500]: {\"result\":null,\"error\":{\"code\":-1,\"message\":\"loadwallet \\\"filename\\\"\\n\\nLoads a wallet from a wallet file or directory.\\nNote that all wallet command-line options used when starting bitcoind will be\\napplied to the new wallet (eg -zapwallettxes, upgradewallet, rescan, etc).\\n\\nArguments:\\n1. filename    (string, required) The wallet directory or .dat file.\\n\\nResult:\\n{                       (json object)\\n  \\\"name\\\" : \\\"str\\\",       (string) The wallet name if loaded successfully.\\n  \\\"warning\\\" : \\\"str\\\"     (string) Warning message if wallet was not loaded cleanly.\\n}\\n\\nExamples:\\n> bitcoin-cli loadwallet \\\"test.dat\\\"\\n> curl --user myusername --data-binary '{\\\"jsonrpc\\\": \\\"1.0\\\", \\\"id\\\": \\\"curltest\\\", \\\"method\\\": \\\"loadwallet\\\", \\\"params\\\": [\\\"test.dat\\\"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\\n\"},\"id\":\"rikpk1hr96\"}\n","code":"bitcoin_client_fetch_unexpected_error"}

@coffnix
Copy link

coffnix commented Jun 16, 2022

delete old wallet.dat sqlite file and run npm to recreate a new using berkdb.

@coffnix
Copy link

coffnix commented Jun 16, 2022

work here:


> ion@1.0.4 bitcoin /home/bitcoin/ion
> node dist/src/bitcoin.js

Loading configuration from /home/bitcoin/testnet-bitcoin-config.json...
Loading ION bitcoin versioning config from /home/bitcoin/testnet-bitcoin-versioning.json...
Creating bitcoin wallet using the import string passed in.
Sidetree bitcoin service configuration:
(node:2878) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2878) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
CommandSucceededEvent {
  connectionId: 'localhost:27017',
  requestId: 1,
  commandName: 'listCollections',
  duration: 2,
  reply: {
    cursor: {
      id: 0,
      ns: 'ion-testnet-bitcoin.$cmd.listCollections',
      firstBatch: [Array]
    },
    ok: 1
  }
}
Collection 'service' found.
CommandSucceededEvent {
  connectionId: 'localhost:27017',
  requestId: 2,
  commandName: 'listCollections',
  duration: 0,
  reply: {
    cursor: {
      id: 0,
      ns: 'ion-testnet-bitcoin.$cmd.listCollections',
      firstBatch: [Array]
    },
    ok: 1
  }
}
Collection 'blocks' found.
CommandSucceededEvent {
  connectionId: 'localhost:27017',
  requestId: 3,
  commandName: 'listCollections',
  duration: 0,
  reply: {
    cursor: {
      id: 0,
      ns: 'ion-testnet-bitcoin.$cmd.listCollections',
      firstBatch: [Array]
    },
    ok: 1
  }
}
Collection 'transactions' found.
Sending jRPC request: id: 3ic0nbtngne, method: createwallet
Wallet with name sidetreeDefaultWallet already exists.
Sending jRPC request: id: 1bcpvtahlja, method: loadwallet
Wallet with name sidetreeDefaultWallet already loaded.
Checking if bitcoin contains a wallet for msqLvzh6Xu57n4KFPR4jjJKbzDu19tB6oS
Checking if bitcoin wallet for msqLvzh6Xu57n4KFPR4jjJKbzDu19tB6oS exists
Sending jRPC request: id: hdbc91maas, method: getaddressinfo
Configuring bitcoin peer to watch address msqLvzh6Xu57n4KFPR4jjJKbzDu19tB6oS. This can take up to 10 minutes.
Sending jRPC request: id: eue66jvjca, method: importpubkey

@dredozubov
Copy link
Author

dredozubov commented Jun 17, 2022

@coffnix which commit of ion are you using? I'm getting a different error with bitcoind 0.20.1 and ion master (de8b67cb8c1cb5efa89d888e0e23e8a9a632d008) after removing the wallet.dat file and wallets folder:

Collection 'transactions' found.
Sending jRPC request: id: 2r58s1mmoc6, method: createwallet
Sidetree-Bitcoin node initialization failed with error: {"stack":"Error: Unexpected fetch HTTP response: [401]: \n    at BitcoinClient.<anonymous> (/home/dr/ion/node_modules/@decentralized-identity/sidetree/dist/lib/bitcoin/BitcoinClient.js:815:27)\n    at Generator.next (<anonymous>)\n    at fulfilled (/home/dr/ion/node_modules/@decentralized-identity/sidetree/dist/lib/bitcoin/BitcoinClient.js:5:58)\n    at process._tickCallback (internal/process/next_tick.js:68:7)","message":"Unexpected fetch HTTP response: [401]: ","code":"bitcoin_client_fetch_unexpected_error"}

UPD

I've completely purged bitcoin installation and set up a vanilla 0.20.1 to make sure. npm run bitcoin gives me the same error.

UPD

Same issue with fresh VPS and bitcoin 0.20.1 installation via Bitcoin-standup-script

@coffnix
Copy link

coffnix commented Jun 17, 2022

take a look on your error.... 401 HTTP.

You need configure same user and password on bitcoin.conf and testnet-bitcoin-config.json

@dredozubov
Copy link
Author

Yes, you're right there, but fixing this only leads to a different error with loadwallet. Is there a ion community chat somewhere?

@coffnix
Copy link

coffnix commented Jun 18, 2022

here... paste your error :D

@thobson88
Copy link

thobson88 commented Jul 11, 2022

Hi @coffnix. I'm getting the same error reported above. After deleting my wallet.dat file I get this:

$ node dist/src/bitcoin.js
Loading configuration from /etc/ion/testnet-bitcoin-config.json...
Loading ION bitcoin versioning config from /etc/ion/testnet-bitcoin-versioning.json...
Creating bitcoin wallet using the import string passed in.
Sidetree bitcoin service configuration:
(node:31183) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:31183) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
CommandSucceededEvent {
  connectionId: 'localhost:27017',
  requestId: 1,
  commandName: 'listCollections',
  duration: 2,
  reply: {
    cursor: {
      id: 0,
      ns: 'ion-testnet-bitcoin.$cmd.listCollections',
      firstBatch: [Array]
    },
    ok: 1
  }
}
Collection 'service' found.
CommandSucceededEvent {
  connectionId: 'localhost:27017',
  requestId: 2,
  commandName: 'listCollections',
  duration: 1,
  reply: {
    cursor: {
      id: 0,
      ns: 'ion-testnet-bitcoin.$cmd.listCollections',
      firstBatch: [Array]
    },
    ok: 1
  }
}
Collection 'blocks' found.
CommandSucceededEvent {
  connectionId: 'localhost:27017',
  requestId: 3,
  commandName: 'listCollections',
  duration: 1,
  reply: {
    cursor: {
      id: 0,
      ns: 'ion-testnet-bitcoin.$cmd.listCollections',
      firstBatch: [Array]
    },
    ok: 1
  }
}
Collection 'transactions' found.
Sending jRPC request: id: 4rhitiio0af, method: createwallet
Wallet with name sidetreeDefaultWallet already exists.
Sending jRPC request: id: 6gd3dlk6o67, method: loadwallet
Sidetree-Bitcoin node initialization failed with error: {"stack":"Error: Unexpected fetch HTTP response: [500]: {\"result\":null,\"error\":{\"code\":-1,\"message\":\"loadwallet \\\"filename\\\"\\n\\nLoads a wallet from a wallet file or directory.\\nNote that all wallet command-line options used when starting bitcoind will be\\napplied to the new wallet (eg -zapwallettxes, upgradewallet, rescan, etc).\\n\\nArguments:\\n1. filename    (string, required) The wallet directory or .dat file.\\n\\nResult:\\n{                       (json object)\\n  \\\"name\\\" : \\\"str\\\",       (string) The wallet name if loaded successfully.\\n  \\\"warning\\\" : \\\"str\\\"     (string) Warning message if wallet was not loaded cleanly.\\n}\\n\\nExamples:\\n> bitcoin-cli loadwallet \\\"test.dat\\\"\\n> curl --user myusername --data-binary '{\\\"jsonrpc\\\": \\\"1.0\\\", \\\"id\\\": \\\"curltest\\\", \\\"method\\\": \\\"loadwallet\\\", \\\"params\\\": [\\\"test.dat\\\"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\\n\"},\"id\":\"6gd3dlk6o67\"}\n\n    at BitcoinClient.<anonymous> (/home/ionuser/ion/node_modules/@decentralized-identity/sidetree/dist/lib/bitcoin/BitcoinClient.js:815:27)\n    at Generator.next (<anonymous>)\n    at fulfilled (/home/ionuser/ion/node_modules/@decentralized-identity/sidetree/dist/lib/bitcoin/BitcoinClient.js:5:58)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)","message":"Unexpected fetch HTTP response: [500]: {\"result\":null,\"error\":{\"code\":-1,\"message\":\"loadwallet \\\"filename\\\"\\n\\nLoads a wallet from a wallet file or directory.\\nNote that all wallet command-line options used when starting bitcoind will be\\napplied to the new wallet (eg -zapwallettxes, upgradewallet, rescan, etc).\\n\\nArguments:\\n1. filename    (string, required) The wallet directory or .dat file.\\n\\nResult:\\n{                       (json object)\\n  \\\"name\\\" : \\\"str\\\",       (string) The wallet name if loaded successfully.\\n  \\\"warning\\\" : \\\"str\\\"     (string) Warning message if wallet was not loaded cleanly.\\n}\\n\\nExamples:\\n> bitcoin-cli loadwallet \\\"test.dat\\\"\\n> curl --user myusername --data-binary '{\\\"jsonrpc\\\": \\\"1.0\\\", \\\"id\\\": \\\"curltest\\\", \\\"method\\\": \\\"loadwallet\\\", \\\"params\\\": [\\\"test.dat\\\"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\\n\"},\"id\":\"6gd3dlk6o67\"}\n","code":"bitcoin_client_fetch_unexpected_error"}

Looks like it's trying to call loadwallet with argument test.dat but no such wallet exists:

$ ls /data/.bitcoin/testnet3/wallets/
database  db.log  sidetreeDefaultWallet  wallet.dat

I've tried creating a new wallet named test.dat using the bitcoin cli but that doesn't help.

This is a clean installation of ION at the latest release 1.0.4. And I've rolled back bitcoin core to version v0.20.1 as directed above.

@cedrickoch
Copy link

cedrickoch commented Aug 31, 2022

I had exactly the same issue than the one described above. After trying a lot of different version of ION and Bitcoin I could get it run with ION v.1.0.2.. As far as I have seen ION v.1.0.3 uses another SideTree version ( v1.0.5. instead of v1.0.3 ) which is ending in the issue mentioned above.

@stoneric
Copy link

stoneric commented Sep 7, 2022

I can confirm cedrickkoch, v1.0.2 is the only version working with bitcoind 0.18 in my case, 20 was not working, 23.
On the ION front none work except 1.0.2 -- loadwallet errors.

@sangaman
Copy link

What's the solution here exactly? Using an older version of ION?

I tried following the installation instructions here https://github.com/decentralized-identity/ion/blob/master/install-guide.md with bitcoin core 25.0. I failed with the issue seemingly described in #275. OK, so I deleted any wallets on disk and downgraded to 0.20.1, but now I'm getting the error described here.

I can call bitcoin-cli loadwallet sidetreeDefaultWallet without issue.

@sangaman
Copy link

I worked around this by editing ./node_modules/@decentralized-identity/sidetree/dist/lib/bitcoin/BitcoinClient.js:273 to remove true as the second parameter on the loadwallet call. Calling bitcoin-cli loadwallet sidetreeDefaultWallet true was failing and giving me the same error as I was seeing from ion, and the help for bitcoin-cli in v25 doesn't mention this second parameter, which was supposed indicate whether the wallet should be loaded on start. Ironically, if the wallet is already loaded then the loadwallet call fails, so we wouldn't want to load the wallet on start in the first place.

So now I have a running ion instance and it's scanning the chain for the pub key that was imported, but it looks like there's a bug in the sidetree code when it comes to loading wallets. I can open a PR for that.

@sangaman
Copy link

sangaman commented Jul 20, 2023

Looks like it's trying to call loadwallet with argument test.dat but no such wallet exists:

$ ls /data/.bitcoin/testnet3/wallets/
database  db.log  sidetreeDefaultWallet  wallet.dat

I've tried creating a new wallet named test.dat using the bitcoin cli but that doesn't help.

@coffnix ION wasn't trying to load a wallet named test.dat - rather the RPC request it was making was invalid and bitcoin core responded with the help documentation for the loadwallet command (which you can find a version of here, including the test.dat reference)

I fixed that issue (and an issue with ION crashing when the wallet it wants is already loaded on v0.20.1) in this PR decentralized-identity/sidetree-reference-impl#48. It would need to be merged there, published, and then updated here to use the new sidetree dependency.

In the meantime if anyone runs into this issue and wants to fix it, they can make the changes I made in that PR directly to node_modules/@decentralized-identity/sidetree/dist/lib/bitcoin/BitcoinClient.js in their working directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants