Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUT-18: Payment Requests #124

Merged
merged 27 commits into from
Oct 18, 2024
Merged
Changes from 10 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions xx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# NUT-XX: Payment Requests

`optional`

---

This NUT introduces a standardised format for payment requests, that supply a sending wallet with all information necessary to complete the transaction. This enables many use-cases where a transaction is better initiated by the receiver (e.g. point of sale).

## Flow

1. Receiver creates a payment request, encodes it and displays it to the sender
2. Sender scans the request and constructs a matching token
3. Sender sends the token according to the transport specified in the payment request
4. Receiver receives the token and finalises the transaction

## Payment Request

A Payment Request is defined as follows

```json
{
"i": str <optional>,
"a": int <optional>,
"u": str <optional>,
"r": bool <optional>,
"m": Array[str] <optional>,
"d": str <optional>,
"t": Transport
}
```

while Transport is defined as

- `i`: Payment id to be included in the payment payload
- `a`: The amount of the requested payment
- `u`: The unit of the requested payment (MUST be set if `a` is set)
- `s`: Whether the payment request is for single use

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be r to match above

- `m`: A set of mints from which the payment is requested
- `d`: A human readable description that the sending wallet will display after scanning the request
- `t`: The method of transport chosen to transmit the payment (can be multiple, sorted by preference)

## Transport

Transport specifies methods for sending the ecash to the receiver. A transport consists of a type and a target.

```json
{
"t": str,
"a": str,
"g": Array[Array[str, str]] <optional>
}
```

- t: type of Transport
- a: target of Transport
- g: optional tags for the Transport

There are different transport layers:

- nostr
- type: `nostr`
- target: `<nprofile>`
- tags: `[["1", "NIP-04"], ["2", "NIP-17"], ["3", "NIP-61"]]`
- post
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the transport-type post? Do you mean http with the method post? If so I would prefer the term http as the transport-type. Post could be misinterpreted as snailmail

- type: `post`
- target: `<endpoint url>`

## Payment payload

Regardless of the transport layer, the payload sent to the receiver is a JSON serialized object as follows:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this work with NIP-61, where the nostr event is the payment, which has its own format and should be signed by the sender?


```json
{
"id": str <optional>,
"memo": str <optional>,
"mint": str,
"unit": <str_enum>,
"proofs": Array<Proof>
}
```

Here, `id` is the payment id (corresponding to `i` in request), `memo` is an optional memo to be sent to the receiver with the payment, `mint` is the mint URL from which the ecash is from, `unit` is the unit of the payment, and `proofs` is an array of proofs (see [NUT-00][00], can also include DLEQ proofs).

## Encoded Request

The payment request is serialized using CBOR, encoded in `base64_urlsafe`, together with a prefix `creq` and a version `A`:

`"creq" + "A" + base64(CBOR(PaymentRequest))`

_Example_

```sh
creqAaVhQRVhVWNzYXRhTXgiaHR0cHM6Ly9taW50Lm1pbmliaXRzLmNhc2gvQml0Y29pbmFEeCNQbGVzYXNlIHBheSB0aGUgdmVyeSBmaXJzdCBjYXNodSBwcmFUgaJhVGVub3N0cmJUYXhGbnByb2ZpbGUxcXFzZG11cDZlMno2bWNwZXVlNno2a2wwOGhlNDloY2VuNXhucmMzdG5wdncwbWRndGplbWgwc3V4YTBrag
```

[00]: 00.md
Loading