Skip to content

Commit

Permalink
ADD: LND verify config
Browse files Browse the repository at this point in the history
This adds the configuration to disable certificate verification or use a custom certificate.
  • Loading branch information
AaronDewes authored Jan 22, 2022
1 parent 06e0faf commit b231178
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions example_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ url =
[lnd]
# HEX encoded LND macaroon
macaroon =
verify = on

[lntxbot]
# base64 encoded lntxbot api credentials
Expand Down
13 changes: 10 additions & 3 deletions lndrest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand All @@ -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()
Expand All @@ -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:
Expand Down

1 comment on commit b231178

@GregorWedlich
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the request actually expect a tls.cert on "verify=verify"?

        response = requests.get(
            url, headers={"Grpc-Metadata-macaroon": config.conf["lnd"]["macaroon"]}
            url,
            headers={"Grpc-Metadata-macaroon": config.conf["lnd"]["macaroon"]},
            verify=verify,
        )
   )

Please sign in to comment.