feat: add preferred_mints to payment requests#1925
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1925 +/- ##
==========================================
+ Coverage 66.24% 66.37% +0.12%
==========================================
Files 330 330
Lines 58633 58900 +267
==========================================
+ Hits 38841 39092 +251
- Misses 19792 19808 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1366643 to
b59c2b7
Compare
lescuer97
left a comment
There was a problem hiding this comment.
LGTM. The errors in the CLI seem to be clippy and other errors not related to the code
|
Can you rebase instead of merge https://github.com/cashubtc/cdk/blob/main/DEVELOPMENT.md#keeping-your-branch-up-to-date please |
I usually rebase, but the update button under the PR was too tempting this time. |
d238cdd to
bbc1c74
Compare
8eae376 to
0250e4e
Compare
cdk-bot
left a comment
There was a problem hiding this comment.
Verified findings approved for disclosure:
- Duplicate
supported_methodsfields make the benchmark example fail to compile (high) - Thecashuexample/test target fails to compile because duplicate fields in a Rust struct literal are a hard error, blocking workspace all-target builds/tests/clippy. - NUT-26 encode path can emit requests that decode rejects (low) - The public NUT-26 encoder can successfully emit payment requests that the PR's own decoder rejects as invalid, breaking encode/decode round trips for directly constructed
PaymentRequestvalues with both mint lists populated.
Unanchored locations included in summary:- crates/cashu/src/nuts/nut18/payment_request.rs:72
| single_use: None, | ||
| mints: vec![MintUrl::from_str("https://mint.example.com").unwrap()], | ||
| preferred_mints: vec![], | ||
| supported_methods: vec![], |
There was a problem hiding this comment.
This struct literal now specifies supported_methods three times. Rust treats duplicate fields in a struct initializer as a hard compile error (E0062), so the cashu example/test target will not build. Could you remove the two extra supported_methods: vec![], entries and leave just one?
| writer.write_tlv(0x08, &Self::encode_nut10(nut10)?); | ||
| } | ||
|
|
||
| // 0x09 preferred_mints: string (repeatable) |
There was a problem hiding this comment.
Should encode_tlv reject the same mints + preferred_mints combination that from_bech32_bytes rejects? Right now a caller can construct a public PaymentRequest with both vectors populated, to_bech32_string() succeeds and writes both tag 0x05 and 0x09, but the resulting request fails to decode with MutuallyExclusiveMints (the new test at the bottom demonstrates this by unwrapping the encode and then asserting decode fails). Since to_bech32_string() already returns Result, adding the same check before writing either mint list would prevent emitting an invalid CREQ-B request.
Summary
preferred_mintsto Cashu Payment Requests (NUT-18 and NUT-26)PaymentRequestandCreateRequestParamsstructs withpreferred_mintsacross core, wallet, CLI, and FFImintsandpreferred_mintsare mutually exclusive during creation and decodingpay_requestselection logic to prioritizepreferred_mintsover fallback mints if they have sufficient balance