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

Update 04.md - optional PostMintQuoteBolt11Request keysetId #120

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gudnuf
Copy link
Collaborator

@gudnuf gudnuf commented May 15, 2024

This PR hopes to solve the following problem:

Using a lightning address to mint tokens that are not of unit sat (ie. usd) results in a mismatch between the requested amount and actual amount in the invoice due to a lack of precision between the two units.

When requesting a lightning invoice from an LNURL, the request must specify an amount in msat, so a cashu wallet that provides this functionality must convert msat to the user's preferred unit.

Many lightning wallets that support paying lightning address expect the requested invoice amount to match the actual amount in the returned invoice.

The problem occurs when the user's preferred unit is not sat.

For example:

  • LN Wallet requests invoice from user@domain.com for 50 sats
  • Cashu wallet receives invoice request and converts 50 sats to 3.25 cents
  • Cashu wallet requests mint quote for 3 cents (rounding to nearest token value)
  • Cashu wallet receives bolt11 invoice for ~46 sats from the mint and sends invoice to LN Wallet
  • LN Wallet receives invoice from LNURL callback and validates that the amount in the invoice is 50 sats
  • Amount mismatch results in an invalid invoice error

Solution

By providing a keysetId along with the PostMintQuoteBolt11Request, the wallet is able to mint usd tokens, while specifying the exact amount of sats that should be in the invoice.

An example request would be:

{
   amount: 50,
   unit: 'sat',
   keysetId: <a USD keyset>
}

This request would allow the Cashu wallet to mint 3 usd tokens, but pay an invoice for 50 sats thereby passing the LN wallet's invoice validation.

@@ -24,7 +24,8 @@ The wallet of `Alice` includes the following `PostMintQuoteBolt11Request` data i
```json
{
"amount": <int>,
Copy link

Choose a reason for hiding this comment

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

1000

@@ -24,7 +24,8 @@ The wallet of `Alice` includes the following `PostMintQuoteBolt11Request` data i
```json
{
"amount": <int>,
"unit": <str_enum["sat"]>
"unit": <str_enum["sat"]>,
"keysetId": <Optional<str>>
Copy link

Choose a reason for hiding this comment

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

1212170660831297556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants