Implement full MVP: auth, HD wallet, Electrum client, deposits, bets, round/draw engine, payout, withdrawals, RBF, admin+audit

All 10 build-order stages complete and unit-tested (49 tests). Verified live on
mainnet: registration/address derivation, deposit crediting, a real 10 PLM bet
(broadcast + confirmed + change credited). A full round close->draw->payout
cycle was triggered live and was in progress at commit time. Withdrawal and RBF
bump are unit-tested but not yet exercised against a live broadcast. Known gaps
(scheduler doesn't resume mid-flight rounds after restart, payout has no retry,
no deployment setup, etc.) are documented in CLAUDE.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 23:52:20 +02:00
co-authored by Claude Sonnet 5
parent bae48c46dc
commit df72367f02
76 changed files with 3506 additions and 1 deletions
+22
View File
@@ -0,0 +1,22 @@
import asyncio
from contextlib import asynccontextmanager
class UserLocks:
"""Per-user asyncio.Lock registry, shared by PLAY and WITHDRAW so a user can
never have a bet-build and a withdrawal-build in flight at once (both would
otherwise spend from the same UTXO set on the user's dedicated address).
Single-process-only by design (an in-memory dict of asyncio.Lock) — this is an
accepted MVP constraint; a multi-process deployment would need a DB or Redis
lock instead (e.g. a Postgres advisory lock).
"""
def __init__(self) -> None:
self._locks: dict[int, asyncio.Lock] = {}
@asynccontextmanager
async def acquire(self, user_id: int):
lock = self._locks.setdefault(user_id, asyncio.Lock())
async with lock:
yield