Files
nutshell/docs/specs/05.md
calle 7e39e1b036 BREAKING: PostMeltRequest, CheckSpendableResponse ` (#106)
* fix PostMeltRequest and /checkfees to GET

* POST /check -> GET /check

* fix GetCheckSpendableResponse

* rename models

* make format

* revert GET

* bump version to 0.9

* skip nostr test
2023-01-30 09:13:46 +01:00

81 lines
1.7 KiB
Markdown

# NUT-5: Melting tokens
Melting tokens is the opposite of minting them (see #4): the wallet `Alice` sends `Proofs` to the mint `Bob` together with a bolt11 Lightning invoice that `Alice` wants to be paid. To melt tokens, `Alice` sends a `POST /melt` request with a JSON body to the mint. The `Proofs` included in the request will be burned by the mint and the mint will pay the invoice in exchange.
`Alice`'s request **MUST** include a `PostMeltRequest` ([TODO: Link PostMeltRequest]) JSON body with `Proofs` that have at least the amount of the invoice to be paid.
## Example
**Request** of `Alice`:
```http
POST https://mint.host:3338/melt
```
With the data being of the form `PostMeltRequest`:
```json
{
"proofs":
[
Proof,
...
],
"pr": str
}
```
With curl:
```bash
curl -X POST https://mint.host:3338/mint&payment_hash=67d1d9ea6ada225c115418671b64a -d \
{
"proofs" :
[
{
"id": "DSAl9nvvyfva",
"amount": 2,
"secret": "S+tDfc1Lfsrb06zaRdVTed6Izg",
"C": "0242b0fb43804d8ba9a64ceef249ad7a60f42c15fe6d4907238b05e857527832a3"
},
{
...
}
],
"pr": "lnbc100n1p3kdrv5sp5lpdxzghe5j67q..."
}
```
**Response** `PostMeltResponse` from `Bob`:
```json
{
"paid": true,
"preimage": "da225c115418671b64a67d1d9ea6a..."
}
```
Only if the `paid==true`, the wallet `Alice` **MUST** delete the `Proofs` from her database (or move them to a history). If `paid==false`, `Alice` **CAN** repeat the same multiple times until the payment is successful.
[00]: 00.md
[01]: 01.md
[02]: 02.md
[03]: 03.md
[04]: 04.md
[05]: 05.md
[06]: 06.md
[07]: 07.md
[08]: 08.md
[09]: 09.md
[10]: 10.md
[11]: 11.md
[12]: 12.md
[13]: 13.md
[14]: 14.md
[15]: 15.md
[16]: 16.md
[17]: 17.md
[18]: 18.md
[19]: 19.md
[20]: 20.md