Skip to content

fix(mint): return stored signatures on idempotent POST /mint retry - #1128

Open
Hardeezah wants to merge 1 commit into
cashubtc:mainfrom
Hardeezah:fix/mint-idempotent-retry
Open

fix(mint): return stored signatures on idempotent POST /mint retry#1128
Hardeezah wants to merge 1 commit into
cashubtc:mainfrom
Hardeezah:fix/mint-idempotent-retry

Conversation

@Hardeezah

Copy link
Copy Markdown
Contributor

When a wallet retries POST /mint with the same outputs after a connection drop, the mint now returns the previously stored signatures instead of raising OutputsAlreadySignedError. This prevents token loss when the connection is lost during the minting process.

  • Add get_blind_signatures_mint_id() and get_blinded_Bs_mint_id() to crud.py
  • Add idempotency block in ledger.mint() that checks quote state first
  • Verify B_ values match (not just output count) to prevent mismatched returns
  • Update test_mint_internal to expect success on retry
  • Add tests for idempotent retry and different-output rejection

Closes #257

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.77%. Comparing base (3282be2) to head (3c04c10).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1128      +/-   ##
==========================================
- Coverage   74.85%   74.77%   -0.08%     
==========================================
  Files         112      112              
  Lines       12589    12599      +10     
==========================================
- Hits         9423     9421       -2     
- Misses       3166     3178      +12     

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

When a wallet retries POST /mint with the same outputs after a connection
drop, the mint now returns the previously stored signatures instead of
raising an error. This prevents token loss when the connection is lost
during the minting process.

- Add get_blind_signatures_mint_id() and get_blinded_Bs_mint_id() to crud
- Add idempotency block in ledger.mint() that checks quote state first
- Verify B_ values match (not just output count) to prevent mismatched returns
- Update test_mint_internal to expect success on retry
- Add tests for idempotent retry and different-output rejection

Closes cashubtc#257
@Hardeezah
Hardeezah force-pushed the fix/mint-idempotent-retry branch from 4f9085c to 3c04c10 Compare August 20, 2026 11:28
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.

Mint should reissue tokens for a failed POST /mint request.

1 participant