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

sparrow cant connect to signet node running on localhost #67

Closed
7hacker opened this issue Mar 5, 2021 · 10 comments
Closed

sparrow cant connect to signet node running on localhost #67

7hacker opened this issue Mar 5, 2021 · 10 comments

Comments

@7hacker
Copy link

7hacker commented Mar 5, 2021

I have a signet node running with server=1 in bitcoin.conf

I boot sparrow with -n signet and -l DEBUG

In the preferences Sparrow's test connection works fine, a banner is displayed and a wallet is also created by sparrow in the bitcoin datadir:

2021-03-04 21:37:05,257 INFO Using signet configuration
2021-03-04 21:37:26,384 DEBUG Configuring bwt: {"network":"signet","bitcoind_url":"http://127.0.0.1:38332","bitcoind_dir":"/Users/nirmal/code/bitcoin/src/signet-custom/","bitcoind_wallet":"sparrow","create_wallet_if_missing":true,"verbose":2,"electrum_addr":"127.0.0.1:0","electrum_skip_merkle":true,"require_addresses":false}
2021-03-04 21:37:26,385 DEBUG Booting bwt
 DEBUG bwt::app > Config { network: Signet, verbose: 2, timestamp: false, bitcoind_wallet: Some("sparrow"), bitcoind_dir: Some("/Users/nirmal/code/bitcoin/src/signet-custom/"), bitcoind_url: Some("http://127.0.0.1:38332"), bitcoind_auth: None, bitcoind_cookie: None, create_wallet_if_missing: true, descriptors: [], xpubs: [], addresses: [], addresses_file: None, rescan_since: Now, force_rescan: false, gap_limit: 20, initial_import_size: 350, auth_cookie: None, auth_token: None, auth_ephemeral: false, print_token: false, electrum_addr: Some(127.0.0.1:0), electrum_skip_merkle: true, poll_interval: 5s, broadcast_cmd: None, startup_banner: false, unix_listener_path: None, require_addresses: false, setup_logger: true }
 DEBUG bitcoincore_rpc > JSON-RPC request: getblockchaininfo []
 DEBUG bitcoincore_rpc > JSON-RPC request: getnetworkinfo []
 DEBUG bitcoincore_rpc > JSON-RPC request: loadwallet ["sparrow"]
2021-03-04 21:37:26,388 DEBUG Syncing 100%
 DEBUG bitcoincore_rpc > JSON-RPC error for loadwallet: RpcError { code: -18, message: "Wallet file verification failed. Failed to load database path \'/Users/nirmal/code/bitcoin/src/signet-custom/signet/wallets/sparrow\'. Path does not exist.", data: None }
 DEBUG bitcoincore_rpc > JSON-RPC request: createwallet ["sparrow",true,true]
 DEBUG bitcoincore_rpc > JSON-RPC request: getwalletinfo []
 DEBUG bitcoincore_rpc > JSON-RPC request: getnetworkinfo []
 INFO  bwt::app        > bwt v0.2.1 connected to /Satoshi:21.99.0/ on signet at height 1672

Then immediately after exiting the preferences pane, Sparrow logs cant connect to the signet node anymore :

 DEBUG bitcoincore_rpc                   > JSON-RPC request: getblockchaininfo []
 DEBUG bitcoincore_rpc                   > JSON-RPC request: getnetworkinfo []
 DEBUG bitcoincore_rpc                   > JSON-RPC request: loadwallet ["sparrow"]
2021-03-04 21:37:39,106 DEBUG Syncing 100%
 DEBUG bitcoincore_rpc                   > JSON-RPC error for loadwallet: RpcError { code: -35, message: "Wallet file verification failed. Refusing to load database. Data file \'/Users/nirmal/code/bitcoin/src/signet-custom/signet/wallets/sparrow/wallet.dat\' is already loaded.", data: None }
 WARN  bwt_jni                           > JSON-RPC error: RPC error response: RpcError { code: -35, message: "Wallet file verification failed. Refusing to load database. Data file \'/Users/nirmal/code/bitcoin/src/signet-custom/signet/wallets/sparrow/wallet.dat\' is already loaded.", data: None }
