Is it possible to connect to BTCPay server remote c-lightning node?

3

I have BTCPay server and would like to use external c-lightning node which i have funded and prefer more over BTCPay server local docker container (DC).

In store configuration i see that there is option to connect to c-lightning over tcp or unix socket (this one is used when i connect internal node because c-lightning DC socket is linked to BTCPay directly).

screenshot of store LN payment configuration menu

How can i connect over TCP? As i uderstand this is not public nodes port (9735) which is used to communicate between nodes but some API port? How can i enable it on c-lightning? Is data sent plain and i should secure communication (lan, fw, vpn etc.)?

baysx

Posted 2019-05-01T15:23:59.820

Reputation: 141

Can't give you the full answer but a hint. Unix domain sockets are local. So you could only connect to a Unix domain socket on that machine / within that docker container. One way is you could migrate your external lightning node inside your dicker container. Shut it down and copy ./lightning dir. I am however sure there is a more elegant way. Also you will most likely not talk to your c Lightning node via port 9735 on tcp as that is what is used on the lightning network. It is new to me that clightning offers a tcp api. Which is the reason I could only comment here and not answer – Rene Pickhardt – 2019-05-01T15:36:00.930

yeah, i see your point. i thought about "sharing" exactly lightning-rpc socket file over ssh or smth similar if its possible to share unix domain socket over lan at all. i have btcpay server and c-lightning on separate physical hosts in same lan, but would like to prefer not to move one into another if its possible. i also could not find any mention about tcp listeners in lightningd help.. – baysx – 2019-05-01T15:41:48.077

Just a word of caution. In case you decide to migrate the node make sure to really migrate the latest channel state and don't run two seperate instances with the same files in the lightning-dir as this will most certainly produce channel beaches with lots of funds – Rene Pickhardt – 2019-05-01T17:14:04.827

Answers

2

Port 9735 is the lightning port. What BTCPay wants is the API. C-Lightning does not support TCP natively, but one can use socat as I did in the docker entrypoint to bridge unix to TCP.

Nicolas Dorier

Posted 2019-05-01T15:23:59.820

Reputation: 729

I'll add additional description if anyone like me will be searching for direct steps there are two ways to connect:

  1. use socat. install and run command socat TCP-LISTEN:22345 UNIX-CONNECT:/path/to/.lightning/lightning-rpc
  2. as suggested before, use https://github.com/ElementsProject/lightning-charge
– baysx – 2019-05-03T08:35:32.900

But what is the EXPOSE_TCP setting for then? I'm confused. I created a new question specifically about that, so that one of you can reap the benefits of answering another question. :) https://bitcoin.stackexchange.com/questions/88862/is-it-possible-to-connect-remotely-to-a-c-lightning-node-with-an-exposed-tcp-por

– gijswijs – 2019-07-05T08:07:01.380

EXPOSE_TCP just mean that the container is running socat to expose RPC over TCP. – Nicolas Dorier – 2019-08-19T05:29:30.340