cln-application icon indicating copy to clipboard operation
cln-application copied to clipboard

Add Invoice Macaroon to Settings

Open john-zaprite opened this issue 1 year ago • 10 comments

We are adding a CLN connection to Zaprite. To make it easier for users to connect, it would be great if they had an option to copy an Invoice Macaroon from the Settings screen.

Maybe there could be a toggle to allow the user to choose which one they needed?

cln-macaroon-toggle

john-zaprite avatar Mar 02 '24 11:03 john-zaprite

I am trying to create an "invoice" rune via the cli. i basically need a limited access rune to create an invoice and to read if that invoice was paid. i tried creating a macaroon (base64) using the cli:

lightning-cli createrune restrictions='[["method=invoice,method=listinvoices"]]'

But i get this error when hitting the rest api with the generated rune:

Bad Macaroon!

Any ideas (*note I am using the CLN app packaged in Umbrel)?

ntheile avatar Mar 06 '24 03:03 ntheile

Restrictions are the array of alternatives, so your command should look something like:

lightning-cli createrune restrictions='[["method=invoice"], ["method=listinvoices"]]'

ShahanaFarooqui avatar Mar 06 '24 06:03 ShahanaFarooqui

https://github.com/ElementsProject/cln-application/pull/56

evansmj avatar May 01 '24 16:05 evansmj

Screenshot 2024-05-01 at 1 21 04 PM Screenshot 2024-05-01 at 1 21 10 PM

Here is what I have it looking like.
@ShahanaFarooqui is the rest 'Macaroon' supposed to be blank?

evansmj avatar May 01 '24 17:05 evansmj

Here is what I have it looking like. @ShahanaFarooqui is the rest 'Macaroon' supposed to be blank?

Do you have c-lightning-rest running? If yes, have you set APP_CORE_LIGHTNING_REST_CERT_DIR correctly in your environment for macaroon to be read successfully from the location?

Also, adding invoice rune on the c-lightning-rest screen doesn't make sense. It is the old rest API library which generates its own macaroon. It does not support runes. We do not have a connect screen & configured variables (like clnrest-port, host, etc.) required for clnrest library yet.

ShahanaFarooqui avatar May 06 '24 18:05 ShahanaFarooqui

Oh okay thanks, so I'll update the pr to hide the Invoice Rune when REST is selected.

evansmj avatar May 06 '24 18:05 evansmj

@john-zaprite c-lightning-REST only supports access.macaroon (admin). Without c-lightning-REST generating invoice macaroon, the UI cannot provide this information. Also, with upcoming sunset of c-lightning-REST, it will not be possible to add that in future also.

ShahanaFarooqui avatar May 06 '24 18:05 ShahanaFarooqui

Thanks @evansmj for looking into this and writing the code!

@ShahanaFarooqui so would you recommend using LNMessage instead of the REST endpoint for Zaprite to connect to the core-lightning node? I think most of our uses are going to be running the version of CLN-App that is packaged up in Umbrel. https://github.com/aaronbarnardsound/lnmessage

ntheile avatar May 06 '24 19:05 ntheile

There are many ways to connect to Core Lightning node as explained here. You can choose any one of them according to your requirement. lnmessage is a NodeJS commando client. For REST API solution, clnrest is the built-in Python REST server.

ShahanaFarooqui avatar May 06 '24 19:05 ShahanaFarooqui

Updated https://github.com/ElementsProject/cln-application/pull/56 to hide Invoice Rune from the rest and grpc menus.

evansmj avatar May 07 '24 23:05 evansmj

https://github.com/ElementsProject/cln-application/pull/56 is now merged if you would like to check out how it looks for the zaprite article screenshots @ntheile @john-zaprite

evansmj avatar Jun 06 '24 12:06 evansmj

Closing with PR #56

ShahanaFarooqui avatar Jun 06 '24 15:06 ShahanaFarooqui

Thanks @evansmj and @ShahanaFarooqui ! Super excited to integrate this into Zaprite!

ntheile avatar Jun 06 '24 16:06 ntheile