From 26eb7a449ca247e5d31f9f6f90ca39a4f07fd90d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Mon, 30 Jun 2025 12:55:23 +0200 Subject: [PATCH] feat: add internal_invoice_queue_put to get rid of dynamic import (#3223) --- lnbits/core/services/payments.py | 6 ++---- lnbits/tasks.py | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lnbits/core/services/payments.py b/lnbits/core/services/payments.py index ca77fc909..8213a42c9 100644 --- a/lnbits/core/services/payments.py +++ b/lnbits/core/services/payments.py @@ -20,6 +20,7 @@ from lnbits.exceptions import InvoiceError, PaymentError from lnbits.fiat import get_fiat_provider from lnbits.helpers import check_callback_url from lnbits.settings import settings +from lnbits.tasks import create_task, internal_invoice_queue_put from lnbits.utils.crypto import fake_privkey, random_secret_and_hash from lnbits.utils.exchange_rates import fiat_amount_as_satoshis, satoshis_amount_as_fiat from lnbits.wallets import fake_wallet, get_funding_source @@ -424,10 +425,7 @@ async def update_wallet_balance( ) payment.status = PaymentState.SUCCESS await update_payment(payment, conn=conn) - # notify receiver asynchronously - from lnbits.tasks import internal_invoice_queue - - await internal_invoice_queue.put(payment.checking_id) + await internal_invoice_queue_put(payment.checking_id) async def check_wallet_limits( diff --git a/lnbits/tasks.py b/lnbits/tasks.py index 702afe6c3..17fbfefe3 100644 --- a/lnbits/tasks.py +++ b/lnbits/tasks.py @@ -107,6 +107,13 @@ def register_invoice_listener(send_chan: asyncio.Queue, name: Optional[str] = No internal_invoice_queue: asyncio.Queue = asyncio.Queue(0) +async def internal_invoice_queue_put(checking_id: str) -> None: + """ + A method to call when it wants to notify about an internal invoice payment. + """ + await internal_invoice_queue.put(checking_id) + + async def internal_invoice_listener() -> None: """ internal_invoice_queue will be filled directly in core/services.py