Skip to content

[bug]: LND uses deprecated 'getinfo' Bitcoin Core API; cannot connect to node #7256

@optout21

Description

@optout21

Background

I have experienced issues connecting LND to Bitcoin Core, and while debugging I found that LND invokes the long-deprecated 'getinfo' API on Bitcoin Core RPC. I am not sure that this is the reason for the disconnection, but seems so, and it seems incorrect.
The bigger-context question is how is it possible to connect LND to a remote BTC node over HTTPS.

Your environment

  • version of lnd: v0.15.4-beta
  • which operating system (uname -a on *Nix) Linux ip-10-242-51-151 5.15.0-1026-aws #30~20.04.2-Ubuntu SMP Fri Nov 25 14:53:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • version of bitcoind: recent Bitcoin Core, exact version not known
  • LND, tag v0.15.4-beta, compiled from sources, on Ubuntu, debug, https://github.com/lightningnetwork/lnd/releases/tag/v0.15.4-beta
  • A remote Bitcoin core full node, accessible through https. Since I have not found a way to directly use a remote https node, I created an nginx proxy, that takes connections on localhost:8332 and forwards them to the remote node.
  • Empty ~/.lnd/mainnet folder

Steps to reproduce

  • I run LND using:
    ~/lnd/lnd-debug --bitcoin.active --bitcoin.mainnet --bitcoin.node=bitcoind --bitcoind.rpchost=localhost --bitcoind.rpcuser=X --bitcoind.rpcpass=Y --bitcoind.zmqpubrawblock=tcp://localhost:8332 --bitcoind.zmqpubrawtx=tcp://localhost:8333
  • LND daemon starts, until wallet creation/unlock
[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.
  • In first run I have created a new wallet, using ~/lnd/lncli-debug create (new wallet, default options). (In subsequent runs, used only unlock.) lnd successfully unlocked!
  • Logs from LND:
2022-12-15 12:26:48.563 [INF] LNWL: Opened wallet
2022-12-15 12:26:48.687 [INF] CHRE: Primary chain is set to: bitcoin
2022-12-15 12:26:50.144 [ERR] LTND: unable to create partial chain control: unable to determine if bitcoind is pruned: unable to detect btcd version: status code: 403, response: ""
2022-12-15 12:26:50.144 [ERR] LTND: Shutting down because error in main method: error creating wallet config: unable to create partial chain control: unable to determine if bitcoind is pruned: unable to detect btcd version: status code: 403, response: ""
2022-12-15 12:26:50.145 [INF] LTND: Shutdown complete
  • Logs from nginx (access and postdata)
127.0.0.1 - X [15/Dec/2022:12:26:49 +0000] "POST / HTTP/1.1" 200 98 "-" "Go-http-client/1.1"
127.0.0.1 - X [15/Dec/2022:12:26:49 +0000] "POST / HTTP/1.1" 200 443 "-" "Go-http-client/1.1"
127.0.0.1 - X [15/Dec/2022:12:26:50 +0000] "POST / HTTP/1.1" 403 0 "-" "Go-http-client/1.1"
[15/Dec/2022:12:26:49 +0000] "POST / HTTP/1.1" 200 98 "-" "Go-http-client/1.1" [{\x22jsonrpc\x22:\x221.0\x22,\x22method\x22:\x22getblockhash\x22,\x22params\x22:[0],\x22id\x22:1}]
[15/Dec/2022:12:26:49 +0000] "POST / HTTP/1.1" 200 443 "-" "Go-http-client/1.1" [{\x22jsonrpc\x22:\x221.0\x22,\x22method\x22:\x22getblockchaininfo\x22,\x22params\x22:[],\x22id\x22:2}]
[15/Dec/2022:12:26:50 +0000] "POST / HTTP/1.1" 403 0 "-" "Go-http-client/1.1" [{\x22jsonrpc\x22:\x221.0\x22,\x22method\x22:\x22getinfo\x22,\x22params\x22:[],\x22id\x22:3}]

As seen, first getblockhash API is invoked, then getblockchaininfo, and then getinfo. The last call returns 403 error code, because this API does not exist.
BTC RPC reference: https://developer.bitcoin.org/reference/rpc/

Expected behaviour

Connect to the node, start up.

Actual behaviour

LND shuts down.

My questions

  • Why does LDN invoke a non-exisitng getinfo BTC API?
  • Is the error from getinfo the reason of shutdown?
  • How is it possible to connect LND to a remote Bitcoin Core node, running in a different location, accessible through an HTTPS link?

Note that after a short search I have not able to find an instance of invoking 'getinfo' in the LND codebase.

Update: Extra info: C-Lightning configured with the same remote-bitcoind-over-nginx-proxy instance worked fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions