From b35d3a2c74a63b3289d862212c7de9c2470a7702 Mon Sep 17 00:00:00 2001 From: Roy Sheinfeld <31890660+kingonly@users.noreply.github.com> Date: Fri, 26 Jan 2024 01:25:22 +0200 Subject: [PATCH 1/4] Update SUMMARY.md --- src/SUMMARY.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SUMMARY.md b/src/SUMMARY.md index f831e27..f70bd48 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -12,15 +12,15 @@ - [Receiving payments via mobile notifications](guide/payment_notification.md) - [iOS](guide/ios_notification_service_extension.md) - [Android](guide/android_notification_foreground_service.md) - - [Receiving payments via lnurlpay](guide/lnurlpay.md) - [Connecting to an LSP](guide/connecting_lsp.md) - [Receiving an on-chain transaction](guide/receive_onchain.md) - [Sending an on-chain transaction](guide/send_onchain.md) - [Using LNURL](guide/lnurl.md) - - [LNURL-Pay](guide/lnurl_pay.md) - - [LNURL-Withdraw](guide/lnurl_withdraw.md) - - [LNURL-Auth](guide/lnurl_auth.md) + - [Sending payment using LNURL-Pay](guide/lnurl_pay.md) + - [Receiving payments using LNURL-Pay](guide/lnurlpay.md) + - [Receiving payments using LNURL-Withdraw](guide/lnurl_withdraw.md) + - [Authenticating using LNURL-Auth](guide/lnurl_auth.md) - [Supporting fiat currencies](guide/fiat_currencies.md) - [Buying Bitcoin](guide/buy_btc.md) - [Exporting channels backup](guide/static_channel_backup.md) From 699e7b8d185eb8fe6b8474d4d54c515c98d770cd Mon Sep 17 00:00:00 2001 From: Roy Sheinfeld <31890660+kingonly@users.noreply.github.com> Date: Fri, 26 Jan 2024 01:26:49 +0200 Subject: [PATCH 2/4] Update SUMMARY.md --- src/SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SUMMARY.md b/src/SUMMARY.md index f70bd48..41e386d 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -17,7 +17,7 @@ - [Sending an on-chain transaction](guide/send_onchain.md) - [Using LNURL](guide/lnurl.md) - - [Sending payment using LNURL-Pay](guide/lnurl_pay.md) + - [Sending payments using LNURL-Pay](guide/lnurl_pay.md) - [Receiving payments using LNURL-Pay](guide/lnurlpay.md) - [Receiving payments using LNURL-Withdraw](guide/lnurl_withdraw.md) - [Authenticating using LNURL-Auth](guide/lnurl_auth.md) From 4b0ac40f59aeef63626e9ef0cf62a965d10263be Mon Sep 17 00:00:00 2001 From: Roy Sheinfeld <31890660+kingonly@users.noreply.github.com> Date: Fri, 26 Jan 2024 01:43:28 +0200 Subject: [PATCH 3/4] Update lnurlpay.md --- src/guide/lnurlpay.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/guide/lnurlpay.md b/src/guide/lnurlpay.md index 2dc26e5..bbddcf8 100644 --- a/src/guide/lnurlpay.md +++ b/src/guide/lnurlpay.md @@ -1,17 +1,18 @@ -# Receiving via lnurl-pay +# Receiving payments using LNURL-Pay -Using the Breez SDK users have the ability to receive Lightning payments via lnurl-pay. -The lnurlpay protocol requires a web server that respons to lnurlpay requests. This service needs to communicate with the user node in order to fetch the required data and the payment request. -In order to interact with the user node the service uses a simple protocol over push notifications. -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. +Breez SDK users have the ability to receive Lightning payments using [LNURL-Pay](https://github.com/lnurl/luds/blob/luds/06.md). +LNURL-Pay requires a web service that serves LNURL-Pay requests. This service needs to communicate with the user node in order to fetch the necessary metadata data and the associated payment request. +To interact with the user node, the service uses a simple protocol over push notifications: +* The service sends a push notification to the user's mobile app with the LNURL-Pay request and a reply URL. +* The app responds to reply URL with the required data. +* The data is forwarded from the service to the payer. ## General workflow -Although the protocol is application specific, the general workflow is as follows: -### 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] +### Step 1: the app registers for an LNURL-Pay service +Use the service endpoint https://app.domain/lnurlpay/[pubkey] to register the app for an LNURL-Pay service. +To verify the request the payload should be signed with the user node private key. +The service responds with a valid LNURL-Pay url, for example: https://app.domain/lnurlp/[pubkey] ### Step 2: External wallet scans the lnurlpay url The external wallet scans the lnurlpay url and parse the lnurlpay request. @@ -61,4 +62,4 @@ This is the last step in the lnurlpay protocol, the external wallet pays the inv ## Reference implementation All the above steps are payloads are one option among many, the service and the user node can agree on any other payload format. For a complete reference, see how we implemented it in c-breez wallet: [NotificationService.swift](https://github.com/breez/c-breez/blob/main/ios/Breez%20Notification%20Service%20Extension/NotificationService.swift). -And the lnurlpay service: [breez-lnurl](https://github.com/breez/breez-lnurl) \ No newline at end of file +And the lnurlpay service: [breez-lnurl](https://github.com/breez/breez-lnurl) From f54dde8a8cbe39dc68c665fe9d2bd6b66718fda3 Mon Sep 17 00:00:00 2001 From: Roy Sheinfeld <31890660+kingonly@users.noreply.github.com> Date: Fri, 26 Jan 2024 02:15:03 +0200 Subject: [PATCH 4/4] Update lnurlpay.md --- src/guide/lnurlpay.md | 68 +++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/src/guide/lnurlpay.md b/src/guide/lnurlpay.md index bbddcf8..f3fdc9c 100644 --- a/src/guide/lnurlpay.md +++ b/src/guide/lnurlpay.md @@ -1,6 +1,7 @@ # Receiving payments using LNURL-Pay Breez SDK users have the ability to receive Lightning payments using [LNURL-Pay](https://github.com/lnurl/luds/blob/luds/06.md). + LNURL-Pay requires a web service that serves LNURL-Pay requests. This service needs to communicate with the user node in order to fetch the necessary metadata data and the associated payment request. To interact with the user node, the service uses a simple protocol over push notifications: * The service sends a push notification to the user's mobile app with the LNURL-Pay request and a reply URL. @@ -9,18 +10,27 @@ To interact with the user node, the service uses a simple protocol over push not ## General workflow -### Step 1: the app registers for an LNURL-Pay service -Use the service endpoint https://app.domain/lnurlpay/[pubkey] to register the app for an LNURL-Pay service. +### Step 1: Registering for an LNURL-Pay service +Use the service endpoint: + +``` +https://app.domain/lnurlpay/[pubkey] +``` + +to register the app for an LNURL-Pay service. To verify the request the payload should be signed with the user node private key. -The service responds with a valid LNURL-Pay url, for example: https://app.domain/lnurlp/[pubkey] +The service responds with a valid LNURL-Pay url, for example: +``` +https://app.domain/lnurlp/[pubkey] +``` +### Step 2: Processing an LNURL-Pay request +When an LNURL-Pay request is triggered a GET request to: +``` +https://app.domain.com/lnurlp/[pubkey] +``` +The service then sends a push notification to the app with the LNURL-Pay request and a callback URL. Such payload may look like the following: -### 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: - -
-
+```
 {
  "template": "lnurlpay_info",
  "data": {  
@@ -28,17 +38,15 @@ The service then sends a push notification to the user node with the lnurlpay re
   "callback_url": https://app.domain.com/lnurlpay/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. +The reply_url is used by the app to respond to the lnurlpay request. +The callback_url is the LNURL-Pay callback URL, used by 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: +### Step 3: Responding to the callback url +When the app receives the push notification, it parses the payload and then uses the reply_url to respond with the required data, for example: -
-
+```
 {
  "callback": "https://app.domain.com/lnurlpay/invoice",
  "maxSendable": 10000,
@@ -46,20 +54,22 @@ The user node receives the push notification, parses the payload and then uses t
  "metadata": "[[\"text/plain\",\"Pay to Breez\"]]",
  "tag": "payRequest"
 }
