jb55 / lnsocket

A minimal C & js library for sending messages to lightning nodes
Other
61 stars 9 forks source link

Static Key #8

Open lnbc1QWFyb24 opened 2 years ago

lnbc1QWFyb24 commented 2 years ago

Is it possible to have a static public key so that the remote node can limit the rune to that key? Or does a new key need to be created every time it is initialised with the gen_key method?

jb55 commented 2 years ago

yes this will be easy to add and why there is a generate_key step. I planned on having a set_key function as well. I haven't had the need for it yet though which is why it doesn't exist.

lnbc1QWFyb24 commented 2 years ago

Yeah the use case I am thinking is for a server to communicate to a core ln node. The idea I am playing with would be a simple API that can be deployed to run in front of your node at home. So it would be great to have a rune with full permissions, but limit it to the public key of the lnsocket.

jb55 commented 2 years ago

On Mon, Jul 11, 2022 at 03:52:09PM -0700, Aaron Barnard wrote:

Yeah the use case I am thinking is for a server to communicate to a core ln node. The idea I am playing with would be a simple API that can be deployed to run in front of your node at home. So it would be great to have a rune with full permissions, but limit it to the public key of the lnsocket.

kk I'll add this soon

lnbc1QWFyb24 commented 2 years ago

Legend thank you!

jb55 commented 2 years ago

there is now an lnsocket_setkey in v0.3.2 for setting static keys. Let me know if you run into any issues!

jb55 commented 2 years ago

js example here: https://github.com/jb55/lnsocket/blob/dead45a7a5220ae8b3b0833b2d553815452ccb6e/test/connection.js#L15-L20

jb55 commented 2 years ago

hmm it might be good to have a method that gets the pubkey...

lnbc1QWFyb24 commented 2 years ago

Awesome will give this a go.

lnbc1QWFyb24 commented 2 years ago

Yeah a method that gets the pubkey would be super handy. Saves having to load tiny-secp256k1 in the browser to derive the pub key.

lnbc1QWFyb24 commented 2 years ago

Or even a method to get the keypair after generating the key. That way you can use set key in a later session with the private key

jb55 commented 2 years ago

yup it's definitely needed... will add in a bit