Skip to content

add method field to quote responses, closes #378 - #387

Merged
thesimplekid merged 2 commits into
mainfrom
add-method-field-to-quote-responses
Jul 4, 2026
Merged

add method field to quote responses, closes #378#387
thesimplekid merged 2 commits into
mainfrom
add-method-field-to-quote-responses

Conversation

@callebtc

@callebtc callebtc commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

@KvngMikey KvngMikey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

robwoodgate added a commit to robwoodgate/cashu-ts that referenced this pull request Jun 12, 2026
Implements cashubtc/nuts#387: every mint and melt quote response
carries a method field. The wallet always knows the method from the
request endpoint, so normalization populates it when the mint omits it
(no mint ships the field yet) and throws when a reported method
disagrees with the endpoint. Once mints implement it, NUT-17 generic
mint_quote/melt_quote notifications become routable by method.
@robwoodgate

robwoodgate commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Implemented in cashubtc/cashu-ts#698 - wallet backfills method from the endpoint for mints that don't send it yet.

robwoodgate added a commit to robwoodgate/cashu-ts that referenced this pull request Jun 12, 2026
Implements cashubtc/nuts#387: every mint and melt quote response
carries a method field. The wallet always knows the method from the
request endpoint, so normalization populates it when the mint omits it
(no mint ships the field yet) and throws when a reported method
disagrees with the endpoint. Once mints implement it, NUT-17 generic
mint_quote/melt_quote notifications become routable by method.
robwoodgate added a commit to robwoodgate/cashu-ts that referenced this pull request Jun 12, 2026
Implements cashubtc/nuts#387: every mint and melt quote response
carries a method field. The wallet always knows the method from the
request endpoint, so normalization populates it when the mint omits it
(no mint ships the field yet) and throws when a reported method
disagrees with the endpoint. Once mints implement it, NUT-17 generic
mint_quote/melt_quote notifications become routable by method.
robwoodgate added a commit to robwoodgate/nuts that referenced this pull request Jun 15, 2026
Consolidates review feedback on the generic payment method PR. Scoped to
the delta NOT covered by cashubtc#377 (accounting fields) or cashubtc#387 (method), so
those can merge independently:

- common mint quote request: optional amount, description, pubkey
- common melt quote request: optional amount
- common mint quote response: expiry, optional pubkey
- common melt quote response: request, optional fee_reserve
- custom mint quotes MUST carry the accounting fields
- custom melt quotes MUST use the standard UNPAID/PENDING/PAID states
@KvngMikey

Copy link
Copy Markdown
Member

implemented in cashubtc/nutshell#1055

robwoodgate added a commit to cashubtc/cashu-ts that referenced this pull request Jul 3, 2026
Implements cashubtc/nuts#387: every mint and melt quote response
carries a method field. The wallet always knows the method from the
request endpoint, so normalization populates it when the mint omits it
(no mint ships the field yet) and throws when a reported method
disagrees with the endpoint. Once mints implement it, NUT-17 generic
mint_quote/melt_quote notifications become routable by method.
@thesimplekid
thesimplekid merged commit 64ec952 into main Jul 4, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in nuts Jul 4, 2026
@thesimplekid
thesimplekid deleted the add-method-field-to-quote-responses branch July 4, 2026 13:56
robwoodgate added a commit to cashubtc/cashu-ts that referenced this pull request Jul 8, 2026
…cts (#698)

Matures the NUT-04/05 base payloads so wallets can handle generic and
custom payment methods, implementing:

- **cashubtc/nuts#377** — mint quote accounting: `amount_paid`,
`amount_issued` and `updated_at` become base mint quote response fields
for every payment method; `state` is deprecated (but always populated
for bolt11).
- **cashubtc/nuts#382** — custom payment methods: base request/response
structs widened per the shapes suggested in review, generic quote
responses get base normalization + validation, and new
`MintQuoteGenericResponse` / `MeltQuoteGenericResponse` passthrough
types are the defaults on the generic quote methods so custom-method
fields are reachable without casting.

- **cashubtc/nuts#387** — every quote response carries a `method` field:
populated from the request endpoint when the mint omits it (no mint
ships it yet), throwing when a reported method disagrees with the
endpoint. Once mints implement it, NUT-17 generic
`mint_quote`/`melt_quote` notifications become routable by method.

Follows up on #672 (nuts#374 `method_name`), which already merged.

## Design notes

- **Required-but-derived accounting.** For mints that predate quote
accounting, `amount_paid`/`amount_issued` are derived from the legacy
single-use `state` + `amount` (UNPAID → 0/0, PAID → amount/0, ISSUED →
amount/amount); conversely a missing bolt11 `state` is derived from the
accounting fields. Underivable responses throw, matching the existing
melt-side strictness. `updated_at` is `number | null` (null when the
mint does not report it — it cannot be derived).
- **Base shapes per the nuts#382 review suggestions.** Mint quote
request base gains optional `amount`/`description`; `expiry` moves into
the mint quote response base (normalized to `null` when unset); melt
quote request base gains optional `amount`; melt quote response base
gains required `request` and optional `fee_reserve` (bolt methods keep
it required, onchain keeps `fee_options`).
- **Mintable amount enforced for all methods.**
`validateMintQuoteAvailableAmount` loses its bolt12/onchain gate:
mintable = `amount_paid − amount_issued` is checked whenever the quote
object carries accounting fields. Stored quotes without them
(pre-accounting) skip the check, as before.
- Method-id validation (`^[a-z0-9_-]+$`) and the generic
`/v1/{mint,melt}/quote/{method}` plumbing already existed and are
unchanged.

## Breaking changes

- `MintQuoteBaseResponse` requires `amount_paid`, `amount_issued`,
`updated_at`, `expiry`; `MeltQuoteBaseResponse` requires `request`.
Type-breaking for code constructing quote literals; runtime consumers
are unaffected because normalization guarantees the fields.
- Non-conformant quote responses that previously passed through
unvalidated (mint quotes missing `quote`/`request`/`unit` or underivable
accounting; melt quotes missing `request`) now throw `Invalid response
from mint`.
@robwoodgate robwoodgate mentioned this pull request Jul 13, 2026
3 tasks
callebtc pushed a commit that referenced this pull request Jul 21, 2026
* Add generic payment method support

* feat(nut04/05): widen common quote structs for custom payment methods

Consolidates review feedback on the generic payment method PR. Scoped to
the delta NOT covered by #377 (accounting fields) or #387 (method), so
those can merge independently:

- common mint quote request: optional amount, description, pubkey
- common melt quote request: optional amount
- common mint quote response: expiry, optional pubkey
- common melt quote response: request, optional fee_reserve
- custom mint quotes MUST carry the accounting fields
- custom melt quotes MUST use the standard UNPAID/PENDING/PAID states

* fix: prettier

* Update 04.md

* fix references to nut17/19

* remove sections

---------

Co-authored-by: Rob Woodgate <robwoodgate@mac.com>
Co-authored-by: Rob Woodgate <robwoodgate@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

NUT-29: add method field for mint and melt quotes, web socket notifications

4 participants