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 directory location is unexpected if wallet.conf is present #645

Open
pinheadmz opened this issue Dec 8, 2018 · 3 comments
Open
Labels
bug Unexpected or incorrect behavior config networks wallet Wallet related

Comments

@pinheadmz
Copy link
Member

pinheadmz commented Dec 8, 2018

To reproduce:

1: Expected

create directory ~/test

save ~/test/bcoin.conf:

network: regtest

run bcoin --prefix=~/test

bcoin will create a folder ~/test/regtest and save the wallet directory there. ✅

2. Somewhat unexpected

create directory ~/test

save ~/test/bcoin.conf:

network: regtest

save ~/test/wallet.conf:

http-port: 9999

run bcoin --prefix=~/test

bcoin will create a folder ~/test/regtest and save the wallet directory there. ✅

bcoin will run normally, however the wallet port setting (and anything else in that wallet.conf file) will be ignored. ❌

See the log:

[info] (wallet) Wallet initialized (primary).
[info] (wallet) Created wallet primary in WalletDB.
[info] (wallet) Loaded primary wallet (id=primary, wid=0, address=RSPuq47YmBAqLqFp6eSvAGtQ6e6QuSaGY9)
[info] (http) Wallet HTTP server listening on 127.0.0.1 (port=48334).
[info] (http) Node HTTP server listening on 127.0.0.1 (port=48332).
[info] (node) Node is loaded.

This is unexpected according to the docs: https://github.com/bcoin-org/bcoin/blob/b0155b663c79714b9fe0f54d7b42e30249e50dc2/CHANGELOG.md#configuration-changes

Wallet and Node are now separated and use different persistent configuration files. Some configuration options have moved to wallet.conf, which is stored in the prefix directory next to the existing bcoin.conf.

...but not according to these docs: https://github.com/bcoin-org/bcoin/blob/master/docs/Configuration.md

3: Really freaking weirdo

create directory ~/test

save ~/test/bcoin.conf:

network: regtest

save ~/test/regtest/wallet.conf:

http-port: 9000

run bcoin --prefix=~/test

bcoin runs with the correct wallet port ✅, see the log. It's reading the wallet.conf file from the subdirectory:

[info] (wallet) Created wallet primary in WalletDB.
[info] (wallet) Loaded primary wallet (id=primary, wid=0, address=RU8tQHBJDHrBDtgCdkwpfKvSrXBE9WkQHx)
[info] (http) Wallet HTTP server listening on 127.0.0.1 (port=9000).
[info] (http) Node HTTP server listening on 127.0.0.1 (port=48332).
[info] (node) Node is loaded.

however -- bcoin is NOT saving the wallet db in ~/test ... it is being saved in literally ~/.bcoin

If you already have a wallet in that directory from running bcoin on mainnet without a prefix option, you're going to get
Error: IO error: /Users/pinhead/.bcoin/regtest/wallet/LOCK: No such file or directory
or
Error: Network mismatch for WalletDB.

@pinheadmz
Copy link
Member Author

pinheadmz commented Dec 8, 2018

OK I figured this out:

wallet.conf must have prefix value as well, it does not inherit prefix from bcoin launch arguments:

prefix: ~/test

... then the wallet is saved in the subdirectory like 1 and 2 above.

So if wallet.conf does not exist (or is not found because its in the wrong place), wallet will be saved to the expected directory like in cases 1 and 2 above. However, mere presence of the wallet.conf means a specific prefix value is needed.

@pinheadmz
Copy link
Member Author

pinheadmz commented Dec 11, 2018

Additional weirdness: Using the above procedure I've got a directory structure like this:
~/test/bcoin.conf
~/test/regtest/wallet.conf, with a prefix value.
This works fine for regular bwallet.
However, running with --no-wallet and running bmultisig an additional directory is added:
~/test/regtest/regtest and it is in this path that wallet and multisig databases are written.

@pinheadmz
Copy link
Member Author

Adding to this issue because I'm pretty sure it's related:

If the conf file exists at custompath/bcoin.conf and contains network: testnet, the network param seems to be ignored by the wallet. Launching with bcoin --prefix=custompath

$ bwallet-cli --prefix=custompath wallets
Error: connect ECONNREFUSED 127.0.0.1:8334
$ bwallet-cli --prefix=custompath --network=testnet wallets
<expected result>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect behavior config networks wallet Wallet related
Projects
None yet
Development

No branches or pull requests

2 participants