From 1744b9ead8da60368bc2b28689094cdcb38d7d00 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 20 May 2023 13:54:05 +0100 Subject: [PATCH] Add wallet send failsafe for dummy mode --- core/management/commands/scheduling.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/core/management/commands/scheduling.py b/core/management/commands/scheduling.py index aef0a67..16cdd06 100644 --- a/core/management/commands/scheduling.py +++ b/core/management/commands/scheduling.py @@ -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():