Skip to content

feat: add mints_strict field to payment requests - #2007

Merged
thesimplekid merged 9 commits into
cashubtc:mainfrom
d4rp4t:feat/nut18-nut28-mint-strict-flag
Jul 21, 2026
Merged

feat: add mints_strict field to payment requests#2007
thesimplekid merged 9 commits into
cashubtc:mainfrom
d4rp4t:feat/nut18-nut28-mint-strict-flag

Conversation

@d4rp4t

@d4rp4t d4rp4t commented May 26, 2026

Copy link
Copy Markdown
Contributor

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
Contributor 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 76.34069% with 150 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.05%. Comparing base (7be1e2e) to head (ca341b9).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
crates/cdk/src/wallet/payment_request.rs 66.25% 109 Missing ⚠️
crates/cdk-ffi/src/types/payment_request.rs 23.68% 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.98%   74.05%   +0.06%     
==========================================
  Files         362      362              
  Lines       83619    84240     +621     
==========================================
+ Hits        61866    62383     +517     
- Misses      21753    21857     +104     

☔ 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.

@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

@thesimplekid
thesimplekid force-pushed the feat/nut18-nut28-mint-strict-flag branch from b5a5eb4 to ee3e33d Compare July 8, 2026 14:53
@robwoodgate

Copy link
Copy Markdown
Contributor

Noted by my agent when checking compliance to current spec:

Melt check already binds to the request unit.

  • Swap unwrap_or(CurrencyUnit::Sat) in Wallet::pay_request (and the repository path) for a reject when unit is None and sm is present. Whether they keep the sat default for legacy unit-less requests without sm is their call; the spec only invalidates the a/sm cases.
  • Optionally have PaymentRequestBuilder::build() error on supported_methods (or amount) with unit: None so invalid requests can't be minted in the first place.

@thesimplekid
thesimplekid force-pushed the feat/nut18-nut28-mint-strict-flag branch from ee3e33d to ac634fb Compare July 17, 2026 14:49
@thesimplekid
thesimplekid force-pushed the feat/nut18-nut28-mint-strict-flag branch 3 times, most recently from ee66fee to 3337b1e Compare July 21, 2026 17:28
d4rp4t and others added 7 commits July 21, 2026 18:29
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.
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 3337b1e to b8be4a0 Compare July 21, 2026 17:30
thesimplekid and others added 2 commits July 21, 2026 18:30
Ports the request-creation plumbing from cashubtc#1925.

Co-authored-by: a1denvalu3 <43107113+a1denvalu3@users.noreply.github.com>
@thesimplekid
thesimplekid force-pushed the feat/nut18-nut28-mint-strict-flag branch from b8be4a0 to ca341b9 Compare July 21, 2026 17:30
@thesimplekid
thesimplekid merged commit ca341b9 into cashubtc:main Jul 21, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in CDK Jul 21, 2026
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.

3 participants