NUT-04/05: add amount, unit, request to melt and mint quote responses (#719)

* add amount, unit, request to melt and mint responses

* make new fields optional to not break compat with old mints

* make new flags optional for backwards compat
This commit is contained in:
callebtc
2025-03-08 18:23:34 +00:00
committed by GitHub
parent 3ab1e1dfb2
commit bae4855915
6 changed files with 41 additions and 2 deletions

View File

@@ -667,7 +667,10 @@ class Ledger(LedgerVerification, LedgerSpendingConditions, LedgerTasks, LedgerFe
if not payment_quote.checking_id:
raise Exception("quote has no checking id")
# verify that payment quote amount is as expected
if melt_quote.is_mpp and melt_quote.mpp_amount != payment_quote.amount.to(Unit.msat).amount:
if (
melt_quote.is_mpp
and melt_quote.mpp_amount != payment_quote.amount.to(Unit.msat).amount
):
raise TransactionError("quote amount not as requested")
# make sure the backend returned the amount with a correct unit
if not payment_quote.amount.unit == unit:
@@ -759,6 +762,8 @@ class Ledger(LedgerVerification, LedgerSpendingConditions, LedgerTasks, LedgerFe
return PostMeltQuoteResponse(
quote=quote.quote,
amount=quote.amount,
unit=quote.unit,
request=quote.request,
fee_reserve=quote.fee_reserve,
paid=quote.paid, # deprecated
state=quote.state.value,