From a54c8750243eac976416ecfddaefdc4fe5ac94b7 Mon Sep 17 00:00:00 2001 From: Roei Erez Date: Sun, 28 Jan 2024 15:45:28 +0200 Subject: [PATCH] address feedback --- src/guide/lnurlpay.md | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/guide/lnurlpay.md b/src/guide/lnurlpay.md index 2dc26e5..b37b442 100644 --- a/src/guide/lnurlpay.md +++ b/src/guide/lnurlpay.md @@ -6,17 +6,37 @@ In order to interact with the user node the service uses a simple protocol over The service sends a push notification to the user node with the lnurlpay request and a reply url, the user node then uses the reply url to responds with the required data which is then forwarded from the service to the payer. ## General workflow -Although the protocol is application specific, the general workflow is as follows: +The protocol is application specific and the steps detiled below refer to the c-breez wallet implementation which requires running [breez-lnurl](https://github.com/breez/breez-lnurl) service. ### Step 1: User node register for an lnurlpay service -Use the service endpoint https://app.domain/lnurlpay/[pubkey] to register the user node for an lnurlpay service. -In order to verify the request the payload should be signed with the user node private key. -The service responds with a valid lnurlpay url, for example: https://app.domain/lnurlp/[pubkey] +Use a POST request to the service endpoint https://app.domain/lnurlpay/[pubkey] to register the user node for an lnurlpay service. +This request should contain the following payload: +
+
+{
+ "time": "seconds since epoch",
+ "webhook_url": "notification service webhook url",
+ "signature": "signed payload"
+}
+
+
+ + +In order to verify the request the following payload fields should be signed with the user node private key: [time]-[webhook_url]. +The service responds with following payload: +
+
+{
+ "lnurl": "[valid lnurlpay url]", 
+}
+
+
+ ### Step 2: External wallet scans the lnurlpay url The external wallet scans the lnurlpay url and parse the lnurlpay request. -It then behaves according to the lnurlpay protocol and performs a GET request to https://app.domain.com/lnurlp/[pubkey]. -The service then sends a push notification to the user node with the lnurlpay request and a callback url. Such payload may look like this: +It then behaves according to the lnurlpay protocol and performs a GET request to the scanned lnurl pay url. +This hits the service which in respond sends a push notification to the user node with the lnurlpay request and a callback url. Such payload may look like this:
@@ -30,8 +50,8 @@ The service then sends a push notification to the user node with the lnurlpay re
 
-The reply_url is used by the user node to respond to the lnurlpay request. -The callback_url is the lnurlpay callback url for the payer to fetch the invoice. +The reply_url is used by the user node to respond to the lnurlpay request. +The callback_url is the lnurlpay callback url for the payer to fetch the invoice. ### Step 3: User node responds to the callback url The user node receives the push notification, parses the payload and then uses the reply_url to responds with the required data as per the lnurlpay protocol, for example: @@ -52,7 +72,7 @@ The service receives the response from the mobile and forward the response to th ### step 4: External wallet fetches the invoice -The external wallet uses the callback_url to fetch the invoice and perform a GET request with the amount as a parameter. In our example it is: https://app.domain.com/lnurlpay/invoice?amount=1000 +The external wallet uses the callback_url to fetch the invoice and perform a GET request with the amount as a parameter. In our example it is: https://app.domain.com/lnurlpay/invoice?amount=1000 The push notification is used again to send the request to the user node and the user node replies with the invoice. ### step 5: External wallet pays the invoice