NUT-05: add new state enum, deprecate paid. NUT-05 + NUT-08: use PostMeltQuoteBolt11Response instead of PostMeltBolt11Response #136
No reviewers
Labels
No labels
breaking change
bug
documentation
enhancement
needs discussion
needs implementation
new nut
ready
wallet-only
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo-admin/nuts!136
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "nut-05-state-and-preimage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
New enum field:
stateThis change to NUT-05 deprecates the
paidfield toPostMeltQuoteBolt11Responseand replaces it with astatefield that is a string enum with three possible values:UNPAID,PENDING,PAID."UNPAID"means that the request has not been paid yet."PENDING"means that the request is currently being paid."PAID"means that the request has been paid successfully.New return type for
/v1/melt/bolt11We also replace
PostMeltBolt11ResponsebyPostMeltQuoteBolt11Responseas the response ofPOST /v1/melt/bolt11but in a backwards-compatible way.This means
payment_preimagetoPostMeltQuoteBolt11Response, which holds the bolt11 preimage after a successful paymentchangetoPostMeltQuoteBolt11Response, which returns overspent Lightning feesWhy
This change enables wallet to know whether a Lightning payment is still in flight, if the user closes the wallet during a payment. When the wallet comes back online, it can request the melt quote via
GET /v1/melt/quote/bolt11/{quote_id}and check itsstate.payment_preimagethere.changeand can unblind the response. Previously, wallets would have to restore these tokens to get the overpaid fees back if the payment was interrupted.Implementation
Mints
statefield toPostMeltQuoteBolt11Responsepaidfield around until all wallets updatePostMeltBolt11ResponsebyPostMeltQuoteBolt11Responsepayment_preimagechangetoPostMeltQuoteBolt11ResponsePostMeltQuoteBolt11ResponseforPOST /v1/melt/bolt11Wallets
paidfield withstateand check it insteadAs long as
paidis kept around, wallets can still function the same way as before, also when thePOST /v1/melt/bolt11is changed (since JSON is "backwards compatible" to new fields).Tracking progress:
@ -167,7 +169,7 @@ The settings for this nut indicate the supported method-unit pairs for melting.}We replace
PostMeltBolt11Responsewith the newPostMeltQuoteBolt11Responsewhich also includes the preimage.@ -167,7 +169,7 @@ The settings for this nut indicate the supported method-unit pairs for melting.}github.com/cashubtc/nuts@971ad28477/08.md (L109-L123)We'll need to update NUT-08 to reflect this
Ack. Lightning payments should be modelled as async by the mint api.
Implemented in CDK https://github.com/cashubtc/cdk/pull/181, is backwards compatible
ACK
777886cd18I suggest we add a new endpoint in a different NUT-05 PR that is async (returns immediately) so we can have both. This should be very easy to add to mints.
Should there be a
FAILEDstate? Otherwise, if the lighting payment fails would the lifecycle of a quote beUNPAID->PENDING->UNPAID?I feel
PENDINGandUNPAIDsound a little to close to each other. MaybePENDINGshould be called something likeONGOINGImplemented in Nutmix
Correct, it would go back to
UNPAIDif it fails.ACK
23db305935LFG