mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 18:11:36 +01:00
29 lines
1001 B
C#
29 lines
1001 B
C#
using System;
|
|
using System.Net.Http;
|
|
using BTCPayServer.Lightning;
|
|
|
|
namespace BTCPayServer.Services
|
|
{
|
|
public class LightningClientFactoryService
|
|
{
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
|
|
public LightningClientFactoryService(IHttpClientFactory httpClientFactory)
|
|
{
|
|
_httpClientFactory = httpClientFactory;
|
|
}
|
|
|
|
public ILightningClient Create(LightningConnectionString lightningConnectionString, BTCPayNetwork network)
|
|
{
|
|
if (lightningConnectionString == null)
|
|
throw new ArgumentNullException(nameof(lightningConnectionString));
|
|
if (network == null)
|
|
throw new ArgumentNullException(nameof(network));
|
|
return new Lightning.LightningClientFactory(network.NBitcoinNetwork)
|
|
{
|
|
HttpClient = _httpClientFactory.CreateClient($"{network.CryptoCode}: Lightning client")
|
|
}.Create(lightningConnectionString);
|
|
}
|
|
}
|
|
}
|