feat: add mints_strict field to payment requests#2007
Conversation
085b13c to
da6ce50
Compare
|
Added changes so it matches: cashubtc/nuts#381 |
|
@codex review |
There was a problem hiding this comment.
💡 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".
|
The nut has been updated: |
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.
da6ce50 to
3ad8355
Compare
|
@codex review |
There was a problem hiding this comment.
💡 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 |
There was a problem hiding this comment.
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 👍 / 👎.
| if !wallet_supports_payment_request_methods(&wallet, &payment_request, &unit) | ||
| .await? |
There was a problem hiding this comment.
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 👍 / 👎.
| /// 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>, |
There was a problem hiding this comment.
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 Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
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
Checklist
just quick-checkbefore committingcrates/cdk-ffi)