Add wallet send failsafe for dummy mode

This commit is contained in:
Mark Veidemanis 2023-05-20 13:54:05 +01:00
parent f41e69b003
commit 1744b9ead8
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 10 additions and 8 deletions

View File

@ -1,6 +1,7 @@
import asyncio
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from django.conf import settings
from django.core.management.base import BaseCommand
from pyotp import TOTP
@ -83,8 +84,8 @@ async def withdrawal_job(group=None):
# TODO: UNCOMMENT
# COMMENTED FOR TESTING
# if not checks["total_profit_in_xmr"] >= 0:
# return
if not checks["total_profit_in_xmr"] >= 0:
return
total_withdrawal = sum(collapsed.values())
if checks["total_xmr_agora"] < total_withdrawal:
@ -110,7 +111,7 @@ async def withdrawal_job(group=None):
print("NOT VALID", wallet.address)
await sendmsg(
group.user,
f"Invalid XMR address: {wallet.address}",
f"Invalid XMR address: {wallet.address}, ignored",
title="Invalid XMR address",
)
continue
@ -131,9 +132,9 @@ async def withdrawal_job(group=None):
print("CAST ADDRESS", cast["address"])
print("CAST AMOUNT", cast["amount"])
print("CAST OTP TRUNCATED BY 2", cast["otp"][-2])
sent = await run.call("wallet_send_xmr", **cast)
print("SENT", sent)
if not settings.DUMMY:
sent = await run.call("wallet_send_xmr", **cast)
print("SENT", sent)
payout = Payout.objects.create( # noqa
user=group.user,
@ -142,8 +143,9 @@ async def withdrawal_job(group=None):
description=reason,
)
payout.response = sent
payout.save()
if not settings.DUMMY:
payout.response = sent
payout.save()
async def aggregator_job():