btcpayserver/BTCPayServer/Payments/Lightning/LightningExtensions.cs
Andrew Camilleri 2f23bad3bc
Support the new LN lib (#5422)
* Support the new LN lib

* fix test

* do not cache factories

* try without useless userinfo in lnd

* Remove monero wallet files

* support simpler DI too

---------

Co-authored-by: Dennis Reimann <mail@dennisreimann.de>
2023-11-21 18:55:02 +09:00

26 lines
962 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 connectionString;
}
}
}
}