Skip to content

feat: add mints_strict field to payment requests#2007

Open
d4rp4t wants to merge 7 commits into
cashubtc:mainfrom
d4rp4t:feat/nut18-nut28-mint-strict-flag
Open

feat: add mints_strict field to payment requests#2007
d4rp4t wants to merge 7 commits into
cashubtc:mainfrom
d4rp4t:feat/nut18-nut28-mint-strict-flag

Conversation

@d4rp4t

@d4rp4t d4rp4t commented May 26, 2026

Copy link
Copy Markdown

Description

Adds mints_strict (ms) field to PaymentRequest as specified in NUT-18 and NUT-26 PR: cashubtc/nuts#381

When ms is absent or true (default), the recipient MUST reject payments from mints not in the mint list. When ms is false, the mint list is a suggestion for the payer.

NUT-26 (bech32m) encoding adds TLV tag 0x09 for this field.

Notes to the reviewers

The field is serialized with skip_serializing_if = "Option::is_none" so existing encoded payment requests remain valid — absence of the tag is equivalent to true (strict mode), consistent with the proposed spec default.


Suggested CHANGELOG Updates

CHANGED

ADDED

  • mints_strict field (ms) to PaymentRequest (NUT-18) with corresponding TLV tag 0x09 in NUT-26 bech32m encoding
  • mints_strict() builder method on PaymentRequestBuilder

Checklist

  • I followed the code style guidelines
  • [] I ran just quick-check before committing
  • If the Wallet API was modified (added/removed/changed), I have reflected those changes in the FFI bindings (crates/cdk-ffi)

@github-project-automation github-project-automation Bot moved this to Backlog in CDK May 26, 2026
@d4rp4t d4rp4t mentioned this pull request May 26, 2026
3 tasks
@d4rp4t d4rp4t force-pushed the feat/nut18-nut28-mint-strict-flag branch from 085b13c to da6ce50 Compare June 14, 2026 22:05
@d4rp4t

d4rp4t commented Jun 14, 2026

Copy link
Copy Markdown
Author

Added changes so it matches: cashubtc/nuts#381

@thesimplekid

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da6ce50884

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cashu/src/nuts/nut18/payment_request.rs Outdated
Comment thread crates/cashu/src/nuts/nut18/payment_request.rs Outdated
Comment thread crates/cashu/src/nuts/nut18/payment_request.rs Outdated
Comment thread crates/cdk/src/wallet/payment_request.rs Outdated
Comment thread crates/cashu/src/nuts/nut26/encoding.rs Outdated
Comment thread fuzz/src/arbitrary_ext.rs Outdated
@robwoodgate

Copy link
Copy Markdown
Contributor

The nut has been updated: ms (mint_strict) is now flipped to mp (mint_preferred) to avoid the omitted=true antipattern.

@thesimplekid thesimplekid force-pushed the feat/nut18-nut28-mint-strict-flag branch from da6ce50 to 3ad8355 Compare June 27, 2026 21:31
@thesimplekid

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ad8355fec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cdk/src/wallet/payment_request.rs Outdated
Comment thread crates/cdk/src/wallet/payment_request.rs Outdated
Comment thread crates/cdk/src/wallet/payment_request.rs
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.22097% with 143 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.11%. Comparing base (c6957ac) to head (ee3e33d).

Files with missing lines Patch % Lines
crates/cdk/src/wallet/payment_request.rs 56.03% 102 Missing ⚠️
crates/cdk-ffi/src/types/payment_request.rs 0.00% 29 Missing ⚠️
crates/cashu/src/nuts/nut26/encoding.rs 94.16% 8 Missing ⚠️
crates/cashu/src/nuts/nut18/payment_request.rs 96.94% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2007      +/-   ##
==========================================
- Coverage   73.11%   73.11%   -0.01%     
==========================================
  Files         359      359              
  Lines       79639    80161     +522     
==========================================
+ Hits        58232    58609     +377     
- Misses      21407    21552     +145     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

d4rp4t and others added 6 commits July 8, 2026 15:04
Add the strict mint flag, fee reserve, and supported payment methods to
the NUT-18 payment request model and builder.

Encode the new fields in NUT-26 TLV records and expose them through the
wallet defaults, FFI wrapper, fuzz generator, and encoding benchmark.
Use the updated mp field and preferred-polarity naming for NUT-18
payment requests. Enforce strict mint lists, add fee reserve when using
unlisted preferred mints, and document the field semantics.
@thesimplekid thesimplekid force-pushed the feat/nut18-nut28-mint-strict-flag branch from 3ad8355 to b5a5eb4 Compare July 8, 2026 14:29
@thesimplekid

Copy link
Copy Markdown
Collaborator

@cdk-bot review

Replace the flat fee reserve with `sm` method objects carrying optional
`mf` values, and encode them as NUT-26 supported-method sub-TLVs on tag
0x0a.

Apply method fees when paying from an unlisted mint, or from any mint
when the request has no mint list. Select the lowest fee among matching
NUT-05 melt methods and keep requested amounts net of input fees.

Cover the current NUT-18 and NUT-26 spec vectors, including the
preferred-method-fee cases. Accept the standard-base64 NUT-18 vectors
published by the spec while continuing to emit urlsafe CREQ-A strings.
@thesimplekid thesimplekid force-pushed the feat/nut18-nut28-mint-strict-flag branch from b5a5eb4 to ee3e33d Compare July 8, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants