Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node Push Data #7

Open
lnbc1QWFyb24 opened this issue Jul 9, 2022 · 5 comments
Open

Node Push Data #7

lnbc1QWFyb24 opened this issue Jul 9, 2022 · 5 comments

Comments

@lnbc1QWFyb24
Copy link

Is it possible for this library to receive a message from the remote node it is connected to? My use case would be to have a plugin running on the coreln node that listens for events and would then push those events over the lnsocket. Is that possible?

@jb55
Copy link
Owner

jb55 commented Jul 11, 2022

yes! unless you disconnect the connection will stay open and receive messages. lnsocket_recv will return a ln tlv packet with the type decoded. if you just keep calling that function you can get all incoming packets. see lnrpc.c to see how that works, you'll notice it listens for many commando packets and discards non-commando packets like pings.

one thing to note is that CLN will disconnect you if you don't respond to pings, and the library doesn't currently do that for you.

@jb55
Copy link
Owner

jb55 commented Jul 11, 2022

How this might work:

lnsocket client connects with a specific pubkey (once we have that feature), or send a packet with an auth token/rune. The plugin then registers that node for notifications. Once you get a notification on the plugin side it then sends a packet to that registered node. I haven't done something like this yet but would be cool to see how to do it on the plugin side...

You could use the sendcustommsg rpc with the nodeid to send the event.

@lnbc1QWFyb24
Copy link
Author

Awesome! Thanks for the detailed replies. I will give the sendcustommsg rpc a try and see how it goes. I don't know c, but will try and grok what is going on as best I can. Thanks for creating this library, I think there are a lot of super interesting ideas that can be built on this primitive!

@jb55
Copy link
Owner

jb55 commented Jul 12, 2022 via email

@lnbc1QWFyb24
Copy link
Author

ah yeah perhaps I could put together a js demo that listens to and prints lightning messages...

That would be amazing 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants