Skip to content

Commit

Permalink
new way to get local balance
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Mar 26, 2024
1 parent a564411 commit d4cde91
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cashu/lightning/corelightningrest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
Expand Down

0 comments on commit d4cde91

Please sign in to comment.