btcpayserver/BTCPayServer/Payments/Lightning/LightningExtensions.cs
2021-12-31 16:59:02 +09:00

27 lines
1002 B
C#

using BTCPayServer.Configuration;
using BTCPayServer.Lightning;
using BTCPayServer.Services;
namespace BTCPayServer.Payments.Lightning
{
public static class LightningExtensions
{
public static ILightningClient CreateLightningClient(this LightningSupportedPaymentMethod supportedPaymentMethod, BTCPayNetwork network, LightningNetworkOptions options, LightningClientFactoryService lightningClientFactory)
{
var external = supportedPaymentMethod.GetExternalLightningUrl();
if (external != null)
{
return lightningClientFactory.Create(external, network);
}
else
{
if (!options.InternalLightningByCryptoCode.TryGetValue(network.CryptoCode, out var connectionString))
throw new PaymentMethodUnavailableException("No internal node configured");
return lightningClientFactory.Create(connectionString, network);
}
}
}
}