Skip to content

refactor(mint): split monolithic ledger.py into ledger/ package#1032

Open
KvngMikey wants to merge 3 commits into
cashubtc:mainfrom
KvngMikey:ledger_refactor
Open

refactor(mint): split monolithic ledger.py into ledger/ package#1032
KvngMikey wants to merge 3 commits into
cashubtc:mainfrom
KvngMikey:ledger_refactor

Conversation

@KvngMikey

Copy link
Copy Markdown
Contributor

Fixes #865

Summary

Extracts the monolithic 1413-line cashu/mint/ledger.py into a package with focused mixin classes, making the code easier to navigate and understand. Each mixin inherits from the mixin that provides the methods it calls, this way all existing imports continue to work unchanged.

Changes

  • cashu/mint/ledger.py has been replaced with a cashu/mint/ledger/ package containing focused submodules.
  • ledger/__init__.py barrel exports from .ledger import Ledger.
  • No logic was changed. Existing test suite passes without modification.

Copilot AI review requested due to automatic review settings June 1, 2026 09:58
@github-project-automation github-project-automation Bot moved this to Backlog in nutshell Jun 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Refactors the mint ledger implementation from a single large module into a structured package, separating mint/melt/swap and blind-signature logic while adding protocol typing for watchdog functionality.

Changes:

  • Split cashu/mint/ledger.py into multiple modules under cashu/mint/ledger/ (mint, melt, swap, blind_signatures, ledger).
  • Introduced SupportsWatchdog protocol to type the watchdog balance/fee API used during mint quoting.
  • Added cashu.mint.ledger package export via __init__.py.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
cashu/mint/protocols.py Adds SupportsWatchdog protocol and supporting imports for typed watchdog integration.
cashu/mint/ledger/ledger.py New composed Ledger class wiring together split ledger mixins and startup/shutdown routines.
cashu/mint/ledger/blind_signatures.py Extracts blind signature storage/signing + fee-change promise generation.
cashu/mint/ledger/mint.py Extracts mint quote, mint, and batch mint flows into a dedicated mixin.
cashu/mint/ledger/melt.py Extracts melt quoting and payment execution logic into a dedicated mixin.
cashu/mint/ledger/swap.py Extracts swap + restore logic into a dedicated mixin.
cashu/mint/ledger/init.py Exposes the new package-level Ledger import.
cashu/mint/ledger.py Removes the previous monolithic ledger module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cashu/mint/ledger/blind_signatures.py
Comment thread cashu/mint/ledger/blind_signatures.py
Comment thread cashu/mint/ledger/blind_signatures.py
Comment thread cashu/mint/ledger/swap.py
Comment thread cashu/mint/ledger/mint.py
Comment thread cashu/mint/ledger/melt.py Outdated
Comment thread cashu/mint/ledger/melt.py
Comment thread cashu/mint/ledger/ledger.py
Comment thread cashu/mint/ledger/swap.py Outdated
@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.80620% with 98 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.23%. Comparing base (2376e47) to head (a62789b).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
cashu/mint/ledger/melt.py 82.64% 42 Missing ⚠️
cashu/mint/ledger/mint.py 79.88% 35 Missing ⚠️
cashu/mint/ledger/ledger.py 92.66% 8 Missing ⚠️
cashu/mint/ledger/blind_signatures.py 90.00% 7 Missing ⚠️
cashu/mint/ledger/swap.py 85.36% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1032      +/-   ##
==========================================
+ Coverage   75.04%   75.23%   +0.19%     
==========================================
  Files         111      116       +5     
  Lines       12244    12288      +44     
==========================================
+ Hits         9188     9245      +57     
+ Misses       3056     3043      -13     

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

@ye0man ye0man moved this from Backlog to Needs Review in nutshell Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

Split ledger.py into more modules

3 participants