2021-10-18 05:37:59 +02:00
|
|
|
using BTCPayServer.Configuration;
|
|
|
|
using BTCPayServer.Lightning;
|
|
|
|
using BTCPayServer.Services;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Payments.Lightning
|
|
|
|
{
|
2021-12-31 16:59:02 +09:00
|
|
|
public static class LightningExtensions
|
2021-10-18 05:37:59 +02:00
|
|
|
{
|
|
|
|
|
2021-12-31 16:59:02 +09:00
|
|
|
|
|
|
|
public static ILightningClient CreateLightningClient(this LightningSupportedPaymentMethod supportedPaymentMethod, BTCPayNetwork network, LightningNetworkOptions options, LightningClientFactoryService lightningClientFactory)
|
2021-10-18 05:37:59 +02:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|