mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 02:28:31 +01:00
27 lines
1002 B
C#
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);
|
|
}
|
|
}
|
|
}
|
|
}
|