Abstract NUT-04 and NUT-05 Payment Methods #258

Merged
davidcaseria merged 15 commits from update_methods into main 2025-06-01 10:14:44 +00:00
davidcaseria commented 2025-05-08 14:56:31 +00:00 (Migrated from github.com)

NUT-04 and NUT-05 have been rewritten to be more abstract and to handle any possible payment method. These NUTs remain mandatory.

The officially defined BOLT11 payment method is organized under NUT-23. This NUT is optional.

There are no breaking changes to this refactor.

NUT-04 and NUT-05 have been rewritten to be more abstract and to handle any possible payment method. These NUTs remain mandatory. The officially defined BOLT11 payment method is organized under NUT-23. This NUT is optional. There are no breaking changes to this refactor. - [x] CDK https://github.com/cashubtc/cdk/pull/749 - [x] Nutshell - [ ] cashu-ts - [ ] nutmix
callebtc (Migrated from github.com) reviewed 2025-05-08 14:56:31 +00:00
callebtc commented 2025-05-10 11:18:16 +00:00 (Migrated from github.com)

This is awesome. Does it include the bolt12 file by accident? If not, it might be useful to merge it with the bolt12 spec (https://github.com/cashubtc/nuts/pull/170).

This is awesome. Does it include the bolt12 file by accident? If not, it might be useful to merge it with the bolt12 spec (https://github.com/cashubtc/nuts/pull/170).
callebtc (Migrated from github.com) reviewed 2025-05-10 11:30:56 +00:00
@ -4,3 +4,3 @@
`used in: NUT-20`
`used in: NUT-20, NUT-23`
callebtc (Migrated from github.com) commented 2025-05-10 11:30:56 +00:00

I think bolt12 does not have this state

I think bolt12 does not have this state ```suggestion ```
callebtc (Migrated from github.com) reviewed 2025-05-10 11:31:30 +00:00
@ -4,3 +4,3 @@
`used in: NUT-20`
`used in: NUT-20, NUT-23`
callebtc (Migrated from github.com) commented 2025-05-10 11:31:29 +00:00

This would have to go to the bolt11 spec in 23.md

This would have to go to the bolt11 spec in `23.md`
callebtc (Migrated from github.com) reviewed 2025-05-10 11:34:15 +00:00
callebtc (Migrated from github.com) commented 2025-05-10 11:34:15 +00:00

This (the shown json) is also bolt11 specific, maybe we can mention here that there are settings for each method and their structure is defined in each spec file.

This (the shown json) is also bolt11 specific, maybe we can mention here that there are settings for each method and their structure is defined in each spec file.
callebtc (Migrated from github.com) reviewed 2025-05-10 11:37:32 +00:00
@ -97,3 +74,3 @@
Like before, the mint `Bob` responds with a `PostMeltQuoteBolt11Response`.
The mint responds with the same structure as the initial quote response.
callebtc (Migrated from github.com) commented 2025-05-10 11:37:32 +00:00

Should we keep this state in here as long as it's common for all payment methods or move it to bolt11?

Should we keep this state in here as long as it's common for all payment methods or move it to bolt11?
thesimplekid (Migrated from github.com) requested changes 2025-05-10 11:38:04 +00:00
@ -4,3 +4,3 @@
`used in: NUT-20`
`used in: NUT-20, NUT-23`
thesimplekid (Migrated from github.com) commented 2025-05-10 11:30:28 +00:00

State may not be used for all of them. For example in the current draft of bolt12 I've removed it in favor of having an amount_paid field and an amount_minted field. I recommend we remove the state here and then specify it in bolt11 (23).

State may not be used for all of them. For example in the current draft of bolt12 I've removed it in favor of having an `amount_paid` field and an `amount_minted` field. I recommend we remove the state here and then specify it in bolt11 (23).
@ -218,23 +133,15 @@ The settings for this nut indicate the supported method-unit pairs for minting a
"unit": <str>,
"min_amount": <int|null>,
thesimplekid (Migrated from github.com) commented 2025-05-10 11:34:04 +00:00

Description is bolt11 specific.

```suggestion ``` Description is bolt11 specific.
thesimplekid (Migrated from github.com) commented 2025-05-10 11:36:56 +00:00

Amountless should be removed from the example.

Amountless should be removed from the example.
thesimplekid (Migrated from github.com) commented 2025-05-10 11:26:11 +00:00
```suggestion ```
callebtc (Migrated from github.com) reviewed 2025-05-10 11:40:15 +00:00
@ -106,3 +79,1 @@
# Melting tokens
Now that `Alice` knows what the total amount is (`amount + fee + fee_reserve`) in her requested `unit`, she can proceed for melting tokens for which a payment will be executed by the mint. She calls the `POST /v1/melt/{method}` endpoint where `method` is the payment method requested (here `bolt11`).
To execute the melting process, the wallet calls the `POST /v1/melt/{method}` endpoint.
callebtc (Migrated from github.com) commented 2025-05-10 11:40:14 +00:00

Move to bolt11? Not quite sure.

Move to bolt11? Not quite sure.
callebtc (Migrated from github.com) reviewed 2025-05-10 11:43:29 +00:00
@ -218,23 +133,15 @@ The settings for this nut indicate the supported method-unit pairs for minting a
"unit": <str>,
"min_amount": <int|null>,
callebtc (Migrated from github.com) commented 2025-05-10 11:43:29 +00:00

I would suggest to move the entire json to bol11 and mention here that settings like additional supported features and transactions limits can be included.

I would suggest to move the entire json to bol11 and mention here that settings like additional supported features and transactions limits can be included.
thesimplekid (Migrated from github.com) reviewed 2025-05-10 16:06:18 +00:00
@ -218,23 +133,15 @@ The settings for this nut indicate the supported method-unit pairs for minting a
"unit": <str>,
"min_amount": <int|null>,
thesimplekid (Migrated from github.com) commented 2025-05-10 16:06:17 +00:00
options: <Object|null>

Thinking about this a bit more, I think its better if we define the minimum common settings (method, unit, min, max) and then have a generic object that can be defined by the specific method nut. This way for each new method we add it to the nut04 list of settings and not create a nut23 setting (nut23 using the current suggested number for bolt11).

```suggestion options: <Object|null> ``` Thinking about this a bit more, I think its better if we define the minimum common settings (method, unit, min, max) and then have a generic object that can be defined by the specific method nut. This way for each new method we add it to the nut04 list of settings and not create a nut23 setting (nut23 using the current suggested number for bolt11).
davidcaseria (Migrated from github.com) reviewed 2025-05-12 12:56:50 +00:00
@ -97,3 +74,3 @@
Like before, the mint `Bob` responds with a `PostMeltQuoteBolt11Response`.
The mint responds with the same structure as the initial quote response.
davidcaseria (Migrated from github.com) commented 2025-05-12 12:56:50 +00:00

@thesimplekid how is bolt12 handled?

@thesimplekid how is bolt12 handled?
davidcaseria (Migrated from github.com) reviewed 2025-05-12 13:05:56 +00:00
@ -106,3 +79,1 @@
# Melting tokens
Now that `Alice` knows what the total amount is (`amount + fee + fee_reserve`) in her requested `unit`, she can proceed for melting tokens for which a payment will be executed by the mint. She calls the `POST /v1/melt/{method}` endpoint where `method` is the payment method requested (here `bolt11`).
To execute the melting process, the wallet calls the `POST /v1/melt/{method}` endpoint.
davidcaseria (Migrated from github.com) commented 2025-05-12 13:05:56 +00:00

I lean towards keeping it because I think the expectation will be that the melting involves fees, which means a melt quote will be sensitive to fee changes over time.

I lean towards keeping it because I think the expectation will be that the melting involves fees, which means a melt quote will be sensitive to fee changes over time.
thesimplekid (Migrated from github.com) reviewed 2025-05-12 14:41:45 +00:00
@ -97,3 +74,3 @@
Like before, the mint `Bob` responds with a `PostMeltQuoteBolt11Response`.
The mint responds with the same structure as the initial quote response.
thesimplekid (Migrated from github.com) commented 2025-05-12 14:41:45 +00:00

For BOLT12 we use the state for melting its used the same as bolt11. I think it makes sense to keep at the very least all payment methods will use unpaid (they haven't starting paying the request) and paid (the payment is complete) and I think most will use pending (payment in flight) at least for some period of time or can skip from unpaid to paid if they really dont need it.

For BOLT12 we use the state for melting its used the same as bolt11. I think it makes sense to keep at the very least all payment methods will use unpaid (they haven't starting paying the request) and paid (the payment is complete) and I think most will use pending (payment in flight) at least for some period of time or can skip from unpaid to paid if they really dont need it.
thesimplekid (Migrated from github.com) reviewed 2025-05-12 14:44:34 +00:00
@ -106,3 +79,1 @@
# Melting tokens
Now that `Alice` knows what the total amount is (`amount + fee + fee_reserve`) in her requested `unit`, she can proceed for melting tokens for which a payment will be executed by the mint. She calls the `POST /v1/melt/{method}` endpoint where `method` is the payment method requested (here `bolt11`).
To execute the melting process, the wallet calls the `POST /v1/melt/{method}` endpoint.
thesimplekid (Migrated from github.com) commented 2025-05-12 14:44:33 +00:00

I agree with keeping it. Its not like minting where there is a request where we may not be able to stop someone paying into the mint. If someone attempts to use an expired melt quote an error is simply returned and we do not burn the ecash so there isn't a risk of unaccounted for or stuck funds.

I agree with keeping it. Its not like minting where there is a request where we may not be able to stop someone paying into the mint. If someone attempts to use an expired melt quote an error is simply returned and we do not burn the ecash so there isn't a risk of unaccounted for or stuck funds.
thesimplekid (Migrated from github.com) reviewed 2025-05-12 14:46:57 +00:00
@ -210,3 +125,3 @@
`MintMethodSetting` indicates supported `method` and `unit` pairs and additional settings of the mint. `disabled` indicates whether this minting is disabled.
`MintMethodSetting` indicates supported `method` and `unit` pairs and additional settings of the mint. `disabled` indicates whether minting is disabled.
thesimplekid (Migrated from github.com) commented 2025-05-12 14:46:57 +00:00

Since we have the options method specific settings should be added there not in the top level struct.

```suggestion ``` Since we have the options method specific settings should be added there not in the top level struct.
thesimplekid (Migrated from github.com) reviewed 2025-05-13 07:58:09 +00:00
thesimplekid (Migrated from github.com) left a comment

Just a few small things but otherwise LGTM

Just a few small things but otherwise LGTM
@ -4,3 +4,3 @@
`used in: NUT-20`
`used in: NUT-20, NUT-23`
thesimplekid (Migrated from github.com) commented 2025-05-13 07:51:01 +00:00
Minting tokens is a two-step process: requesting a mint quote and minting new tokens. This document describes the general flow that applies to all payment methods, with specifics for each supported payment method provided in dedicated NUTs.
```suggestion Minting tokens is a two-step process: requesting a mint quote and minting new tokens. This document describes the general flow that applies to all payment methods, with specifics for each supported payment method provided in dedicated NUTs. ```
@ -210,3 +125,3 @@
`MintMethodSetting` indicates supported `method` and `unit` pairs and additional settings of the mint. `disabled` indicates whether this minting is disabled.
`MintMethodSetting` indicates supported `method` and `unit` pairs and additional settings of the mint. `disabled` indicates whether minting is disabled.
thesimplekid (Migrated from github.com) commented 2025-05-13 07:56:06 +00:00
`min_amount` and `max_amount` indicate the minimum and maximum amount for an operation of this method-unit pair. `options` are method-specific and can be defined in method-specific NUTs.
```suggestion `min_amount` and `max_amount` indicate the minimum and maximum amount for an operation of this method-unit pair. `options` are method-specific and can be defined in method-specific NUTs. ```
thesimplekid (Migrated from github.com) commented 2025-05-13 07:54:38 +00:00
`min_amount` and `max_amount` indicate the minimum and maximum amount for an operation of this method-unit pair. `options` are method-specific and can be defined in method-specific NUTs.
```suggestion `min_amount` and `max_amount` indicate the minimum and maximum amount for an operation of this method-unit pair. `options` are method-specific and can be defined in method-specific NUTs. ```
thesimplekid (Migrated from github.com) commented 2025-05-13 07:54:45 +00:00
```suggestion ```
thesimplekid (Migrated from github.com) reviewed 2025-05-13 08:29:03 +00:00
thesimplekid commented 2025-05-13 14:02:19 +00:00 (Migrated from github.com)
PR for cdk https://github.com/cashubtc/cdk/pull/749
thesimplekid (Migrated from github.com) approved these changes 2025-05-16 08:44:10 +00:00
thesimplekid (Migrated from github.com) left a comment
ACK bd326c916408c0d922ed5ce0933690faf5b15986
thesimplekid (Migrated from github.com) reviewed 2025-05-20 12:33:36 +00:00
thesimplekid (Migrated from github.com) commented 2025-05-20 12:33:36 +00:00
[22]: 22.md
[23]: 23.md
```suggestion [22]: 22.md [23]: 23.md ```
thesimplekid (Migrated from github.com) approved these changes 2025-05-21 07:05:10 +00:00
thesimplekid (Migrated from github.com) left a comment
ACK f3a45b3eba8681663d8d855bd757a802609b1f6b
thesimplekid (Migrated from github.com) approved these changes 2025-05-31 20:40:28 +00:00
thesimplekid (Migrated from github.com) left a comment
ACK d7a623eeee49fb777cd38dfe98c6b6210afc7c65
Sign in to join this conversation.
No description provided.