From 7c29cb62efd59010dc7911ac6402ad1d2e625a88 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Mon, 14 May 2018 15:05:03 -0500 Subject: [PATCH] Enabling dual support - clients with or without macaroons/tls --- .../Payments/Lightning/Lnd/LndSwaggerClientCustomHttp.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BTCPayServer/Payments/Lightning/Lnd/LndSwaggerClientCustomHttp.cs b/BTCPayServer/Payments/Lightning/Lnd/LndSwaggerClientCustomHttp.cs index ed5cee152..7f9c92eb5 100644 --- a/BTCPayServer/Payments/Lightning/Lnd/LndSwaggerClientCustomHttp.cs +++ b/BTCPayServer/Payments/Lightning/Lnd/LndSwaggerClientCustomHttp.cs @@ -28,9 +28,12 @@ namespace BTCPayServer.Payments.Lightning.Lnd // public static LndSwaggerClientCustomHttp Create(Uri uri, Network network, byte[] tlsCertificate = null, byte[] grpcMacaroon = null) { - // for now working with custom build of lnd that has no macaroons and is on http - //_HttpClient = HttpClientFactoryForLnd.Generate(tlsCertificate, grpcMacaroon); - var httpClient = new HttpClient(); + // for development we are working with custom build of lnd that allows no macaroons and http + var clientWithNoMacaroonsTls = tlsCertificate == null || grpcMacaroon == null; + + var httpClient = clientWithNoMacaroonsTls ? new HttpClient() : + HttpClientFactoryForLnd.Generate(tlsCertificate, grpcMacaroon); + return new LndSwaggerClientCustomHttp(uri.ToString().TrimEnd('/'), httpClient); } }