BlockchainCommons / Learning-Bitcoin-from-the-Command-Line

A complete course for learning Bitcoin programming and usage from the command
3.12k stars 754 forks source link

Errors on starting LND #185

Closed jleo84 closed 3 years ago

jleo84 commented 3 years ago

Hello,

In chapter "18.2 - Interlude Accessing a Second Lightning Node", I am getting the following error message when execute lncli --network=testnet create command:

[lncli] unable to generate seed: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp 127.0.0.1:10009: connect: connection refused"

And if I run the command: lncli --network=testnet getinfo, I get the message:

[lncli] unable to read macaroon path (check the network setting!): open /home/standup/.lnd/data/chain/bitcoin/testnet/admin.macaroon: no such file or directory

The log has some error messages:

standup@ubuntu:~$ sudo journalctl -u lnd -f -n20
-- Logs begin at Tue 2020-12-01 05:26:06 PST. --
Dec 04 00:40:46 ubuntu lnd[5083]: 2020-12-04 00:40:46.468 [INF] LTND: Opening bbolt database, sync_freelist=false
Dec 04 00:40:46 ubuntu lnd[5083]: 2020-12-04 00:40:46.472 [INF] CHDB: Checking for schema update: latest_version=17, db_version=17
Dec 04 00:40:46 ubuntu lnd[5083]: 2020-12-04 00:40:46.472 [INF] LTND: Database now open (time_to_open=3.32664ms)!
Dec 04 00:40:46 ubuntu lnd[5083]: 2020-12-04 00:40:46.481 [INF] RPCS: password RPC server listening on 127.0.0.1:10009
Dec 04 00:40:46 ubuntu lnd[5083]: 2020-12-04 00:40:46.481 [INF] RPCS: password gRPC proxy started at 127.0.0.1:8080
Dec 04 00:40:46 ubuntu lnd[5083]: 2020-12-04 00:40:46.481 [INF] LTND: Waiting for wallet encryption password. Use `lncli create` to create a wallet, `lncli unlock` to unlock an existing wallet, or `lncli changepassword` to change the password of an existing wallet and unlock it.
Dec 04 00:40:46 ubuntu systemd[1]: Stopping LND Lightning Network Daemon...
Dec 04 00:40:46 ubuntu lncli[5094]: [lncli] open /var/lib/lnd/tls.cert: no such file or directory
Dec 04 00:40:46 ubuntu systemd[1]: lnd.service: Control process exited, code=exited, status=1/FAILURE
Dec 04 00:40:46 ubuntu lnd[5083]: 2020-12-04 00:40:46.929 [INF] LTND: Received terminated
Dec 04 00:40:46 ubuntu lnd[5083]: 2020-12-04 00:40:46.929 [INF] LTND: Shutting down...
Dec 04 00:40:46 ubuntu lnd[5083]: 2020-12-04 00:40:46.929 [INF] LTND: Gracefully shutting down.
Dec 04 00:40:46 ubuntu lnd[5083]: 2020-12-04 00:40:46.930 [ERR] LTND: unable to set up wallet password listeners: shutting down
Dec 04 00:40:46 ubuntu lnd[5083]: 2020-12-04 00:40:46.930 [INF] LTND: Shutdown complete
Dec 04 00:40:46 ubuntu lnd[5083]: unable to set up wallet password listeners: shutting down
Dec 04 00:40:46 ubuntu systemd[1]: lnd.service: Main process exited, code=exited, status=1/FAILURE
Dec 04 00:40:46 ubuntu systemd[1]: lnd.service: Failed with result 'exit-code'.
Dec 04 00:40:46 ubuntu systemd[1]: Stopped LND Lightning Network Daemon.
Dec 04 00:40:46 ubuntu systemd[1]: Dependency failed for LND Lightning Network Daemon.
Dec 04 00:40:46 ubuntu systemd[1]: lnd.service: Job lnd.service/start failed with result 'dependency'.

I found similar issue here but with no applicable answer.

Can it be fixed ? Is there any step of tutorial missing ?

jleo84 commented 3 years ago

I've noticed if I run /usr/bin/lnd instead of sudo systemctl start lnd, the lncli works.

Is it something related to service configuration ?

shannona commented 3 years ago

That error suggests that Lightning is not connecting to Bitcoin correctly. It's most likely due to bitcoind.rpcuser and bitcoind.rpcpass being blank in ~/.lnd/lnd.conf:

bitcoind.rpcuser=
bitcoind.rpcpass=

These can be filled in as follows:

$ BITCOINRPC_USER=$(cat ~standup/.bitcoin/bitcoin.conf | grep rpcuser | awk -F = '{print $2}')
$ BITCOINRPC_PASS=$(cat ~standup/.bitcoin/bitcoin.conf | grep rpcpassword | awk -F = '{print $2}')

My top guess is that you rebooted the machine to restart Bitcoin and then didn't refill these variables, so the config creation didn't work correctly. I've rewritten the chapter a little bit so that doesn't happen.

I also found one other error regarding installation (where something wasn't sudoed), and resolved that. I've verified that the CLI commands work correct following the designated setup.

zhengjia commented 3 years ago

Make sure you specify --rpcserver and point it to the second node.