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