diff --git a/lnbits/wallets/alby.py b/lnbits/wallets/alby.py index 593ad6740..7b7507739 100644 --- a/lnbits/wallets/alby.py +++ b/lnbits/wallets/alby.py @@ -44,11 +44,14 @@ class AlbyWallet(Wallet): except (httpx.ConnectError, httpx.RequestError): return StatusResponse(f"Unable to connect to '{self.endpoint}'", 0) - data = r.json()["balance"] if r.is_error: - return StatusResponse(data["error"], 0) + error_message = r.json()["message"] + return StatusResponse(error_message, 0) - return StatusResponse(None, data) + data = r.json() + assert data["unit"] == "sat" + # multiply balance by 1000 to get msats balance + return StatusResponse(None, data["balance"] * 1000) async def create_invoice( self, diff --git a/lnbits/wallets/opennode.py b/lnbits/wallets/opennode.py index ac6b510fc..7f20447b0 100644 --- a/lnbits/wallets/opennode.py +++ b/lnbits/wallets/opennode.py @@ -56,10 +56,12 @@ class OpenNodeWallet(Wallet): except (httpx.ConnectError, httpx.RequestError): return StatusResponse(f"Unable to connect to '{self.endpoint}'", 0) - data = r.json()["data"] if r.is_error: - return StatusResponse(data["message"], 0) + error_message = r.json()["message"] + return StatusResponse(error_message, 0) + data = r.json()["data"] + # multiply balance by 1000 to get msats balance return StatusResponse(None, data["balance"]["BTC"] * 1000) async def create_invoice(