This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Overview
Electrum is a lightweight Bitcoin wallet with full Lightning Network support. It communicates with Electrum servers (not full nodes) via the Electrum protocol, and can run as a daemon with GUI/CLI clients or as an embedded library.
`electrum/gui/` contains four independent implementations:
-`qt/` — full-featured desktop GUI (PyQt5/PyQt6)
-`qml/` — mobile GUI (Qt Quick / QML)
-`text.py` — curses terminal UI
-`stdio.py` — minimal stdio interface
### Plugin System
`electrum/plugins/` holds all optional features: hardware wallets (Ledger, Trezor, BitBox02, ColdCard, Jade, KeepKey, …), swap servers, watchtowers, label sync, audio modem, etc. Plugins register hooks that the core calls at defined points.
### Async Model
Network and Lightning code is heavily async (asyncio). Background tasks run as coroutines managed by `TaskGroup` / `MonitoredTaskGroup`. GUI threads communicate with async tasks via `aiohttp`-style futures or Qt signals.
### Testing Conventions
- Base class: `ElectrumTestCase` in `tests/__init__.py` (extends `unittest.IsolatedAsyncioTestCase`)
- Testnet mode: `@as_testnet` decorator on test classes/methods
BitcoinPurple is a Bitcoin fork with 1-minute blocks and a shorter difficulty retarget window. The Electrum client has been extended to support it as a first-class network alongside mainnet and testnet.
| `POW_GENESIS_BITS` | `None` (derived from MAX_TARGET) | **`0x1e0ffff0`** (genesis nBits differ from powLimit) |
| `MAX_ADJUSTMENT_FACTOR` | 4 | 4 |
`POW_GENESIS_BITS` is non-`None` for BTCP because the genesis block's `nBits` (`0x1e0ffff0`) is stricter than the `powLimit` compact (`0x1e0fffff`). `get_target(-1)` in `blockchain.py` returns `bits_to_target(POW_GENESIS_BITS)` when this is set, so period-0 header verification passes the exact equality check.
-`adj_interval == CHUNK_SIZE` (Bitcoin, 2016): reads old targets from on-disk headers.
-`adj_interval < CHUNK_SIZE` (BTCP, 120): retargets happen *within* a chunk, so headers are still in RAM (the buffer being verified). Uses an internal `_read_hdr(data, i)` helper to read from the buffer instead of `read_header()`.
### Files
| Path | Purpose |
|------|---------|
| `electrum/constants.py` | `BitcoinPurple` and `BitcoinPurpleTestnet` classes with all chain params |
| `electrum/blockchain.py` | `verify_chunk`, `get_target`, `can_connect` — all generalised for per-chain PoW constants |
BTCP has 1-minute blocks (10× faster than Bitcoin). All LN timeout values expressed in blocks must be scaled ×10 to preserve the same real-world security windows (e.g. `to_self_delay` 144 → 1440, `cltv_expiry_delta` 40 → 400). See `tecnichal-data.md §8.3` for the full table.