2021-03-04 21:37:39,114 ERROR Failed to start BWT
dev.bwt.libbwt.BwtException: JSON-RPC error: RPC error response: RpcError { code: -35, message: "Wallet file verification failed. Refusing to load database. Data file \'/Users/nirmal/code/bitcoin/src/signet-custom/signet/wallets/sparrow/wallet.dat\' is already loaded.", data: None }
        at [email protected]/dev.bwt.libbwt.daemon.NativeBwtDaemon.start(Native Method)
        at [email protected]/com.sparrowwallet.sparrow.net.Bwt.start(Bwt.java:129)
        at [email protected]/com.sparrowwallet.sparrow.net.Bwt.start(Bwt.java:80)
        at [email protected]/com.sparrowwallet.sparrow.net.Bwt$ConnectionService$1.call(Bwt.java:302)
        at [email protected]/com.sparrowwallet.sparrow.net.Bwt$ConnectionService$1.call(Bwt.java:240)
        at javafx.graphics/javafx.concurrent.Task$TaskCallable.call(Task.java:1425)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at javafx.graphics/javafx.concurrent.Service.lambda$executeTask$6(Service.java:725)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
        at javafx.graphics/javafx.concurrent.Service.lambda$executeTask$7(Service.java:724)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:832)
 DEBUG bwt_jni                           > shutdown signal received

Restarting sparrow and going back to the preferences pane to test the connection leads to a failure.

The only way to re-establish the connection is to delete sparrow's wallet in bitcoin core's datadir and the ~/.sparrow/ directory where I imagine more state is stored.

@craigraw
Copy link
Collaborator

craigraw commented Mar 5, 2021

Strange, I can't reproduce this. On my side, everything proceeds as described in your logs, but on the second connection, after the debug message with Bitcoin Core failing to reload the wallet "Wallet file verification failed. Refusing to load database. Data file \'....../Library/Application Support/Bitcoin/signet/wallets/sparrow/wallet.dat\' is already loaded." bwt continues on to the getwalletinfo call as normal.

There are two differences from my setup that are visible though:

  1. You are using a custom signet chain, although it seems unlikely this is the cause
  2. You have compiled a custom version of Bitcoin Core later than the 0.21.0 release - more likely the cause?

ccing @shesek (the author of bwt) for further thoughts.

@7hacker
Copy link
Author

7hacker commented Mar 5, 2021

hi @craigraw Yes I imagine a custom signet chain shouldn't matter, since the Signet PR that was merged recently didn't seem to contain anything that would distinguish the default network from a custom one, but I could be wrong on that.

Yes I am running bitcoin core master as of 02/05 and I'll try this again with the 0.21.0 branch

@shesek
Copy link

shesek commented Mar 5, 2021

This is indeed because you're running a newer Bitcoin Core release. The error code for the 'wallet already loaded' message was recently changed (following a request made by myself, actually) and didn't get updated in bwt yet, so it doesn't recognize the error. I was planning to update this when v0.22 gets released, but I'll look into doing this sooner.

@7hacker
Copy link
Author

7hacker commented Mar 5, 2021

Hi @shesek , thanks very much

@shesek
Copy link

shesek commented Mar 6, 2021

@7hacker As a temporary workaround, you can unload the wallet before connecting Sparrow with $ bitcoin-cli unloadwallet sparrow. This will make the loadwallet command succeed instead of returning the 'already loaded' message.

@7hacker
Copy link
Author

7hacker commented Mar 6, 2021

Thanks @shesek , I'll use this workaround since another issue is that the bitcoin-core 0.21.0 branch doesn't have the tools to mine nodes on a custom signet

shesek added a commit to bwt-dev/bwt that referenced this issue Mar 17, 2021
Try `getwalletinfo` first and only call `loadwallet` if that fails.

This also makes detecting the 'already loaded' error message
unnecessary, instead of having to detect *three* different ways it could
be returned by different Bitcoin Core versions (<v0.21, ==v0.21 and >v0.21).

Also see: sparrowwallet/sparrow#67 (comment)
@shesek
Copy link

shesek commented Mar 17, 2021

@7hacker A fix was released in bwt v0.2.3 (but note that you'll only get it when Sparrow is updated to use the new bwt release).

@craigraw
Copy link
Collaborator

Sparrow has been updated to use bwt 0.2.3. Thanks @shesek!

@shesek
Copy link

shesek commented Mar 17, 2021

@craigraw That was fast! 🔥

@7hacker
Copy link
Author

7hacker commented Mar 17, 2021

woo! Thanks @craigraw @shesek I'll be sure to re-run this flow and report back if i find any issues. Closing for now

@7hacker 7hacker closed this as completed Mar 17, 2021
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

3 participants