Skip to content

Commit

Permalink
added melting
Browse files Browse the repository at this point in the history
  • Loading branch information
Egge21M committed Dec 11, 2024
1 parent 9efbdab commit 0d40500
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions docs/02-Guides/melting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
sidebar_position: 2
---

# Melting Proofs

**Melting** is the reverse of [minting](minting.md). It involves paying [Proofs](https://github.com/cashubtc/nuts/blob/main/00.md#proof) back to the mint to settle an external Lightning invoice. This process consists of three steps:

1. Request a melt quote for the invoice.
2. Submit the required Proofs (including a fee reserve, if applicable).
3. Confirm whether the invoice was paid and collect any change.

:::warning
Mints only refund overpaid fees. To ensure your inputs match the required amount, use `CashuWallet.send()` beforehand to swap Proofs as needed.
:::

```ts
const quote = await wallet.createMeltQuote(mintQuote.request);
const fee = quote.fee_reserve;

const {keep, send} = await wallet.send(10, proofs});

const response = await wallet.meltProofs(quote, send);
```

## Fee Reserve and Change

Mints may include a fee reserve to cover anticipated Lightning fees. The `cashu-ts` library automatically appends [blank outputs](https://github.com/cashubtc/nuts/blob/main/08.md) to the melt request and mints new Proofs if change is returned.

## Options

`meltProofs` accepts a range of options to control the shape of the minted Proofs. Check out the [API Reference](https://github.com/cashubtc/cashu-ts/blob/main/src/CashuWallet.ts) for more information
2 changes: 1 addition & 1 deletion docs/02-Guides/minting.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 1

# Minting Proofs

**Minting** is the operation of making a Lightning payment to the mint to receive some [Proofs](https://github.com/cashubtc/nuts/blob/main/00.md#proof) in return.
**Minting** is the process of creating new [Proofs](https://github.com/cashubtc/nuts/blob/main/00.md#proof) by paying a lightning invoice issued by the mint.
This is a three step process:

1. Request the mint quote for amount `x`
Expand Down

0 comments on commit 0d40500

Please sign in to comment.