diff --git a/lnbits/extensions/admin/crud.py b/lnbits/extensions/admin/crud.py index 6fccb8ee..683558f9 100644 --- a/lnbits/extensions/admin/crud.py +++ b/lnbits/extensions/admin/crud.py @@ -1,26 +1,31 @@ +import json from typing import List, Optional from lnbits.core.crud import create_payment from lnbits.helpers import urlsafe_short_hash from lnbits.settings import * +from lnbits.tasks import internal_invoice_queue from . import db from .models import Admin, Funding -def update_wallet_balance(wallet_id: str, amount: int) -> str: +async def update_wallet_balance(wallet_id: str, amount: int) -> str: temp_id = f"temp_{urlsafe_short_hash()}" internal_id = f"internal_{urlsafe_short_hash()}" - create_payment( + + payment = await create_payment( wallet_id=wallet_id, checking_id=internal_id, payment_request="admin_internal", payment_hash="admin_internal", - amount=amount * 1000, + amount=amount*1000, memo="Admin top up", pending=False, ) - return "success" + # manually send this for now + await internal_invoice_queue.put(internal_id) + return payment async def update_admin(user: str, **kwargs) -> Admin: q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()])