diff options
Diffstat (limited to '47.md')
| -rw-r--r-- | 47.md | 19 |
1 files changed, 15 insertions, 4 deletions
| @@ -12,8 +12,18 @@ This NIP describes a way for clients to access a remote Lightning wallet through | |||
| 12 | 12 | ||
| 13 | ## Terms | 13 | ## Terms |
| 14 | 14 | ||
| 15 | * **client**: Nostr app on any platform that wants to pay Lightning invoices | 15 | * **client**: Nostr app on any platform that wants to pay Lightning invoices. |
| 16 | * **wallet service**: Nostr app that typically runs on an always-on computer (eg. in the cloud or on a Raspberry Pi). | 16 | * **user**: The person using the **client**, and want's to connect their wallet app to their **client**. |
| 17 | * **wallet service**: Nostr app that typically runs on an always-on computer (eg. in the cloud or on a Raspberry Pi). This app has access to the APIs of the wallets it serves. | ||
| 18 | |||
| 19 | ## Theory of Operation | ||
| 20 | 1. **Users** who which to use this NIP to send lightning payments to other nostr users must first acquire a special "connection" URI from their NIP-47 compliant wallet application. The wallet application may provide this URI using a QR screen, or a pasteable string, or some other means. | ||
| 21 | |||
| 22 | 2. The **user** should then copy this URI into their **client(s)** by pasting, or scanning the QR, etc. The **client(s)** should save this URI and use it later whenever the **user** makes a payment. The **client** should then request an `info` (13194) event from the relay(s) specified in the URI. The **wallet service** will have sent that event to those relays earlier, and the relays will hold it as a replaceable event. | ||
| 23 | |||
| 24 | 3. When the **user** initiates a payment their nostr **client** create a `pay_invoice` request, encrypts it using a token from the URI, and sends it (kind 23194) to the relay(s) specified in the connection URI. The **wallet service** will be listening on those relays and will decrypt the request and then contact the **user's** wallet application to send the payment. The **wallet service** will know how to talk to the wallet application because the connection URI specified relay(s) that have access to the wallet app API. | ||
| 25 | |||
| 26 | 4. Once the payment is complete the **wallet service** will send an encrypted `response` (kind 23195) to the **user** over the relay(s) in the URI. | ||
| 17 | 27 | ||
| 18 | ## Events | 28 | ## Events |
| 19 | 29 | ||
| @@ -24,7 +34,8 @@ There are three event kinds: | |||
| 24 | 34 | ||
| 25 | The info event should be a replaceable event that is published by the **wallet service** on the relay to indicate which commands it supports. The content should be | 35 | The info event should be a replaceable event that is published by the **wallet service** on the relay to indicate which commands it supports. The content should be |
| 26 | a plaintext string with the supported commands, space-seperated, eg. `pay_invoice get_balance`. Only the `pay_invoice` command is described in this NIP, but other commands might be defined in different NIPs. | 36 | a plaintext string with the supported commands, space-seperated, eg. `pay_invoice get_balance`. Only the `pay_invoice` command is described in this NIP, but other commands might be defined in different NIPs. |
| 27 | Both the request and response events SHOULD contain one `p` tag, containing the public key of the **wallet service** if this is a request, and the public key of the **client** if this is a response. The response event SHOULD contain an `e` tag with the id of the request event it is responding to. | 37 | |
| 38 | Both the request and response events SHOULD contain one `p` tag, containing the public key of the **wallet service** if this is a request, and the public key of the **user** if this is a response. The response event SHOULD contain an `e` tag with the id of the request event it is responding to. | ||
| 28 | 39 | ||
| 29 | The content of requests and responses is encrypted with [NIP04](https://github.com/nostr-protocol/nips/blob/master/04.md), and is a JSON-RPCish object with a semi-fixed structure: | 40 | The content of requests and responses is encrypted with [NIP04](https://github.com/nostr-protocol/nips/blob/master/04.md), and is a JSON-RPCish object with a semi-fixed structure: |
| 30 | 41 | ||
| @@ -117,7 +128,7 @@ Errors: | |||
| 117 | ## Example pay invoice flow | 128 | ## Example pay invoice flow |
| 118 | 129 | ||
| 119 | 0. The user scans the QR code generated by the **wallet service** with their **client** application, they follow a `nostr+walletconnect:` deeplink or configure the connection details manually. | 130 | 0. The user scans the QR code generated by the **wallet service** with their **client** application, they follow a `nostr+walletconnect:` deeplink or configure the connection details manually. |
| 120 | 1. **client** sends an event to with **wallet service** service with kind `23194`. The content is a `pay_invoice` request. The private key is the secret from the connection string above. | 131 | 1. **client** sends an event to the **wallet service** service with kind `23194`. The content is a `pay_invoice` request. The private key is the secret from the connection string above. |
| 121 | 2. **wallet service** verifies that the author's key is authorized to perform the payment, decrypts the payload and sends the payment. | 132 | 2. **wallet service** verifies that the author's key is authorized to perform the payment, decrypts the payload and sends the payment. |
| 122 | 3. **wallet service** responds to the event by sending an event with kind `23195` and content being a response either containing an error message or a preimage. | 133 | 3. **wallet service** responds to the event by sending an event with kind `23195` and content being a response either containing an error message or a preimage. |
| 123 | 134 | ||