diff --git a/lnbits/core/services.py b/lnbits/core/services.py index 68447e24..85a90c5a 100644 --- a/lnbits/core/services.py +++ b/lnbits/core/services.py @@ -247,6 +247,15 @@ async def pay_invoice( new_checking_id=payment.checking_id, conn=conn, ) + wallet = await get_wallet(wallet_id, conn=conn) + if wallet: + await websocketUpdater( + wallet_id, + { + "wallet_balance": wallet.balance or None, + "payment": payment._asdict(), + }, + ) logger.debug(f"payment successful {payment.checking_id}") elif payment.checking_id is None and payment.ok is False: # payment failed diff --git a/lnbits/core/tasks.py b/lnbits/core/tasks.py index 1b6ddf26..722eefbb 100644 --- a/lnbits/core/tasks.py +++ b/lnbits/core/tasks.py @@ -7,7 +7,7 @@ from loguru import logger from lnbits.tasks import SseListenersDict, register_invoice_listener from . import db -from .crud import get_balance_notify +from .crud import get_balance_notify, get_wallet from .models import Payment from .services import websocketUpdater @@ -38,8 +38,15 @@ async def wait_for_paid_invoices(invoice_paid_queue: asyncio.Queue): logger.trace("received invoice paid event") # send information to sse channel await dispatch_api_invoice_listeners(payment) - await websocketUpdater(payment.wallet_id, payment.dict()) - + wallet = await get_wallet(payment.wallet_id) + if wallet: + await websocketUpdater( + payment.wallet_id, + { + "wallet_balance": wallet.balance or None, + "payment": payment._asdict(), + }, + ) # dispatch webhook if payment.webhook and not payment.webhook_status: await dispatch_webhook(payment)