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>
17 lines
683 B
Python
17 lines
683 B
Python
from sqlalchemy import select
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.db.models import PendingTransaction, Round
|
|
from app.tx.confirmation import register_handler
|
|
|
|
|
|
async def _on_payout_confirmed(session: AsyncSession, pending: PendingTransaction) -> None:
|
|
round_ = await session.scalar(select(Round).where(Round.payout_txid == pending.current_txid))
|
|
if round_ is not None and round_.status == "paying_out":
|
|
round_.status = "closed"
|
|
# The winner's own address is already watched by the Electrum listener, so
|
|
# their balance is credited by the normal deposit path once this confirms.
|
|
|
|
|
|
register_handler("payout", _on_payout_confirmed)
|