-
-
+``` -The service receives the response from the mobile and forward the response to the external wallet. +The service receives the response from the app and forwards it to the sender. -### step 4: External wallet fetches the invoice +### Step 4: Fetching a bolt11 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 push notification is used again to send the request to the user node and the user node replies with the invoice. +The sender fetchs a bolt11 invoice by invoking a GET request to the callback_url with adding a specific amount as a query parameter. For example: +``` +https://app.domain.com/lnurlpay/invoice?amount=1000 +``` +An additional push notification is triggered to send the invoice request to the app. Then the app replied with the bolt11 invoice data. -### step 5: External wallet pays the invoice -This is the last step in the lnurlpay protocol, the external wallet pays the invoice and the payment is received by the user node. See [payment_notification](payment_notification.md) for more details on how to receive payments via push notifications. +### Step 5: Paying the invoice +In the last step, the payer pays the received bolt11 invoice. Follow the steps [here](payment_notification.md) to receive payments via push notifications. ## Reference implementation -All the above steps are payloads are one option among many, the service and the user node can agree on any other payload format. -For a complete reference, see how we implemented it in c-breez wallet: [NotificationService.swift](https://github.com/breez/c-breez/blob/main/ios/Breez%20Notification%20Service%20Extension/NotificationService.swift). -And the lnurlpay service: [breez-lnurl](https://github.com/breez/breez-lnurl) +For a complete reference implementation, see: +* [Breez's NotificationService](https://github.com/breez/c-breez/blob/main/ios/Breez%20Notification%20Service%20Extension/NotificationService.swift) +* [Breez's LNURL-Pay service](https://github.com/breez/breez-lnurl)