upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--47.md278
1 files changed, 276 insertions, 2 deletions
diff --git a/47.md b/47.md
index b6a4f2b..4cef610 100644
--- a/47.md
+++ b/47.md
@@ -36,6 +36,7 @@ The info event should be a replaceable event that is published by the **wallet s
36a plaintext string with the supported commands, space-separated, eg. `pay_invoice get_balance`. Only the `pay_invoice` command is described in this NIP, but other commands might be defined in different NIPs. 36a plaintext string with the supported commands, space-separated, eg. `pay_invoice get_balance`. Only the `pay_invoice` command is described in this NIP, but other commands might be defined in different NIPs.
37 37
38Both 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. 38Both 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.
39Optionally, a request can have an `expiration` tag that has a unix timestamp in seconds. If the request is received after this timestamp, it should be ignored.
39 40
40The 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: 41The 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:
41 42
@@ -108,7 +109,8 @@ Request:
108{ 109{
109 "method": "pay_invoice", 110 "method": "pay_invoice",
110 "params": { 111 "params": {
111 "invoice": "lnbc50n1..." // bolt11 invoice 112 "invoice": "lnbc50n1...", // bolt11 invoice
113 "amount": 123, // invoice amount in msats, optional
112 } 114 }
113} 115}
114``` 116```
@@ -117,7 +119,7 @@ Response:
117```jsonc 119```jsonc
118{ 120{
119 "result_type": "pay_invoice", 121 "result_type": "pay_invoice",
120 "result": { 122 "result": {
121 "preimage": "0123456789abcdef..." // preimage of the payment 123 "preimage": "0123456789abcdef..." // preimage of the payment
122 } 124 }
123} 125}
@@ -126,6 +128,278 @@ Response:
126Errors: 128Errors:
127- `PAYMENT_FAILED`: The payment failed. This may be due to a timeout, exhausting all routes, insufficient capacity or similar. 129- `PAYMENT_FAILED`: The payment failed. This may be due to a timeout, exhausting all routes, insufficient capacity or similar.
128 130
131### `multi_pay_invoice`
132
133Description: Requests payment of multiple invoices.
134
135Request:
136```jsonc
137{
138 "method": "multi_pay_invoice",
139 "params": {
140 "invoices": [
141 {"id":"4da52c32a1", "invoice": "lnbc1...", "amount": 123}, // bolt11 invoice and amount in msats, amount is optional
142 {"id":"3da52c32a1", "invoice": "lnbc50n1..."},
143 ],
144 }
145}
146```
147
148Response:
149
150For every invoice in the request, a separate response event is sent. To differentiate between the responses, each
151response event contains an `d` tag with the id of the invoice it is responding to, if no id was given, then the
152payment hash of the invoice should be used.
153
154```jsonc
155{
156 "result_type": "multi_pay_invoice",
157 "result": {
158 "preimage": "0123456789abcdef..." // preimage of the payment
159 }
160}
161```
162
163Errors:
164- `PAYMENT_FAILED`: The payment failed. This may be due to a timeout, exhausting all routes, insufficient capacity or similar.
165
166### `pay_keysend`
167
168Request:
169```jsonc
170{
171 "method": "pay_keysend",
172 "params": {
173 "amount": 123, // invoice amount in msats, required
174 "pubkey": "03...", // payee pubkey, required
175 "preimage": "0123456789abcdef...", // preimage of the payment, optional
176 "tlv_records: [ // tlv records, optional
177 {
178 "type": 5482373484, // tlv type
179 "value": "0123456789abcdef" // hex encoded tlv value
180 }
181 ]
182 }
183}
184```
185
186Response:
187```jsonc
188{
189 "result_type": "pay_keysend",
190 "result": {
191 "preimage": "0123456789abcdef...", // preimage of the payment
192 }
193}
194```
195
196Errors:
197- `PAYMENT_FAILED`: The payment failed. This may be due to a timeout, exhausting all routes, insufficient capacity or similar.
198
199### `multi_pay_keysend`
200
201Description: Requests multiple keysend payments.
202
203Has an array of keysends, these follow the same semantics as `pay_keysend`, just done in a batch
204
205Request:
206```jsonc
207{
208 "method": "multi_pay_keysend",
209 "params": {
210 "keysends": [
211 {"id": "4c5b24a351", pubkey": "03...", "amount": 123},
212 {"id": "3da52c32a1", "pubkey": "02...", "amount": 567, "preimage": "abc123..", "tlv_records": [{"type": 696969, "value": "77616c5f6872444873305242454d353736"}]},
213 ],
214 }
215}
216```
217
218Response:
219
220For every keysend in the request, a separate response event is sent. To differentiate between the responses, each
221response event contains an `d` tag with the id of the keysend it is responding to, if no id was given, then the
222pubkey should be used.
223
224```jsonc
225{
226 "result_type": "multi_pay_keysend",
227 "result": {
228 "preimage": "0123456789abcdef..." // preimage of the payment
229 }
230}
231```
232
233Errors:
234- `PAYMENT_FAILED`: The payment failed. This may be due to a timeout, exhausting all routes, insufficient capacity or similar.
235
236### `make_invoice`
237
238Request:
239```jsonc
240{
241 "method": "make_invoice",
242 "params": {
243 "amount": 123, // value in msats
244 "description": "string", // invoice's description, optional
245 "description_hash": "string", // invoice's description hash, optional
246 "expiry": 213 // expiry in seconds from time invoice is created, optional
247 }
248}
249```
250
251Response:
252```jsonc
253{
254 "result_type": "make_invoice",
255 "result": {
256 "type": "incoming", // "incoming" for invoices, "outgoing" for payments
257 "invoice": "string", // encoded invoice, optional
258 "description": "string", // invoice's description, optional
259 "description_hash": "string", // invoice's description hash, optional
260 "preimage": "string", // payment's preimage, optional if unpaid
261 "payment_hash": "string", // Payment hash for the payment
262 "amount": 123, // value in msats
263 "fees_paid": 123, // value in msats
264 "created_at": unixtimestamp, // invoice/payment creation time
265 "expires_at": unixtimestamp, // invoice expiration time, optional if not applicable
266 "metadata": {} // generic metadata that can be used to add things like zap/boostagram details for a payer name/comment/etc.
267 }
268}
269```
270
271### `lookup_invoice`
272
273Request:
274```jsonc
275{
276 "method": "lookup_invoice",
277 "params": {
278 "payment_hash": "31afdf1..", // payment hash of the invoice, one of payment_hash or invoice is required
279 "invoice": "lnbc50n1..." // invoice to lookup
280 }
281}
282```
283
284Response:
285```jsonc
286{
287 "result_type": "lookup_invoice",
288 "result": {
289 "type": "incoming", // "incoming" for invoices, "outgoing" for payments
290 "invoice": "string", // encoded invoice, optional
291 "description": "string", // invoice's description, optional
292 "description_hash": "string", // invoice's description hash, optional
293 "preimage": "string", // payment's preimage, optional if unpaid
294 "payment_hash": "string", // Payment hash for the payment
295 "amount": 123, // value in msats
296 "fees_paid": 123, // value in msats
297 "created_at": unixtimestamp, // invoice/payment creation time
298 "expires_at": unixtimestamp, // invoice expiration time, optional if not applicable
299 "settled_at": unixtimestamp, // invoice/payment settlement time, optional if unpaid
300 "metadata": {} // generic metadata that can be used to add things like zap/boostagram details for a payer name/comment/etc.
301 }
302}
303```
304
305Errors:
306- `NOT_FOUND`: The invoice could not be found by the given parameters.
307
308### `list_transactions`
309
310Lists invoices and payments. If `type` is not specified, both invoices and payments are returned.
311The `from` and `until` parameters are timestamps in seconds since epoch. If `from` is not specified, it defaults to 0.
312If `until` is not specified, it defaults to the current time. Transactions are returned in descending order of creation
313time.
314
315Request:
316```jsonc
317{
318 "method": "list_transactions",
319 "params": {
320 "from": 1693876973, // starting timestamp in seconds since epoch (inclusive), optional
321 "until": 1703225078, // ending timestamp in seconds since epoch (inclusive), optional
322 "limit": 10, // maximum number of invoices to return, optional
323 "offset": 0, // offset of the first invoice to return, optional
324 "unpaid": true, // include unpaid invoices, optional, default false
325 "type": "incoming", // "incoming" for invoices, "outgoing" for payments, undefined for both
326 }
327}
328```
329
330Response:
331```jsonc
332{
333 "result_type": "list_transactions",
334 "result": {
335 "transactions": [
336 {
337 "type": "incoming", // "incoming" for invoices, "outgoing" for payments
338 "invoice": "string", // encoded invoice, optional
339 "description": "string", // invoice's description, optional
340 "description_hash": "string", // invoice's description hash, optional
341 "preimage": "string", // payment's preimage, optional if unpaid
342 "payment_hash": "string", // Payment hash for the payment
343 "amount": 123, // value in msats
344 "fees_paid": 123, // value in msats
345 "created_at": unixtimestamp, // invoice/payment creation time
346 "expires_at": unixtimestamp, // invoice expiration time, optional if not applicable
347 "settled_at": unixtimestamp, // invoice/payment settlement time, optional if unpaid
348 "metadata": {} // generic metadata that can be used to add things like zap/boostagram details for a payer name/comment/etc.
349 }
350 ],
351 },
352}
353```
354
355### `get_balance`
356
357Request:
358```jsonc
359{
360 "method": "get_balance",
361 "params": {
362 }
363}
364```
365
366Response:
367```jsonc
368{
369 "result_type": "get_balance",
370 "result": {
371 "balance": 10000, // user's balance in msats
372 }
373}
374```
375
376### `get_info`
377
378Request:
379```jsonc
380{
381 "method": "get_info",
382 "params": {
383 }
384}
385```
386
387Response:
388```jsonc
389{
390 "result_type": "get_info",
391 "result": {
392 "alias": "string",
393 "color": "hex string",
394 "pubkey": "hex string",
395 "network": "string", // mainnet, testnet, signet, or regtest
396 "block_height": 1,
397 "block_hash": "hex string",
398 "methods": ["pay_invoice", "get_balance", "make_invoice", "lookup_invoice", "list_transactions", "get_info"], // list of supported methods for this connection
399 }
400}
401```
402
129## Example pay invoice flow 403## Example pay invoice flow
130 404
1310. 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. 4050. 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.