19 lines
645 B
Python
19 lines
645 B
Python
from datetime import datetime, timezone
|
|||
|
|
|
||
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||
|
|
|
||
|
|
from app.db.models import PendingTransaction, Withdrawal
|
||
|
|
from app.tx.confirmation import register_handler
|
||
|
|
|
||
|
|
|
||
|
|
async def _on_withdrawal_confirmed(session: AsyncSession, pending: PendingTransaction) -> None:
|
||
|
|
if pending.withdrawal_id is None:
|
||
|
|
return
|
||
|
|
withdrawal = await session.get(Withdrawal, pending.withdrawal_id)
|
||
|
|
if withdrawal is not None and withdrawal.status == "broadcast":
|
||
|
|
withdrawal.status = "confirmed"
|
||
|
|
withdrawal.confirmed_at = datetime.now(timezone.utc)
|
||
|
|
|
||
|
|
|
||
|
|
register_handler("withdrawal", _on_withdrawal_confirmed)
|