From 656c6cac5b96ebc25dde34923c85c78756326f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 3 Feb 2026 12:23:49 +0100 Subject: [PATCH] hotfix: websocket with old balance was sent. (#3759) --- lnbits/core/services/payments.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lnbits/core/services/payments.py b/lnbits/core/services/payments.py index 454a5e54a..ef1d07dbd 100644 --- a/lnbits/core/services/payments.py +++ b/lnbits/core/services/payments.py @@ -776,7 +776,7 @@ async def _pay_internal_invoice( await update_payment(internal_payment, conn=conn) logger.success(f"internal payment successful {internal_payment.checking_id}") - send_payment_notification_in_background(wallet, payment) + await _send_payment_notification_in_background(wallet.id, payment, conn=conn) # notify receiver asynchronously from lnbits.tasks import internal_invoice_queue @@ -849,7 +849,8 @@ async def _pay_external_invoice( payment = await update_payment_success_status( payment, payment_response, conn=conn ) - send_payment_notification_in_background(wallet, payment) + + await _send_payment_notification_in_background(wallet.id, payment, conn=conn) logger.success(f"payment successful {payment_response.checking_id}") payment.checking_id = payment_response.checking_id @@ -1057,3 +1058,13 @@ async def cancel_hold_invoice(payment: Payment) -> InvoiceResponse: await update_payment(payment) return response + + +async def _send_payment_notification_in_background( + wallet_id: str, payment: Payment, conn: Connection | None = None +): + # fetch balance again + wallet = await get_wallet(wallet_id, conn=conn) + if not wallet: + raise PaymentError(f"Could not fetch wallet '{wallet_id}'.", status="failed") + send_payment_notification_in_background(wallet, payment)