From a3aafe4b6ff8fcef3ada144a767050bf807ac73c Mon Sep 17 00:00:00 2001 From: Arc <33088785+arcbtc@users.noreply.github.com> Date: Wed, 19 Jul 2023 12:14:03 +0100 Subject: [PATCH] Data returned from wallet websocket was not json (#1823) * Fixed walet websocket json * format --- lnbits/core/services.py | 10 ++++++---- lnbits/core/static/js/service-worker.js | 2 +- lnbits/core/tasks.py | 11 +++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lnbits/core/services.py b/lnbits/core/services.py index b9f386a29..c0ce6ac3f 100644 --- a/lnbits/core/services.py +++ b/lnbits/core/services.py @@ -251,10 +251,12 @@ async def pay_invoice( if wallet: await websocketUpdater( wallet_id, - { - "wallet_balance": wallet.balance or None, - "payment": payment._asdict(), - }, + json.dumps( + { + "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: diff --git a/lnbits/core/static/js/service-worker.js b/lnbits/core/static/js/service-worker.js index f03c99ef5..6f42720d1 100644 --- a/lnbits/core/static/js/service-worker.js +++ b/lnbits/core/static/js/service-worker.js @@ -1,6 +1,6 @@ // update cache version every time there is a new deployment // so the service worker reinitializes the cache -const CACHE_VERSION = 48 +const CACHE_VERSION = 50 const CURRENT_CACHE = `lnbits-${CACHE_VERSION}-` const getApiKey = request => { diff --git a/lnbits/core/tasks.py b/lnbits/core/tasks.py index 4b397b100..14f8478d1 100644 --- a/lnbits/core/tasks.py +++ b/lnbits/core/tasks.py @@ -1,4 +1,5 @@ import asyncio +import json from typing import Dict, Optional import httpx @@ -124,10 +125,12 @@ async def wait_for_paid_invoices(invoice_paid_queue: asyncio.Queue): if wallet: await websocketUpdater( payment.wallet_id, - { - "wallet_balance": wallet.balance or None, - "payment": payment.dict(), - }, + json.dumps( + { + "wallet_balance": wallet.balance or None, + "payment": payment.dict(), + } + ), ) # dispatch webhook if payment.webhook and not payment.webhook_status: