lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.73k stars 2.09k forks source link

Can't connect to btcd backend server #1656

Closed curtischong closed 6 years ago

curtischong commented 6 years ago

Background

I have been trying to connect to my btcd backend on an external server but when I run lnd --bitcoin.active --bitcoin.mainnet --debuglevel=debug --btcd.rpcuser=myuser --btcd.rpcpass=mypass --externalip=X.X.X.X:xxxx --btcd.rpccert=rpc.cert

I have also tried including --btcd.rpchost=X.X.X.X:xxxx in the command above

I am faced with this output:

2018-07-30 18:04:13.863 [INF] LTND: Version 0.4.2-beta commit=
2018-07-30 18:04:13.863 [INF] LTND: Active chain: Bitcoin (network=mainnet)

Sometimes I would get more output and would be prompted to input the password for my wallet yeilding me an input that looks like this:

2018-07-30 18:31:52.781 [INF] LTND: Version 0.4.2-beta commit=
2018-07-30 18:31:52.781 [INF] LTND: Active chain: Bitcoin (network=mainnet)
2018-07-30 18:31:52.781 [INF] CHDB: Checking for schema update: latest_version=3, db_version=3
2018-07-30 18:31:52.796 [INF] RPCS: password RPC server listening on 127.0.0.1:10009
2018-07-30 18:31:52.796 [INF] RPCS: password gRPC proxy started at 127.0.0.1:8080
2018-07-30 18:31:52.796 [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.
2018-07-30 18:31:58.391 [INF] LNWL: Opened wallet
2018-07-30 18:31:58.450 [INF] LTND: Primary chain is set to: bitcoin
2018-07-30 18:31:58.453 [INF] LTND: Initializing btcd backed fee estimator

I don't know why it is looking at 127.0.0.1:10009 and 127.0.0.1:8080 when I have provided the ip in my command. I have also set the ip in my lnd.conf to be the ip of my server just to be safe.

I have verified that the credentials in btcd.conf and btcctl.conf are the same

My server is definitely running and I can call the btcd server with this command: btcctl -u myuser -P mypass -s X.X.X.X:xxxx getpeerinfo --rpccert=rpc.cert

Does anyone know why I can't connect to my server?

Your environment

Roasbeef commented 6 years ago

Looks like you need to check your authentication params for lnd to btcd. On btcd, you're likely seeing a series of authentication failures.

curtischong commented 6 years ago

so I added --rpclisten=X.X.X.X:xxxx --listen=X.X.X.X:xxxx and I would get an output like this:

2018-07-31 11:24:04.688 [INF] LTND: Version 0.4.2-beta commit=
2018-07-31 11:24:04.688 [INF] LTND: Active chain: Bitcoin (network=mainnet)
2018-07-31 11:24:04.688 [INF] CHDB: Checking for schema update: latest_version=3, db_version=3
2018-07-31 11:24:04.703 [ERR] LTND: password RPC server unable to listen on X.X.X.X:xxxx
2018-07-31 11:24:04.703 [INF] LTND: Shutdown complete
listen tcp X.X.X.X:xxxx: bind: can't assign requested address
Roasbeef commented 6 years ago

The listening address isn't the issue (for lnd). Your lnd node can't connect to the btcd node. In this case, you should double check that you have the correct parameters for rpc authentication to the btcd backend.

curtischong commented 6 years ago

My authentication parameters are correct and I know that rpc works because of my btcctl command. It might be my tls certificate but I don't have much experience with those and I don't know what to do. I have tried creating my own TLS certificate but that didn't really work out. Is the tls certificate in the Lnd directory used to connect to your wallet in localhost? or to the backend? are there two tls certificates that I need?

Roasbeef commented 6 years ago

lnd makes its own TLS cert. It expects the btcd cert to be in the default location, if it isn't there, then you need to specify it manually.

I have verified that the credentials in btcd.conf and btcctl.conf are the same You need to check lnd.conf.