topup wallet endpoint
This commit is contained in:
parent
582cc52ac6
commit
66a7f53b97
1 changed files with 9 additions and 4 deletions
|
|
@ -1,26 +1,31 @@
|
||||||
|
import json
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from lnbits.core.crud import create_payment
|
from lnbits.core.crud import create_payment
|
||||||
from lnbits.helpers import urlsafe_short_hash
|
from lnbits.helpers import urlsafe_short_hash
|
||||||
from lnbits.settings import *
|
from lnbits.settings import *
|
||||||
|
from lnbits.tasks import internal_invoice_queue
|
||||||
|
|
||||||
from . import db
|
from . import db
|
||||||
from .models import Admin, Funding
|
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()}"
|
temp_id = f"temp_{urlsafe_short_hash()}"
|
||||||
internal_id = f"internal_{urlsafe_short_hash()}"
|
internal_id = f"internal_{urlsafe_short_hash()}"
|
||||||
create_payment(
|
|
||||||
|
payment = await create_payment(
|
||||||
wallet_id=wallet_id,
|
wallet_id=wallet_id,
|
||||||
checking_id=internal_id,
|
checking_id=internal_id,
|
||||||
payment_request="admin_internal",
|
payment_request="admin_internal",
|
||||||
payment_hash="admin_internal",
|
payment_hash="admin_internal",
|
||||||
amount=amount * 1000,
|
amount=amount*1000,
|
||||||
memo="Admin top up",
|
memo="Admin top up",
|
||||||
pending=False,
|
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:
|
async def update_admin(user: str, **kwargs) -> Admin:
|
||||||
q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()])
|
q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue