mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2024-11-19 09:54:21 +01:00
alby: fix balance reporting and error handling + opennode: fix error handling (#2221)
* opennode: fix error handling * alby: fix balance reporting and error handling
This commit is contained in:
parent
22ea83e843
commit
4f45781319
@ -44,11 +44,14 @@ class AlbyWallet(Wallet):
|
|||||||
except (httpx.ConnectError, httpx.RequestError):
|
except (httpx.ConnectError, httpx.RequestError):
|
||||||
return StatusResponse(f"Unable to connect to '{self.endpoint}'", 0)
|
return StatusResponse(f"Unable to connect to '{self.endpoint}'", 0)
|
||||||
|
|
||||||
data = r.json()["balance"]
|
|
||||||
if r.is_error:
|
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(
|
async def create_invoice(
|
||||||
self,
|
self,
|
||||||
|
@ -56,10 +56,12 @@ class OpenNodeWallet(Wallet):
|
|||||||
except (httpx.ConnectError, httpx.RequestError):
|
except (httpx.ConnectError, httpx.RequestError):
|
||||||
return StatusResponse(f"Unable to connect to '{self.endpoint}'", 0)
|
return StatusResponse(f"Unable to connect to '{self.endpoint}'", 0)
|
||||||
|
|
||||||
data = r.json()["data"]
|
|
||||||
if r.is_error:
|
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)
|
return StatusResponse(None, data["balance"]["BTC"] * 1000)
|
||||||
|
|
||||||
async def create_invoice(
|
async def create_invoice(
|
||||||
|
Loading…
Reference in New Issue
Block a user