Safe restore from a backup: START_PAUSED and the derivation-gap check (B-90, REG-15, OPS-27)

START_PAUSED=true pauses the lottery as the operator before the scheduler exists.
On the first Electrum session the 20 derivation indexes past the highest
assigned one are looked up on every server; if any has history, registration
stays closed (503 registration_unavailable) and restore_gap_detected is
written, so a restored database cannot hand a lost user's address to a new one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-10-18 00:43:45 +02:00
1 parent 55d852fe08
commit 40ac490826
21 files changed
+281 -70

No files matched your search

+9
View File
@@ -25,6 +25,15 @@ def _throwaway_master_key(tmp_path, monkeypatch):
hd._account_key = None
@pytest.fixture(autouse=True)
def _registration_open(monkeypatch):
"""B-90: a real listener keeps registration closed until its restore-gap check ran;
only the tests about that check care, and they set it themselves."""
from app.electrum.listener import ElectrumListener
monkeypatch.setattr(ElectrumListener, "registration_open", True)
# B-74: the real powLimit needs ~2^32 hashes per header, so tests mine headers at a trivial
# target (`0x207fffff`) and this swaps in a limit that allows it. Done at import, not in a
# fixture, because some test modules mine headers while they are being collected. The