mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-09 20:12:34 +02:00
fix: rounding errors on eclair total balance (#3196)
This commit is contained in:
@@ -3,7 +3,9 @@ import base64
|
|||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import urllib.parse
|
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
|
import httpx
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
@@ -70,8 +72,8 @@ class EclairWallet(Wallet):
|
|||||||
|
|
||||||
if r.is_error or "total" not in data:
|
if r.is_error or "total" not in data:
|
||||||
return StatusResponse(f"Server error: '{r.text}'", 0)
|
return StatusResponse(f"Server error: '{r.text}'", 0)
|
||||||
|
total = round(Decimal(data.get("total")), 8) * 100_000_000_000
|
||||||
return StatusResponse(None, int(data.get("total") * 100_000_000_000))
|
return StatusResponse(balance_msat=int(total), error_message=None)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
return StatusResponse("Server error: 'invalid json response'", 0)
|
return StatusResponse("Server error: 'invalid json response'", 0)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
@@ -66,7 +66,6 @@ async def test_pay_real_invoice(
|
|||||||
|
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
balance = await get_node_balance_sats()
|
balance = await get_node_balance_sats()
|
||||||
# TODO: maybe take fee into consideration?
|
|
||||||
assert prev_balance - balance == 100
|
assert prev_balance - balance == 100
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user