Skip to content

feat: add mints_strict field to payment requests#2007

Open
d4rp4t wants to merge 6 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 6 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.

d4rp4t and others added 6 commits June 27, 2026 21:34
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 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".

.collect::<Result<Vec<_>, _>>()?;
let mint_info = wallet.load_mint_info().await?;

let mint_supports_method = mint_info

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor disabled flags when matching requested methods

When sm is present, this check treats a method entry as usable even if the mint has the corresponding NUT disabled flag set. NUT-04/NUT-05 define disabled as minting/melting being disabled, so an external mint that keeps bolt11 in methods while temporarily disabling that operation will still pass this predicate and can be selected despite not satisfying the request's method constraint; gate the method scans on !mint_info.nuts.nut04.disabled and !mint_info.nuts.nut05.disabled.

Useful? React with 👍 / 👎.

Comment on lines +466 to +467
if !wallet_supports_payment_request_methods(&wallet, &payment_request, &unit)
.await?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip failed method probes during wallet selection

When paying an sm request without an explicit mint_url, this await? runs while iterating candidate wallets, so any stale/offline mint whose info cannot be loaded aborts the whole payment before later candidates are considered. This can make a payable request fail even when another wallet has enough balance and supports a requested method; treat this like the get_wallet lookup above by skipping that candidate and only failing after no usable wallet remains.

Useful? React with 👍 / 👎.

Comment on lines +377 to +380
/// Mint URLs accepted or preferred by the original payment request
pub mints: Vec<MintUrl>,
/// Whether the original request's mint list is preferred instead of strict
pub mint_preferred: Option<bool>,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Persist Nostr mint policy for deferred checks

These new policy fields are only carried through the live wait_for_nostr_payment path. The CLI also stores pending Nostr requests via NostrWaitInfoSerializable in create_request.rs and later processes them in check_requests.rs, but that serialized form still contains only the secret key, relays, and pubkey; after a restart, check_requests will receive a payment from any mint even for a strict m list. Include mints/mint_preferred in the stored pending request and apply the same filter there.

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.31646% with 157 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.80%. Comparing base (08fde41) to head (3ad8355).

Files with missing lines Patch % Lines
crates/cdk/src/wallet/payment_request.rs 27.09% 113 Missing ⚠️
crates/cashu/src/nuts/nut26/encoding.rs 82.56% 19 Missing ⚠️
crates/cdk-ffi/src/types/payment_request.rs 0.00% 15 Missing ⚠️
crates/cashu/src/nuts/nut18/payment_request.rs 72.97% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2007      +/-   ##
==========================================
- Coverage   71.88%   71.80%   -0.09%     
==========================================
  Files         356      356              
  Lines       74532    74837     +305     
==========================================
+ Hits        53574    53733     +159     
- Misses      20958    21104     +146     

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

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