lnd: LND fails to start when bitcoin RPC credentials have a "!" in them
Tested with: Bitcoind 0.16 LND 0.4 Ubuntu 16.04
Issue: If the Bitcoin rpcuser or rpcpassword contain the ’ ! ’ character, LND will exit with a 401 status code after the wallet has been unlocked. The issue exits if the ’ ! ’ is present at the end, or in the middle of the string, i.e.
rcpuser=iamcool!!
or
rpcuser=iamcool!!yes
The relevant log section:
2018-03-22 13:55:55.982 [INF] LTND: Waiting for wallet encryption password. Use `lncli create` to create wallet, or `lncli unlock` to unlock already created wallet.
2018-03-22 13:56:09.260 [INF] LNWL: Opened wallet
2018-03-22 13:56:09.340 [INF] LTND: Primary chain is set to: bitcoin
2018-03-22 13:56:09.340 [INF] LTND: Initializing bitcoind backed fee estimator
2018-03-22 13:56:10.495 [INF] LNWL: Opened wallet
unable to start wallet: status code: 401, response: ""
unable to create chain control: status code: 401, response: ""
status code: 401, response: ""
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (4 by maintainers)
So the problems discovered have either been related to my unrealistic expectations of what bash can do, or to underlying problems with how Bitcoin handles certain characters, such as # or " . Should we close this issue?
I’ll take this on as my first issue-ish
I tested with
bitcoind 0.16.0 (regtest mode) lnd 0.4.0 (commit 18e6705d97840bfe4040a8a373ba40bc6a1b4b59) Mac OS X
EDIT: I was able to reproduce this issue. There seem to be a few issues with how lnd talks to bitcoind when passing the rpcuser and rpcpass.
unable to start wallet: status code: 401, response: ""unable to create chain control: status code: 401, response: ""status code: 401, response: ""I will look into how errors are handled when the wallet starts and chain control is created to see whether we can guard against scenario “3” above.
I believe that for scenario “1” (which I was not able to reproduce) or “2”, the username and password certificate (is it a certificate) is being computed or passed incorrectly. I believe it would make sense to attempt to connect to the rpc server manually using an rpcuser that includes the “#”
Reproduction Scenario (Mac OS X)
bitcoin.conf
rpcuser=kek!kekrpcpass=kek!regtest=1txindex=1server=1daemon=1zmqpubrawblock=tcp://127.0.0.1:28332zmqpubrawtx=tcp://127.0.0.1:28332lnd.conf
regtest=1txindex=1server=1daemon=1zmqpubrawblock=tcp://127.0.0.1:28332zmqpubrawtx=tcp://127.0.0.1:28332Reproduction Scenario:
When I pass the rpcuser and rpcpass to lnd via the cli, I get a bash error:
$ lnd --bitcoind.rpcuser=kek!!kek --bitcoind.rpcpass=kek! -bash: !: event not found
But if I add it to the lnd.conf file, it works
lnd.conf
rpcuser=kek!@#kekrpcpass=kek!regtest=1txindex=1server=1daemon=1zmqpubrawblock=tcp://127.0.0.1:28332zmqpubrawtx=tcp://127.0.0.1:28332If I drop the “!” from both rpcuser and rpc pass, I get the 401. $ lnd --bitcoind.rpcuser=kekkek --bitcoind.rpcpass=kek 2018-03-24 11:11:51.634 [INF] LTND: Version 0.4.0-beta 2018-03-24 11:11:51.634 [INF] LTND: Active chain: Bitcoin (network=regtest) 2018-03-24 11:11:51.634 [INF] CHDB: Checking for schema update: latest_version=0, db_version=0 2018-03-24 11:11:51.645 [INF] LTND: Primary chain is set to: bitcoin 2018-03-24 11:11:52.567 [INF] LNWL: Opened wallet unable to start wallet: status code: 401, response: “” unable to create chain control: status code: 401, response: “” status code: 401, response: “”
If I keep the password correct (including the “!”) $ lnd --bitcoind.rpcuser=kekkek --bitcoind.rpcpass=kek! 2018-03-24 11:12:52.698 [INF] LTND: Version 0.4.0-beta 2018-03-24 11:12:52.698 [INF] LTND: Active chain: Bitcoin (network=regtest) 2018-03-24 11:12:52.698 [INF] CHDB: Checking for schema update: latest_version=0, db_version=0 2018-03-24 11:12:52.710 [INF] LTND: Primary chain is set to: bitcoin 2018-03-24 11:12:53.656 [INF] LNWL: Opened wallet unable to start wallet: status code: 401, response: “” unable to create chain control: status code: 401, response: “” status code: 401, response: “”
Interestingly, however:
If I change the rpcuser to:
rpcuser=kek!#kekit will no longer allow me to connect.