optional ssl certifiace for lndrest

This commit is contained in:
dni ⚡ 2023-04-19 09:57:19 +02:00
parent fe315d0a9b
commit adae3b4302
No known key found for this signature in database
GPG key ID: 886317704CC4E618

View file

@ -24,6 +24,7 @@ class LndRestWallet(Wallet):
def __init__(self):
endpoint = settings.lnd_rest_endpoint
cert = settings.lnd_rest_cert
macaroon = (
settings.lnd_rest_macaroon
@ -39,8 +40,16 @@ class LndRestWallet(Wallet):
encrypted_macaroon
)
if not endpoint or not macaroon or not settings.lnd_rest_cert:
raise Exception("cannot initialize lndrest")
if not endpoint:
raise Exception("cannot initialize lndrest: no endpoint")
if not macaroon:
raise Exception("cannot initialize lndrest: no macaroon")
if not cert:
logger.warning(
"no certificate for lndrest provided, this only works if you have a publicly issued certificate"
)
endpoint = endpoint[:-1] if endpoint.endswith("/") else endpoint
endpoint = (
@ -49,8 +58,12 @@ class LndRestWallet(Wallet):
self.endpoint = endpoint
self.macaroon = load_macaroon(macaroon)
# if no cert provided it should be public so we set verify to True
# and it will still check for validity of certificate and fail if its not valid
# even on startup
self.cert = cert or True
self.auth = {"Grpc-Metadata-macaroon": self.macaroon}
self.cert = settings.lnd_rest_cert
async def status(self) -> StatusResponse:
try: