From 0b1f3c22e05786a5894f4a2e02f4b3c905f0acda Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 6 Oct 2020 21:53:43 -0300 Subject: [PATCH] lndhub: fix "token" -> "refresh_token". --- lnbits/core/views/api.py | 8 +++++++- lnbits/extensions/lndhub/views_api.py | 4 ++-- lnbits/wallets/lndrest.py | 11 +++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index 39d1f10..bd19830 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -17,7 +17,13 @@ from ..tasks import sse_listeners @api_check_wallet_key("invoice") async def api_wallet(): return ( - jsonify({"id": g.wallet.id, "name": g.wallet.name, "balance": g.wallet.balance_msat,}), + jsonify( + { + "id": g.wallet.id, + "name": g.wallet.name, + "balance": g.wallet.balance_msat, + } + ), HTTPStatus.OK, ) diff --git a/lnbits/extensions/lndhub/views_api.py b/lnbits/extensions/lndhub/views_api.py index c413c46..acfacfb 100644 --- a/lnbits/extensions/lndhub/views_api.py +++ b/lnbits/extensions/lndhub/views_api.py @@ -28,8 +28,8 @@ async def lndhub_getinfo(): ) async def lndhub_auth(): token = ( - g.data["token"] - if "token" in g.data and g.data["token"] + g.data["refresh_token"] + if "refresh_token" in g.data and g.data["refresh_token"] else urlsafe_b64encode((g.data["login"] + ":" + g.data["password"]).encode("utf-8")).decode("ascii") ) return jsonify({"refresh_token": token, "access_token": token}) diff --git a/lnbits/wallets/lndrest.py b/lnbits/wallets/lndrest.py index d05728a..7ff8e8c 100644 --- a/lnbits/wallets/lndrest.py +++ b/lnbits/wallets/lndrest.py @@ -37,7 +37,12 @@ class LndRestWallet(Wallet): else: data["memo"] = memo or "" - r = httpx.post(url=f"{self.endpoint}/v1/invoices", headers=self.auth_invoice, verify=self.auth_cert, json=data,) + r = httpx.post( + url=f"{self.endpoint}/v1/invoices", + headers=self.auth_invoice, + verify=self.auth_cert, + json=data, + ) if r.is_error: error_message = r.text @@ -78,7 +83,9 @@ class LndRestWallet(Wallet): def get_invoice_status(self, checking_id: str) -> PaymentStatus: checking_id = checking_id.replace("_", "/") r = httpx.get( - url=f"{self.endpoint}/v1/invoice/{checking_id}", headers=self.auth_invoice, verify=self.auth_cert, + url=f"{self.endpoint}/v1/invoice/{checking_id}", + headers=self.auth_invoice, + verify=self.auth_cert, ) if r.is_error or not r.json().get("settled"):