-
Notifications
You must be signed in to change notification settings - Fork 75
Add NUT-XX for batched minting #273
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
41dc819
docs: Add NUT-XX for batched minting
Egge21M 00d0c08
docs: added nut-20 support to xx.md
Egge21M f71defc
docs: clarified uniqueness
Egge21M 648ad0c
Apply suggestion from @vnprc
thesimplekid ba4543f
Apply suggestions from code review
thesimplekid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| # NUT-XX: Batched Mint | ||
|
|
||
| `optional` | ||
|
|
||
| `depends on: NUT-04` | ||
|
|
||
| This spec describes how a wallet can mint multiple quotes in one batch operation. | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Checking Quote Status | ||
|
|
||
| Before minting, the wallet must verify that each mint quote has been paid. | ||
| It does this by sending: | ||
|
|
||
| ```http | ||
| POST https://mint.host:3338/v1/mint/{method}/check | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "quotes": [ "quote_id_1", "quote_id_2", … ] | ||
| } | ||
| ``` | ||
|
|
||
| - **quote**: an array of **unique** quote IDs previously obtained via the [NUT-04 creation process][04-creation]. | ||
|
|
||
| The mint returns a JSON array of quote objects, each containing: | ||
|
|
||
| ```json | ||
| [ | ||
| { | ||
| "quote": "quote_id_1", | ||
| "request": "payment_request_1", | ||
| "unit": "UNIT_NAME" | ||
| // …plus any additional fields specific to {method} | ||
| }, | ||
| { | ||
| "quote": "quote_id_2", | ||
| "request": "payment_request_2", | ||
| "unit": "UNIT_NAME" | ||
| // … | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| - **quote**: the original quote ID | ||
| - **request**: the payment request string for that quote | ||
| - **unit**: the unit type, matching what was requested | ||
|
|
||
| NOTE: If a `quote_id` is not known by the mint it SHOULD omit it from the response. | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Executing the Batched Mint | ||
|
|
||
| Once all quoted payments are confirmed, the wallet mints the tokens by calling: | ||
|
|
||
| ```http | ||
| POST https://mint.host:3338/v1/mint/{method} | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "quotes": [ "quote_id_1", "quote_id_2", … ], | ||
| "outputs": [ BlindedMessage_1, BlindedMessage_2, … ], | ||
| "signature": [signature_1, signature_2, ... ] | ||
| } | ||
| ``` | ||
|
|
||
| - **quote**: an array of **unique** quote IDs previously obtained via the [NUT-04 creation process][04-creation]. | ||
| - **outputs**: an array of blinded messages (see [NUT-00][00]). | ||
| - The total value represented by these blinded messages must equal the sum of the quote amounts. | ||
| - **signature**: The signature for a NUT-20 locked quote. See [NUT-20 Support][nut-20-support] | ||
| The mint responds with: | ||
|
|
||
| ```json | ||
| { | ||
| "signatures": [ BlindSignature_1, BlindSignature_2, … ] | ||
| } | ||
| ``` | ||
|
|
||
| - **signatures**: blind signatures corresponding to each provided blinded message. | ||
|
|
||
| ## NUT-20 support | ||
|
|
||
| The `signature` field of the request can be used to add matching NUT-20 signatures to a batch mint. Signatures can be mapped to their quotes using both indexes in the request body. As long as there is a single NUT-20 quote in the request this field is mandatory, otherwise it can be fully omitted. | ||
|
|
||
| - Signatures for NUT-20 quotes can be added to the `signature` key of the request. | ||
| - Signatures need to be in the same index as the matching quote_id in the `quote` key. | ||
| - If a request contains both signed and unsigned quotes, all unsigned quotes need to map to `null` in the `signature` array. | ||
| - As soon as there is a single signed quote in the request: `quote.length === signature.length` | ||
|
|
||
| Example: | ||
|
|
||
| ```json | ||
| { | ||
| "quotes": [ "locked_quote_id_1", "quote_id_2", "locked_quote_id_3" ], | ||
| "outputs": [ BlindedMessage_1, BlindedMessage_2, ... ], | ||
| "signature": [signature_1, null, signature_3 ] | ||
| } | ||
| ``` | ||
|
|
||
| [00]: 00.md | ||
| [04-creation]: 04.md#requesting-a-mint-quote | ||
| [nut-20-support]: #nut-20-support | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the behavior if one of the quote IDs is not found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the best would be to simply omit it from the response. That way the client could handle that case and still use the available data without resending the request