From a56441108d3b5c8e8bdf14c08c276fbdd5a43d6d Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:21:08 +0100 Subject: [PATCH 1/2] returs different model --- cashu/lightning/corelightningrest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cashu/lightning/corelightningrest.py b/cashu/lightning/corelightningrest.py index da36cdc1..1f02dfc4 100644 --- a/cashu/lightning/corelightningrest.py +++ b/cashu/lightning/corelightningrest.py @@ -212,7 +212,7 @@ async def pay_invoice( checking_id = data["payment_hash"] preimage = data["payment_preimage"] - fee_msat = data["msatoshi_sent"] - data["msatoshi"] + fee_msat = data["amount_sent_msat"] - data["amount_msat"] return PaymentResponse( ok=self.statuses.get(data["status"]), From d4cde915f50d67aad245a948f67aff2eb60f0185 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:54:16 +0100 Subject: [PATCH 2/2] new way to get local balance --- cashu/lightning/corelightningrest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cashu/lightning/corelightningrest.py b/cashu/lightning/corelightningrest.py index 1f02dfc4..4503f6a0 100644 --- a/cashu/lightning/corelightningrest.py +++ b/cashu/lightning/corelightningrest.py @@ -70,7 +70,7 @@ async def cleanup(self): logger.warning(f"Error closing wallet connection: {e}") async def status(self) -> StatusResponse: - r = await self.client.get(f"{self.url}/v1/channel/localremotebal", timeout=5) + r = await self.client.get(f"{self.url}/v1/listFunds", timeout=5) r.raise_for_status() if r.is_error or "error" in r.json(): try: @@ -88,7 +88,7 @@ async def status(self) -> StatusResponse: data = r.json() if len(data) == 0: return StatusResponse(error_message="no data", balance=0) - balance_msat = int(data.get("localBalance") * 1000) + balance_msat = int(sum([c["our_amount_msat"] for c in data["channels"]])) return StatusResponse(error_message=None, balance=balance_msat) async def create_invoice(