Validate addresses and enable payments

This commit is contained in:
2023-05-20 13:41:49 +01:00
parent 390132fb10
commit 85c64efc78
5 changed files with 765 additions and 9 deletions

View File

@@ -17,6 +17,7 @@ from core.models import (
Requisition,
)
from core.util import logs
from core.util.validation import Validation
log = logs.get_logger("scheduling")
@@ -100,10 +101,20 @@ async def withdrawal_job(group=None):
raise Exception("You can only have one platform per group")
platform = group.platforms.first()
# run = await AgoraClient(platform)
run = await AgoraClient(platform)
otp_code = TOTP(platform.otp_token).now()
for wallet, pay_list_iter in pay_list.items():
print("WALLET ITER", wallet)
if not Validation.is_address("xmr", wallet.address):
print("NOT VALID", wallet.address)
await sendmsg(
group.user,
f"Invalid XMR address: {wallet.address}",
title="Invalid XMR address",
)
continue
for amount, reason in pay_list_iter:
print("ITER", wallet, pay_list_iter)
print("ITER SENT", wallet, amount, reason)
@@ -121,9 +132,8 @@ async def withdrawal_job(group=None):
print("CAST AMOUNT", cast["amount"])
print("CAST OTP TRUNCATED BY 2", cast["otp"][-2])
# TODO: UNCOMMENT
# sent = await run.call("wallet_send_xmr", **cast)
# print("SENT", sent)
sent = await run.call("wallet_send_xmr", **cast)
print("SENT", sent)
payout = Payout.objects.create( # noqa
user=group.user,
@@ -132,9 +142,8 @@ async def withdrawal_job(group=None):
description=reason,
)
# TODO: UNCOMMENT
# payout.response = sent
# payout.save()
payout.response = sent
payout.save()
async def aggregator_job():