Skip to content

Commit

Permalink
feat: nut19 in nut20
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Nov 18, 2024
1 parent 3d2f85e commit 9557e9e
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions 20.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

`optional`

`depends on: NUT-19`

---

Similar to [NUT-04][04], which covers minting via BOLT11 invoices, minting via [BOLT12](https://github.com/lightning/bolts/blob/master/12-offer-encoding.md) is also a two-step process: requesting a mint quote and minting tokens. This document describes both steps, focusing on BOLT12-specific considerations.
Expand All @@ -22,11 +24,17 @@ The wallet of `Alice` includes the following `PostMintQuoteBolt12Request` data i
"unit": <str_enum["sat"]>,
"description": <str|null>,
"expiry": <int|null>,
"single_use": <bool>
"single_use": <bool>,
"pubkey": <str>
}
```

The `amount` field is optional and specifies the amount to mint. The `unit` field is mandatory. An optional `description` can be passed if the mint signals support for it in `MintMethodSetting`. If `single_use` is false, the offer can be paid multiple times. The optional `expiry` field specifies the unix timestamp when the offer expires it **MUST** be before the `max_expiry` in the `MintMethodSettings` if one is given.
The `amount` field is optional and specifies the amount to mint. The `unit` field is mandatory. An optional `description` can be passed if the mint signals support for it in `MintMethodSetting`. If `single_use` is false, the offer can be paid multiple times. The optional `expiry` field specifies the unix timestamp when the offer expires it **MUST** be before the `max_expiry` in the `MintMethodSettings` if one is given. `pubkey` is the public key that will be required for signature verification during the minting process. The mint will only mint ecash after receiving a valid signature from the corresponding private key in the `PostMintRequest`.

> **Note:** While a pubkey is optinal as per [NUT-19][19] for [NUT-04][04] it is required in this NUT and the mint **MUST NOT** issue a mint quote if one is not included.

> **Privacy:** To prevent linking multiple mint quotes together, wallets **SHOULD** generate a unique public key for each mint quote request
The mint `Bob` then responds with a `PostMintQuoteBolt12Response`:

Expand All @@ -36,7 +44,8 @@ The mint `Bob` then responds with a `PostMintQuoteBolt12Response`:
"request": <str>,
"expiry": <int>,
"amount_paid": <int>,
"amount_issued": <int>
"amount_issued": <int>,
"pubkey": <str>
}
```

Expand All @@ -60,7 +69,8 @@ Response of `Bob`:
"request": "lno1qcp...",
"expiry": 1701704757,
"amount_paid": 0,
"amount_issued": 0
"amount_issued": 0,
"pubkey": "03d56ce4e446a85bbdaa547b4ec2b073d40ff802831352b8272b7dd7a4de5a7cac"
}
```

Expand All @@ -82,6 +92,11 @@ Example request of `Alice` with curl:
curl -X GET http://localhost:3338/v1/mint/quote/bolt12/DSGLX9kevM...
```

#### Witness

In order to mint ecash the wallet **MUST** include a signature as defined in [NUT-19][19].


# Minting tokens

After requesting a mint quote and paying the request, the wallet proceeds with minting new tokens by calling `POST /v1/mint/bolt12`.
Expand All @@ -95,11 +110,12 @@ The wallet `Alice` includes the following `PostMintBolt12Request` data in its re
```json
{
"quote": <str>,
"outputs": <Array[BlindedMessage]>
"outputs": <Array[BlindedMessage]>,
"witness": <str>
}
```

The `quote` is the quote ID from the previous step and `outputs` are `BlindedMessages` (see [NUT-00][00]) that the wallet requests signatures on. The sum of the outputs must equal the amount that can be minted (`amount_paid` - `amount_issued`).
The `quote` is the quote ID from the previous step and `outputs` are `BlindedMessages` (see [NUT-00][00]) that the wallet requests signatures on. The sum of the outputs must equal the amount that can be minted (`amount_paid` - `amount_issued`). `witness` is the signature on the mint quote id as defined above.

The mint `Bob` then responds with a `PostMintBolt12Response`:

Expand Down Expand Up @@ -175,3 +191,4 @@ Example `MintMethodSetting`:
[10]: 10.md
[11]: 11.md
[12]: 12.md
[19]: 19.md

0 comments on commit 9557e9e

Please sign in to comment.