pull down to refresh
1 sat \ 4 replies \ @netstatic 26 Aug 2023 \ on: Easiest way to create a LNurl invoice with params? bitcoin
I'm not sure what you're asking for. There are no LNURL invoices, just regular lightning invoices. Since you bring up the "SuccessAction" param I'll assume you want to implement the payRequest spec for LNURL with the successAction spec?
This is a high-level overview of how it works (where 'U' is the user/wallet, 'S' is the server, and 'N' is the lightning node):
U: Bech32 decodes lnurl to get a plaintext ascii url
U->S: makes a request to the url
S->U: Gives json back with min/max amounts and a callback url
U->S: Requests callback url with amount query param
S->N: Requests invoice with amount from query param
N->S: Sends invoice back to server
S->U: Sends json with invoice (in 'pr' property) and a url (wrapped in an object under the 'successAction' property) back to user
The invoice that's generated will typically leverage a lightning node. If you want to construct an invoice manually you can follow the BOLT11 spec but it would be better if you just use your lightning node since the lightning node will have to know the payment_preimage to complete the payment anyway
So basically what I want is this:
My site shows an invoice in a mobile browser, user clics to pay it, wallet opens, users pays, wallet sends the user back to browser.
I can already do all of that (using bolt-11 invoices and "lightning:invoice") except the last step, so as I understand, SuccessAction is what I need to use.
Am I lost?
reply
Ok I think I understand more. It sounds like you are already generating lnurls that deeplink to lightning wallets from the browser. In that case, yes, all you need to do is send the 'successAction' object in the response given from the callback url. To display a url, the successAction object needs to look like:
{ "tag": "url", "description": "Thank you for your purchase. Here is your order details", // Up to 144 characters "url": "https://www.ln-service.com/order/<orderId>" // url domain must be the same as `callback` domain at step 3 }
^ sample json taken from LUD-09 spec
reply
Oh, thanks. hmm, maybe we are getting there but still lost. I don't think I am generating lnurls, my deeplinks look like this: "lightning: lnbc..."
So I guess I need to learn 2 steps:
- How to create LNurls (instead of bolt11)
- Encode the LNurl with params into a deeplink
is that right?
reply
Lnurl Just an encoding of the url.
reply