$ show spesmilo/electrum
Electrum is a mature, production-grade Bitcoin wallet with full Lightning Network support, used by thousands of users daily. It is a desktop/mobile application with a daemon architecture, offering three GUI frontends: a full-featured PyQt6 desktop interface, a Qt Quick (QML) mobile interface, and a curses terminal interface. The daemon manages wallet lifecycle, network connections, and exposes a JSON-RPC API. The codebase is highly modular, with a plugin system for hardware wallets (Trezor, Ledger, Coldcard, KeepKey, Jade, BitBox02, Safe-T, Digital Bitbox), label sync, two-factor authentication, submarine swaps, watchtowers, and more. Core features include SPV (Simple Payment Verification) with merkle proof validation, coin selection with privacy-aware heuristics (CoinChooserPrivacy), BIP32 key derivation, mnemonic seeds (BIP39, SLIP39, legacy), and a full Lightning Network implementation with pathfinding (LNPathFinder using Dijkstra with liquidity hints), channel management, HTLC accounting, trampoline routing, and onion messages. The repository also includes deterministic build scripts for Linux (AppImage), Windows (Wine+PyInstaller), macOS, and Android (python-for-android), with reproducible builds using pinned dependencies and hash verification.
The LLM identified 3 files worth highlighting for reuse:
MemoryZipImporter provides a secure mechanism to load Python modules from in-memory zip archives. It uses the importlib machinery to find and load modules without writing to disk, preventing file race conditions and tampering. This is reusable for any application that needs to securely load third-party plugins or code from signed archives.
JsonDB is a thread-safe JSON database that stores data as in-memory dicts and persists changes via JSON patch accumulation. It supports crash recovery by replaying patches after loading the base snapshot. The consolidation logic batches many small patches into a full dump to keep file sizes manageable. This pattern is reusable for any application needing simple, reliable JSON-based storage with thread safety.
StoredDict, StoredList, and StoredObject are dict/list/dataclass subclasses that automatically record mutations and trigger persistence through a callback. They work with JsonDB to provide transparent persistence: any change to the data structure is automatically saved. This pattern is reusable for any application that wants in-memory data structures that are automatically persisted to disk without manual save calls.