0
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)
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 – 2019-02-03T19:23:35.970
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. – 2019-02-03T19:27:28.353
So.. it's not possible to do this with just one curl command? (as is the case with bitcoind) – Rog – 2019-02-03T19:36:37.103
You can query rest api wth curl. There are curl examples in the rest api link above. – James C. – 2019-02-03T19:38:30.663
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 – 2019-02-03T19:40:55.523Exactly, they need to be copied to the client. Check out the full LND getting started guide, it describes this in very well. – James C. – 2019-02-03T19:42:54.263
Just making sure I'm not doing something wrong, I now got this working fine:
curl -X GET --cacert $LND_DIR/tls.cert --header "$MACAROON_HEADER" https://localhost:8080/v1/genseedHowever the response is{"error":"wallet already exists","code":2}rather than the seeds. So the connection and macaroon authentication is working fine. But any other command I try instead ofgenseed, such asgetinfoorpeersorpayments(all as GET requests, no params) returnsNot Foundin all cases. Am I still missing something? – Rog – 2019-02-03T20:49:08.260