Skip to content

feat(mint): enforce NUT 11014/11015 max inputs and outputs#965

Open
b-l-u-e wants to merge 1 commit into
cashubtc:mainfrom
b-l-u-e:feat/nut-11014/11015-max-inputs-max-outputs-limits
Open

feat(mint): enforce NUT 11014/11015 max inputs and outputs#965
b-l-u-e wants to merge 1 commit into
cashubtc:mainfrom
b-l-u-e:feat/nut-11014/11015-max-inputs-max-outputs-limits

Conversation

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

@b-l-u-e b-l-u-e commented Mar 31, 2026

This PR adds Cashu/NUT-aligned errors 11014 (Max inputs exceeded) and 11015 (Max outputs exceeded), configurable via MINT_MAX_INPUTS and MINT_MAX_OUTPUTS (defaults: 1000).

  • Defines TransactionMaxInputsExceededError and TransactionMaxOutputsExceededError in cashu/core/errors.py.
  • Enforces limits in verify_inputs_and_outputs and _verify_outputs, and on restore().
  • Aligns Pydantic request models so proof/input lists use the inputs cap and blinded output lists use the outputs cap.

Tests cover both error paths in tests/mint/test_mint_verification.py.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.98%. Comparing base (85c959e) to head (c4ccb4f).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #965      +/-   ##
==========================================
+ Coverage   74.92%   74.98%   +0.06%     
==========================================
  Files         111      111              
  Lines       12065    12078      +13     
==========================================
+ Hits         9040     9057      +17     
+ Misses       3025     3021       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@b-l-u-e b-l-u-e force-pushed the feat/nut-11014/11015-max-inputs-max-outputs-limits branch from f27814f to e41618e Compare March 31, 2026 12:03
Comment thread cashu/mint/ledger.py Outdated
Comment thread cashu/mint/ledger.py Outdated
Comment thread cashu/mint/ledger.py Outdated
@a1denvalu3
Copy link
Copy Markdown
Collaborator

The PR implements NUT-14 and NUT-15 limits on the maximum number of inputs and outputs by checking lengths and raising newly defined TransactionMaxInputsExceededError (11014) and TransactionMaxOutputsExceededError (11015). However, the PR also adds max_length validators to the Pydantic models for these endpoints. As a result, requests exceeding these limits are intercepted by FastAPI's Pydantic validation before reaching the route handlers, returning a generic HTTP 422 Unprocessable Entity error instead of the protocol-specified Cashu 11014/11015 errors.

@b-l-u-e b-l-u-e force-pushed the feat/nut-11014/11015-max-inputs-max-outputs-limits branch from e41618e to c4ccb4f Compare May 21, 2026 19:44
@b-l-u-e
Copy link
Copy Markdown
Contributor Author

b-l-u-e commented May 21, 2026

The PR implements NUT-14 and NUT-15 limits on the maximum number of inputs and outputs by checking lengths and raising newly defined TransactionMaxInputsExceededError (11014) and TransactionMaxOutputsExceededError (11015). However, the PR also adds max_length validators to the Pydantic models for these endpoints. As a result, requests exceeding these limits are intercepted by FastAPI's Pydantic validation before reaching the route handlers, returning a generic HTTP 422 Unprocessable Entity error instead of the protocol-specified Cashu 11014/11015 errors.

made changes limits enforced in ledger, list max_length removed from models so clients get 11014/11015 instead of 422.

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.

3 participants