Enabling dual support - clients with or without macaroons/tls

This commit is contained in:
rockstardev 2018-05-14 15:05:03 -05:00
parent f97173e9e7
commit 7c29cb62ef

View file

@ -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);
}
}