diff --git a/lnbits/wallets/eclair.py b/lnbits/wallets/eclair.py index daec315fa..c46f75c37 100644 --- a/lnbits/wallets/eclair.py +++ b/lnbits/wallets/eclair.py @@ -3,7 +3,9 @@ import base64 import hashlib import json import urllib.parse -from typing import Any, AsyncGenerator, Optional +from collections.abc import AsyncGenerator +from decimal import Decimal +from typing import Any, Optional import httpx from loguru import logger @@ -70,8 +72,8 @@ class EclairWallet(Wallet): if r.is_error or "total" not in data: return StatusResponse(f"Server error: '{r.text}'", 0) - - return StatusResponse(None, int(data.get("total") * 100_000_000_000)) + total = round(Decimal(data.get("total")), 8) * 100_000_000_000 + return StatusResponse(balance_msat=int(total), error_message=None) except json.JSONDecodeError: return StatusResponse("Server error: 'invalid json response'", 0) except Exception as exc: diff --git a/tests/regtest/test_real_invoice.py b/tests/regtest/test_real_invoice.py index 22707aca2..99319abbe 100644 --- a/tests/regtest/test_real_invoice.py +++ b/tests/regtest/test_real_invoice.py @@ -66,7 +66,6 @@ async def test_pay_real_invoice( await asyncio.sleep(1) balance = await get_node_balance_sats() - # TODO: maybe take fee into consideration? assert prev_balance - balance == 100