feat: support NUT-26 Bech32m-Encoded Payment Requests#904
feat: support NUT-26 Bech32m-Encoded Payment Requests#904KvngMikey wants to merge 5 commits intocashubtc:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #904 +/- ##
===========================================
+ Coverage 61.51% 74.76% +13.25%
===========================================
Files 93 100 +7
Lines 11051 11950 +899
===========================================
+ Hits 6798 8935 +2137
+ Misses 4253 3015 -1238 ☔ View full report in Codecov by Sentry. |
7a5a9da to
588081a
Compare
|
Thanks for the PR but the commit history is pretty noisy ruff/CI fixes, merge commits, small follow-ups which makes the timeline harder to scan. Could you squash or reorganize into a few logical commits for example one for the feature, one for tests.. |
- implement bech32m encoding and decoding - integrate with NUT18 transport layer - add support for serialized payment requests - fix linting and minor issues
- add CLI tests for NUT-26 - extend existing test suite
78bd2a9 to
ea3b2cc
Compare
@b-l-u-e , perfect, this has been done now. |
- restructure imports to avoid circular dependencies - move imports out of functions where necessary - clean up module organization
ea3b2cc to
cfbfe8f
Compare
looks cleaner thanks |
|
based on issue #857 it mentions mint compatibility wherever payment-request data is parsed or persisted. I couldn’t find creq*, nut18,or nut26 references under cashu/mint unless im doing it the wrong way |
The mint doesn't parse or persist payment request strings, payment requests are a wallet-to-wallet concept, the issue has been updated to reflect this. |
|
pls move the model definition into the centralized models file where all BaseModels are defined |
There was a problem hiding this comment.
Pull request overview
Implements NUT-26 Bech32m+TLV encoding/decoding for payment requests, adds auto-detection in NUT-18 deserialize(), and updates the wallet CLI + tests to accept both NUT-18 (creqA) and NUT-26 (creqb1) formats.
Changes:
- Added
cashu/core/nuts/nut26.pywith Bech32m primitives, TLV serialization, and PaymentRequest encode/decode. - Updated NUT-18 helpers and wallet CLI to decode either NUT-18 or NUT-26 payment requests.
- Added/updated wallet and CLI tests to cover NUT-26 vectors, round-trips, and validation cases.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
cashu/core/nuts/nut26.py |
New NUT-26 Bech32m+TLV codec implementation (including transport + NUT-10 encoding). |
cashu/core/nuts/nut18.py |
Refactors NUT-18 into serialize()/deserialize() functions and dispatches to NUT-26 on creqb1. |
cashu/core/base.py |
Moves PaymentRequest/Transport/NUT10Option models into shared core base module. |
cashu/wallet/cli/cli.py |
Extends pay/decode command handling to accept NUT-26 payment request strings. |
tests/wallet/test_wallet_payment_request.py |
Adds extensive NUT-26 serialization/deserialization/validation tests and updates NUT-18 tests to use new helpers. |
tests/wallet/test_cli_nut26.py |
New CLI-level tests for decode/pay using NUT-26 requests. |
tests/wallet/test_cli_nut18.py |
Updates CLI tests to use nut18.serialize() instead of PaymentRequest.serialize(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #857
Implements NUT-26
(Bech32m + TLV)encoding for payment requests as an alternative to theCBOR+base64format (NUT-18).deserialize()auto-detectscreqb1 (NUT-26)vscreqA (NUT-18)and dispatches accordingly; addedserialize_bech32m()method, case-insensitive prefix detection for both formatspayanddecodecommands accept both creqA and creqb1 prefixescreqAserialization is untouchedbech32package primitives with theBech32m checksum constant (0x2BC830A3)