Skip to content

feat: support NUT-26 Bech32m-Encoded Payment Requests#904

Open
KvngMikey wants to merge 5 commits intocashubtc:mainfrom
KvngMikey:bech32m_encoded_payments
Open

feat: support NUT-26 Bech32m-Encoded Payment Requests#904
KvngMikey wants to merge 5 commits intocashubtc:mainfrom
KvngMikey:bech32m_encoded_payments

Conversation

@KvngMikey
Copy link
Copy Markdown
Contributor

@KvngMikey KvngMikey commented Feb 24, 2026

Fixes #857

Implements NUT-26 (Bech32m + TLV) encoding for payment requests as an alternative to the CBOR+base64 format (NUT-18).

  • Bech32m encode/decode, TLV serialization, transport encoding (nostr + http_post), NUT-10 spending conditions, tag tuples
  • deserialize() auto-detects creqb1 (NUT-26) vs creqA (NUT-18) and dispatches accordingly; added serialize_bech32m() method, case-insensitive prefix detection for both formats
  • pay and decode commands accept both creqA and creqb1 prefixes
  • Backward compatible as existing creqA serialization is untouched
  • No new dependencies, reuses the existing bech32 package primitives with the Bech32m checksum constant (0x2BC830A3)

@github-project-automation github-project-automation bot moved this to Backlog in nutshell Feb 24, 2026
@KvngMikey KvngMikey marked this pull request as draft February 24, 2026 11:49
@ye0man ye0man added this to the 0.20.0 milestone Mar 10, 2026
@KvngMikey KvngMikey marked this pull request as ready for review March 13, 2026 09:26
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 59.42029% with 112 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.76%. Comparing base (89564fe) to head (5cf58d1).
⚠️ Report is 70 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
cashu/core/nuts/nut26.py 53.52% 112 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Comment thread cashu/core/nuts/nut18.py Outdated
Comment thread cashu/mint/management_rpc/protos/googleapis Outdated
@KvngMikey KvngMikey force-pushed the bech32m_encoded_payments branch from 7a5a9da to 588081a Compare March 22, 2026 10:18
@b-l-u-e
Copy link
Copy Markdown
Contributor

b-l-u-e commented Mar 22, 2026

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
@KvngMikey KvngMikey force-pushed the bech32m_encoded_payments branch from 78bd2a9 to ea3b2cc Compare March 23, 2026 08:36
@KvngMikey
Copy link
Copy Markdown
Contributor Author

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

@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
@KvngMikey KvngMikey force-pushed the bech32m_encoded_payments branch from ea3b2cc to cfbfe8f Compare March 23, 2026 08:42
@b-l-u-e
Copy link
Copy Markdown
Contributor

b-l-u-e commented Mar 24, 2026

@b-l-u-e , perfect, this has been done now.

looks cleaner thanks

@b-l-u-e
Copy link
Copy Markdown
Contributor

b-l-u-e commented Mar 24, 2026

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

@KvngMikey
Copy link
Copy Markdown
Contributor Author

KvngMikey commented Mar 24, 2026

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.

@callebtc
Copy link
Copy Markdown
Collaborator

pls move the model definition into the centralized models file where all BaseModels are defined

Copilot AI review requested due to automatic review settings March 31, 2026 10:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.py with 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.

Comment thread cashu/core/nuts/nut18.py
Comment thread cashu/wallet/cli/cli.py
Comment thread cashu/wallet/cli/cli.py
Comment thread cashu/core/nuts/nut26.py
Comment thread cashu/core/nuts/nut26.py
Comment thread cashu/core/nuts/nut26.py
Comment thread cashu/core/nuts/nut26.py Outdated
Comment thread cashu/core/nuts/nut26.py
Comment thread cashu/core/nuts/nut26.py Outdated
Comment thread cashu/core/nuts/nut26.py
@KvngMikey KvngMikey changed the title Support NUT-26 Bech32m-Encoded Payment Requests feat: support NUT-26 Bech32m-Encoded Payment Requests Apr 11, 2026
a1denvalu3 pushed a commit that referenced this pull request Apr 14, 2026
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.

Support & Validate Bech32m-Encoded Payment Requests

6 participants