Survive oversized Electrum replies and ignore dust deposits (B-75, ELC-20, DEP-01, DAT-10)

A reply line over asyncio's default 64 KiB StreamReader limit raised out of
_read_loop and closed the only connection; the pool address's get_history passes
that after ~800 transactions, and dust sent to any public address does it on
purpose.

- ElectrumClient opens the stream with a 16 MiB limit and frames lines itself:
  an oversized line is discarded up to its newline, a non-JSON line is dropped,
  and the request whose id is readable in the first/last 256 bytes fails at once;
  the connection stays up either way.
- Coins below DUST_LIMIT_SATS are never offered as credit candidates, never
  credited, and select_utxos never selects them.
- Spec (ELC-20, DEP-01, DAT-10, ARC), storico, BUGS.md and test counts updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-10-14 12:14:12 +02:00
1 parent b424f670c5
commit daec4749c2
15 files changed
+245 -49

No files matched your search

+3 -3
View File
@@ -337,7 +337,7 @@ del database sono tutti uguali, perché arrivano tutti dallo stesso percorso
corroborazione è in [connessione-electrum.md](connessione-electrum.md)).
Le conferme richieste e la soglia sotto cui un output non si accredita
(`DUST_LIMIT_SATS`) sono regole del deposito, definite in
[registrazione-e-depositi.md](registrazione-e-depositi.md) (B-82, B-75): lo
[registrazione-e-depositi.md](registrazione-e-depositi.md) (B-82): lo
schema non le ripete. Il numero di conferme configurabile è la colonna
`round_config.deposit_confirmations` ([DAT-62]). L'inserimento è
idempotente su (`txid`, `vout`), che è unico su tutta la tabella, non solo
@@ -347,8 +347,8 @@ del database sono tutti uguali, perché arrivano tutti dallo stesso percorso
`app/deposits/service.py:credit_confirmed_utxos` ·
`app/electrum/listener.py:ElectrumListener.refresh_user` ·
*Test:* `tests/unit/test_deposits.py`, `tests/unit/test_electrum_listener.py`
*Stato:* da implementare (B-82, B-75) · *Oggi:* si accredita ogni output
con `height > 0` (1 conferma), coinbase comprese, di qualunque importo.
*Stato:* da implementare (B-82) · *Oggi:* si accredita ogni output
con `height > 0` (1 conferma), coinbase comprese.
- **[DAT-11]** Gli UTXO dei montepremi e della riserva **non** sono in
`utxo_events`: non appartengono a un utente. Il pagamento di un round spende