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-XX: Multinut payments #103

Merged
merged 15 commits into from
May 22, 2024
2 changes: 1 addition & 1 deletion 08.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NUT-08: Lightning fee return
==========================

`optional`
`optional`, `depends on: NUT-05`

---

Expand Down
2 changes: 1 addition & 1 deletion 11.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NUT-11: Pay to Public Key (P2PK)
==========================

`optional`
`optional`, `depends on: NUT-10`

---

Expand Down
80 changes: 80 additions & 0 deletions 15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
NUT-15: Partial multi-path payments
==========================

`optional` `depends on: NUT-05`

---

In this document, we describe how wallets can instruct multiple mints to each pay a partial amount of a bolt11 Lightning invoice. The full payment is composed of partial payments (MPP) from multiple multi-path payments from different Lightning nodes. This way, wallets can pay a larger Lightning invoice combined from multiple smaller balances on different mints. Due to the atomic nature of MPP, either all payments wil be successful or all of them will fail.

The Lightning backend of the mint must support paying a partial amount of an Invoice and multi-path payments (MPP, see [BOLT 4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md)). For example, the mint's Lightning node must be able to pay 50 sats of a 100 sat bolt11 invoice. The receiving Lightning node must support receiving multi-path payments as well.

## Multimint payment execution

`Alice`'s wallet coordinates multiple MPPs on different mints that support the feature (see below for the indicated setting). For a given Lightning invoice of `amount_total`, `Alice` splits the total amount into several partial amounts `amount_total = amount_1 + amount_2 + ...` that each must be covered by her individual balances on the mints she wants to use for the payment. She constructs multiple `PostMeltQuoteBolt11Request`'s that each include the corresponding partial amount in the payment option (see below) that she sends to all mints she wants to use for the payment. The mints then respond with a normal `PostMeltQuoteBolt11Response` (see [NUT-05][05]). `Alice` proceeds to pay the melt requests at each mint simultaneously. When all mints have sent out the partial Lightning payment, she receives a successful response from all mints individually.

## Melt quote

To request a melt quote with a partial `amount`, the wallet of `Alice` makes a `POST /v1/melt/quote/bolt11` similar to [NUT-05][05].

```http
POST https://mint.host:3338/v1/melt/quote/bolt11
```

The wallet `Alice` includes the following `PostMeltQuoteBolt11Request` data in its request which includes an additional (and optional) `options` object compared to the standard request in [NUT-05][05]:

```json
{
"request": <str>,
"unit": <str_enum["sat"]>,
"options": {
"mpp": {
"amount": <int>
}
}
}
```

Here, `request` is the bolt11 Lightning invoice to be paid, `unit` is the unit the wallet would like to pay with, and `amount` is the amount for the requested payment. The wallet then pays the returned melt quote the same way as in [NUT-05][05].

## Settings

The settings returned in the info endpoint ([NUT-06][06]) indicate that a mint supports this NUT. The mint MUST indicate each `method` and `unit` that supports `mpp`. It can indicate this in an array of objects for multiple `method` and `unit` pairs and the boolean flag `mpp` set to `true`.

`MultipathPaymentSetting` is of the form:
```json
{
[
{
"method": <str>,
"unit": <str>,
"mpp": <bool>
},
...
]
}
```

Example `MultipathPaymentSetting`:

```json
{
"15": {
[
{
"method": "bolt11",
"unit": "sat",
"mpp": true
},
{
"method": "bolt11",
"unit": "usd",
"mpp": true
},
]
}
}
```

[05]: 05.md
[06]: 06.md
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Wallets and mints `MUST` implement all mandatory specs and `CAN` implement optio
| [12][12] | DLEQ proofs | [Nutshell][py], [cdk] | [Nutshell][py], [cashu-rs-mint] |
| [13][13] | Deterministic secrets | [Nutshell][py], [Moksha][moksha], [cashu-ts][ts], [cdk] | - |
| [14][14] | Hashed Timelock Contracts (HTLCs) | [Nutshell][py], [cdk] | [Nutshell][py], [cashu-rs-mint] |
| [15][15] | Partial multi-path payments (MPP) | [Nutshell][py] | [Nutshell][py] |

#### Wallets:

Expand Down Expand Up @@ -76,3 +77,4 @@ Wallets and mints `MUST` implement all mandatory specs and `CAN` implement optio
[12]: 12.md
[13]: 13.md
[14]: 14.md
[15]: 15.md