From 51c3f647d2fa94c0f07ea6a9612e640bd775f0c0 Mon Sep 17 00:00:00 2001 From: Aaron Dewes Date: Wed, 29 Dec 2021 00:17:22 +0100 Subject: [PATCH 1/2] WIP: Add LND verify config --- example_config.ini | 1 + lndrest.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/example_config.ini b/example_config.ini index fbd550a..89edebe 100644 --- a/example_config.ini +++ b/example_config.ini @@ -52,6 +52,7 @@ url = [lnd] # HEX encoded LND macaroon macaroon = +verify = on [lntxbot] # base64 encoded lntxbot api credentials diff --git a/lndrest.py b/lndrest.py index 7203077..6da1ed3 100755 --- a/lndrest.py +++ b/lndrest.py @@ -15,10 +15,13 @@ logger = logging.getLogger("LNDREST") +verify = True +if(config.conf["lnd"]["verify"].lower() == "off"): + verify = False +if(config.conf["lnd"]["verify"].lower() != "off"): + verify = config.conf["lnd"]["verify"] # TODO: Remove display calls from here to app.py -# TODO: Add the "verify=False" param to all post and get requests for local api queries - class InvoiceDecodeError(BaseException): pass @@ -36,6 +39,7 @@ def payout(amt, payment_request): str(config.conf["btcpay"]["url"]) + "/channels/transactions", headers={"Grpc-Metadata-macaroon": str(config.conf["lnd"]["macaroon"])}, data=json.dumps(data), + verify=verify, ) res_json = response.json() @@ -58,6 +62,7 @@ def last_payment(payment_request): url, headers={"Grpc-Metadata-macaroon": str(config.conf["lnd"]["macaroon"])}, data=json.dumps(data), + verify=verify, ) json_data = response.json() @@ -82,7 +87,9 @@ def decode_request(payment_request): if payment_request: url = str(config.conf["btcpay"]["url"]) + "/payreq/" + str(payment_request) response = requests.get( - url, headers={"Grpc-Metadata-macaroon": config.conf["lnd"]["macaroon"]} + url, + headers={"Grpc-Metadata-macaroon": config.conf["lnd"]["macaroon"]} + verify=verify, ) # successful response if response.status_code != 200: From 0fce0534cf356495cb6b8a3a6e3ab7937299d09d Mon Sep 17 00:00:00 2001 From: Aaron Dewes Date: Wed, 29 Dec 2021 00:23:39 +0100 Subject: [PATCH 2/2] Fix syntax error --- lndrest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lndrest.py b/lndrest.py index 6da1ed3..bd40956 100755 --- a/lndrest.py +++ b/lndrest.py @@ -88,7 +88,7 @@ def decode_request(payment_request): url = str(config.conf["btcpay"]["url"]) + "/payreq/" + str(payment_request) response = requests.get( url, - headers={"Grpc-Metadata-macaroon": config.conf["lnd"]["macaroon"]} + headers={"Grpc-Metadata-macaroon": config.conf["lnd"]["macaroon"]}, verify=verify, ) # successful response