public static ILightningClient CreateClient(LightningConnectionString connString, Network network)
 {
     if (connString.ConnectionType == LightningConnectionType.Charge)
     {
         return(new ChargeClient(connString.ToUri(true), network));
     }
     else if (connString.ConnectionType == LightningConnectionType.CLightning)
     {
         return(new CLightningClient(connString.ToUri(false), network));
     }
     else if (connString.ConnectionType == LightningConnectionType.LndREST)
     {
         return(new LndClient(new LndSwaggerClient(new LndRestSettings(connString.BaseUri)
         {
             Macaroon = connString.Macaroon,
             MacaroonFilePath = connString.MacaroonFilePath,
             CertificateThumbprint = connString.CertificateThumbprint,
             AllowInsecure = connString.AllowInsecure,
         }), network));
     }
     else
     {
         throw new NotSupportedException($"Unsupported connection string for lightning server ({connString.ConnectionType})");
     }
 }
Пример #2
0
 public ILightningClient Create(LightningConnectionString connectionString)
 {
     if (connectionString == null)
     {
         throw new ArgumentNullException(nameof(connectionString));
     }
     if (connectionString.ConnectionType == LightningConnectionType.Charge)
     {
         if (connectionString.CookieFilePath != null)
         {
             return(new ChargeClient(connectionString.BaseUri, connectionString.CookieFilePath, Network,
                                     HttpClient, connectionString.AllowInsecure));
         }
         else
         {
             return(new ChargeClient(connectionString.ToUri(true), Network, HttpClient, connectionString.AllowInsecure));
         }
     }
     else if (connectionString.ConnectionType == LightningConnectionType.CLightning)
     {
         return(new CLightningClient(connectionString.ToUri(false), Network));
     }
     else if (connectionString.ConnectionType == LightningConnectionType.LndREST)
     {
         return(new LndClient(new LndSwaggerClient(new LndRestSettings(connectionString.BaseUri)
         {
             Macaroon = connectionString.Macaroon,
             MacaroonFilePath = connectionString.MacaroonFilePath,
             CertificateThumbprint = connectionString.CertificateThumbprint,
             AllowInsecure = connectionString.AllowInsecure,
         }, HttpClient), Network));
     }
     else if (connectionString.ConnectionType == LightningConnectionType.Eclair)
     {
         return(new EclairLightningClient(connectionString.BaseUri, connectionString.Password, Network, HttpClient));
     }
     else if (connectionString.ConnectionType == LightningConnectionType.Ptarmigan)
     {
         var rpcClient =
             !string.IsNullOrEmpty(connectionString.BitcoinHost) &&
             !string.IsNullOrEmpty(connectionString.BitcoinAuth)
                 ? new RPCClient(connectionString.BitcoinAuth, connectionString.BitcoinHost, Network)
         {
             HttpClient = HttpClient
         }
                 : null;
         return(new PtarmiganLightningClient(connectionString.BaseUri, connectionString.ApiToken, Network, rpcClient, HttpClient));
     }
     else
     {
         throw new NotSupportedException(
                   $"Unsupported connection string for lightning server ({connectionString.ConnectionType})");
     }
 }