topup wallet endpoint

This commit is contained in:
Tiago vasconcelos 2022-03-22 10:28:07 +00:00 committed by dni ⚡
parent 582cc52ac6
commit 66a7f53b97

View File

@ -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()])