mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-05 11:18:36 +02:00
FIX: admin topup to use payment_hash (#1588)
* FIX: admin topup to use payment_hash * flake8
This commit is contained in:
@@ -13,7 +13,7 @@ from loguru import logger
|
|||||||
from lnbits import bolt11
|
from lnbits import bolt11
|
||||||
from lnbits.db import Connection
|
from lnbits.db import Connection
|
||||||
from lnbits.decorators import WalletTypeInfo, require_admin_key
|
from lnbits.decorators import WalletTypeInfo, require_admin_key
|
||||||
from lnbits.helpers import url_for, urlsafe_short_hash
|
from lnbits.helpers import url_for
|
||||||
from lnbits.settings import (
|
from lnbits.settings import (
|
||||||
FAKE_WALLET,
|
FAKE_WALLET,
|
||||||
EditableSettings,
|
EditableSettings,
|
||||||
@@ -400,21 +400,20 @@ def fee_reserve(amount_msat: int) -> int:
|
|||||||
|
|
||||||
|
|
||||||
async def update_wallet_balance(wallet_id: str, amount: int):
|
async def update_wallet_balance(wallet_id: str, amount: int):
|
||||||
internal_id = f"internal_{urlsafe_short_hash()}"
|
payment_hash, _ = await create_invoice(
|
||||||
payment = await create_payment(
|
|
||||||
wallet_id=wallet_id,
|
wallet_id=wallet_id,
|
||||||
checking_id=internal_id,
|
amount=amount,
|
||||||
payment_request="admin_internal",
|
|
||||||
payment_hash="admin_internal",
|
|
||||||
amount=amount * 1000,
|
|
||||||
memo="Admin top up",
|
memo="Admin top up",
|
||||||
pending=False,
|
internal=True,
|
||||||
)
|
)
|
||||||
# manually send this for now
|
async with db.connect() as conn:
|
||||||
from lnbits.tasks import internal_invoice_queue
|
checking_id = await check_internal(payment_hash, conn=conn)
|
||||||
|
assert checking_id, "newly created checking_id cannot be retrieved"
|
||||||
|
await update_payment_status(checking_id=checking_id, pending=False, conn=conn)
|
||||||
|
# notify receiver asynchronously
|
||||||
|
from lnbits.tasks import internal_invoice_queue
|
||||||
|
|
||||||
await internal_invoice_queue.put(internal_id)
|
await internal_invoice_queue.put(checking_id)
|
||||||
return payment
|
|
||||||
|
|
||||||
|
|
||||||
async def check_admin_settings():
|
async def check_admin_settings():
|
||||||
|
Reference in New Issue
Block a user