1

I have a bitcoind and LND server running. I can make RPC calls to bitcoind using curl, like this:

curl http://XXX:YYY@localhost:8332 -H 'content-type:text/plain;' --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}'

However I can't find out how to make RPC calls to LND using curl.

My lnd.conf contains a [Bitcoind] section like this:

[Bitcoind]
bitcoind.rpchost=127.0.0.1:8332
bitcoind.rpcuser=XXX
bitcoind.rpcpass=YYY
bitcoind.zmqpubrawblock=127.0.0.1:28332
bitcoind.zmqpubrawtx=127.0.0.1:28333

However, what I'm struggling with is finding out or configuring how to actually connect to LND itself with RPC.

Can't find clear documentation about this. I figured out that apparently I need to use port 10009, but this doesn't work:

curl http://XXX:YYY@localhost:10009 -H 'content-type:text/plain;' --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getinfo","params":[]}'

(result is empty, no error, nothing)

I guessed perhaps I need to set a separate RPC username and password for LND, but I can't find out how or where, i.e. what the settings are in lnd.conf?

Also, do I have to add a config line to make sure the LND daemon is listening to RPC calls?

Also, do I have to add a config line to make sure the LND daemon is accepting RPC calls from specific IPs? (localhost in this case, or adding external IPs later)

2 Answers 2

0

The lnd.conf information you shared above is required for the LND instance to query your local bitcoind node (to detect or follow on-chain/mempool events), and does not represent the LND user interface.

LND has a REST API which you can query with curl: https://api.lightning.community/rest/index.html#lnd-rest-api-reference

The REST interface listening port can be configured here: https://github.com/lightningnetwork/lnd/blob/master/config.go

The LND documentation describes it in more detail, but you will need to generate valid macaroons for LND https calls.

8
  • Thanks, but is there no RPC API in LND? Maybe I made some wrong assumptions about how this works. What is LND's port 10009 supposed to do? I though that was for RPC calls, or does that serve another purpose?
    – Rog
    Feb 3, 2019 at 19:23
  • That is not jsonrpc but grpc. If you want to use that you have to compile the interface proto file to the language of your choice and include the interface stub in your client code.
    – James C.
    Feb 3, 2019 at 19:27
  • So.. it's not possible to do this with just one curl command? (as is the case with bitcoind)
    – Rog
    Feb 3, 2019 at 19:36
  • You can query rest api wth curl. There are curl examples in the rest api link above.
    – James C.
    Feb 3, 2019 at 19:38
  • Very much appreciate your comments btw, thanks a lot. I'm now looking through the REST API documentation, however the first example shows the creation of the macaroon header, and a curl command line which uses the tls.cert file in the LND directory. But isn't this supposed to work from somewhere remote, i.e. without having access to local files on the server (i.e. the tls.cert and the .macaroon file)? Or are they supposed to be copied to a remote client location from where you want to call the LND server's REST API?
    – Rog
    Feb 3, 2019 at 19:40
2

LND has two API interfaces:

  1. On port 8080 is a REST RPC interface
  2. On port 10009 is a GRPC interface.

The REST interface on 8080 needs a macaroon file and an optional tls certificate.
You can use CURL like this:

MACAROON_HEADER="Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 ~/.lnd/admin.macaroon)" 
curl -X GET --cacert ~/.lnd/tls.cert --header "$MACAROON_HEADER" https://192.168.0.7:8080/v1/getinfo

if you want to ignore tlc.cert add -k option to the curl call.

The parameters above are:

  1. ~./lnd/admin.macaroon: is the path to your nodes macaroon file (generated by your lnd node)
  2. ~/.lnd/tls.cert: is the path to the tls cert file (generated by your lnd node)
  3. 192.168.0.7:8080 is the IP and port of the RPC of your LND node, if its on the same machine you can just use localhost:8080

You need the following settings in your lnd.conf:

  • restlisten=0.0.0.0:8080 this tells LND to listen to RPC requests on port 8080
  • no-rest-tls=true - this allows you to disable tls certificates
1
  • Ensure you set nolisten=0 norest=0
    – frazras
    Jan 4, 2022 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.