Skip to content

feat: mint strict flag#37

Open
d4rp4t wants to merge 5 commits into
Kukks:masterfrom
d4rp4t:feat/preferred-mints
Open

feat: mint strict flag#37
d4rp4t wants to merge 5 commits into
Kukks:masterfrom
d4rp4t:feat/preferred-mints

Conversation

@d4rp4t

@d4rp4t d4rp4t commented May 26, 2026

Copy link
Copy Markdown
Collaborator

cashubtc/nuts#380

Summary by CodeRabbit

  • New Features
    • Added an optional MintsStrict field to payment requests for stricter mints-related behavior.
    • Updated CBOR and Bech32 handling to include MintsStrict during encoding/decoding.
  • Bug Fixes
    • Improved parsing validation for MintsStrict, rejecting improperly formatted values.
  • Tests
    • Added new NUT-18 parsing test coverage for preferred fee methods, including MintsStrict, FeeReserve, and SupportedMethods.

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@d4rp4t, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 43 minutes and 41 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 61b39374-444c-4a14-83bf-aaab965d9a1a

📥 Commits

Reviewing files that changed from the base of the PR and between cbb28cd and 3f8d4c8.

📒 Files selected for processing (1)
  • DotNut.Tests/Unit/Nut18Tests.cs
📝 Walkthrough

Walkthrough

The PR adds a nullable MintsStrict boolean property to the PaymentRequest class and implements serialization support across two formats: Bech32 encoding using TLV tag 0x09 with single-byte boolean values, and CBOR encoding using map key "ms". Test coverage validates both encoding schemes against hardcoded vectors.

Changes

MintsStrict Payment Request Support

Layer / File(s) Summary
MintsStrict property contract
DotNut/NUT18/PaymentRequest.cs
PaymentRequest adds a new nullable bool property MintsStrict to enable callers to specify mints-related behavior.
Bech32 TLV encoding for MintsStrict
DotNut/Encoding/PaymentRequestBech32Encoder.cs
TLV tag enum includes new MintsStrict enum value (0x09). EncodeTLV conditionally writes a single-byte boolean (0x01 for true, 0x00 for false). DecodeTLV recognizes tag 0x09 with strict validation (exactly one byte, only 0x00 or 0x01 accepted) and introduces a supportedMethods accumulator for collecting SupportedMethods TLVs.
CBOR encoding for MintsStrict
DotNut/Encoding/PaymentRequestEncoder.cs
ToCBORObject conditionally includes MintsStrict in the CBOR map under key "ms" when present. FromCBORObject parses CBOR key "ms" as a boolean and assigns it to paymentRequest.MintsStrict.
Test validation for MintsStrict in both formats
DotNut.Tests/Unit/Nut18Tests.cs
Two new test cases validate MintsStrict parsing from hardcoded CBOR and Bech32 vectors, verifying PaymentId, Amount, Unit, mints, MintsStrict, FeeReserve, and SupportedMethods fields. Previous ValidPr() test is removed.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly Related PRs

  • Kukks/DotNut#29: Extends the existing PaymentRequestBech32Encoder TLV schema with MintsStrict decoding/encoding and SupportedMethods handling, building on the same Bech32 payment-request encoding component.

Suggested Reviewers

  • Kukks

Poem

A property new, both swift and neat,
Through Bech32's tags and CBOR's beat,
MintsStrict now flows through every way,
Encoding mints with style today! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: mint strict flag' directly corresponds to the main change: adding a MintsStrict property across the payment request encoding/decoding system.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@DotNut/Encoding/PaymentRequestBech32Encoder.cs`:
- Around line 289-291: The code in the switch case 0x09 currently sets
pr.MintsStrict = value.Length == 1 && value[0] == 0x01 which silently coerces
any malformed TLV to false; instead validate the TLV in the case 0x09 branch and
reject/raise an error when the value is not exactly one byte equal to 0x00 or
0x01; if value[0] == 0x00 set pr.MintsStrict = false, if 0x01 set it true,
otherwise throw/return a decode error (or propagate an existing TLV format
exception) so invalid external payloads fail fast.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6d9dff93-bde4-4c72-bf9f-c2f52da6fda3

📥 Commits

Reviewing files that changed from the base of the PR and between d6b4d36 and e5328c2.

📒 Files selected for processing (3)
  • DotNut/Encoding/PaymentRequestBech32Encoder.cs
  • DotNut/Encoding/PaymentRequestEncoder.cs
  • DotNut/NUT18/PaymentRequest.cs

Comment thread DotNut/Encoding/PaymentRequestBech32Encoder.cs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@d4rp4t d4rp4t marked this pull request as draft May 26, 2026 17:51
@d4rp4t d4rp4t mentioned this pull request May 26, 2026
3 tasks
@d4rp4t

d4rp4t commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator Author

updated so it matches cashubtc/nuts#381

@d4rp4t d4rp4t marked this pull request as ready for review June 14, 2026 22:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@DotNut.Tests/Unit/Nut18Tests.cs`:
- Line 26: The comment in the Nut18Tests class contains a typo where it
references "NUT-26" but should reference "NUT-18" to be consistent with the test
class name and the PR objectives. Locate the comment that reads "Test vector
from NUT-26 PR `#381`" and correct "NUT-26" to "NUT-18".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8f3d36b0-64e7-40e9-bfef-9c1bb3977739

📥 Commits

Reviewing files that changed from the base of the PR and between e5328c2 and cbb28cd.

📒 Files selected for processing (4)
  • DotNut.Tests/Unit/Nut18Tests.cs
  • DotNut/Encoding/PaymentRequestBech32Encoder.cs
  • DotNut/Encoding/PaymentRequestEncoder.cs
  • DotNut/NUT18/PaymentRequest.cs
🚧 Files skipped from review as they are similar to previous changes (3)
  • DotNut/NUT18/PaymentRequest.cs
  • DotNut/Encoding/PaymentRequestEncoder.cs
  • DotNut/Encoding/PaymentRequestBech32Encoder.cs

Comment thread DotNut.Tests/Unit/Nut18Tests.cs Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant