diff --git a/BTCPayApp.Core/LDK/LDKExtensions.cs b/BTCPayApp.Core/LDK/LDKExtensions.cs index a603c50..4bfb293 100644 --- a/BTCPayApp.Core/LDK/LDKExtensions.cs +++ b/BTCPayApp.Core/LDK/LDKExtensions.cs @@ -307,7 +307,7 @@ public static class LDKExtensions provider.GetRequiredService(), ProbabilisticScoringFeeParameters.with_default())); services.AddScoped(provider => provider.GetRequiredService().as_Router()); - services.AddScoped(); + //services.AddScoped(); services.AddScoped(); //services.AddScoped(provider => provider.GetRequiredService()); services.AddScoped(provider => provider.GetRequiredService()); diff --git a/BTCPayApp.Core/LDK/PaymentsManager.cs b/BTCPayApp.Core/LDK/PaymentsManager.cs index fd09288..8ac3660 100644 --- a/BTCPayApp.Core/LDK/PaymentsManager.cs +++ b/BTCPayApp.Core/LDK/PaymentsManager.cs @@ -358,7 +358,7 @@ public class PaymentsManager : _channelManager.claim_funds(preimage); return; } - if (accept.AdditionalData.TryGetValue(VoltageFlow2Jit.LightningPaymentLSPKey, out var lspDoc) && + if (accept.AdditionalData.TryGetValue(Flow2Jit.LightningPaymentLSPKey, out var lspDoc) && lspDoc.Deserialize() is { } lsp && await _ldkNode.GetJITLSPService() is { } lspService && lspService.ProviderName == lsp && await lspService.IsAcceptable(accept!, eventPaymentClaimable)) diff --git a/BTCPayApp.Core/LSP/JIT/VoltageFlow2Jit.cs b/BTCPayApp.Core/LSP/JIT/Flow2Jit.cs similarity index 95% rename from BTCPayApp.Core/LSP/JIT/VoltageFlow2Jit.cs rename to BTCPayApp.Core/LSP/JIT/Flow2Jit.cs index 6377160..57ad433 100644 --- a/BTCPayApp.Core/LSP/JIT/VoltageFlow2Jit.cs +++ b/BTCPayApp.Core/LSP/JIT/Flow2Jit.cs @@ -14,9 +14,10 @@ using JsonSerializer = System.Text.Json.JsonSerializer; namespace BTCPayApp.Core.LSP.JIT; /// -/// https://docs.voltage.cloud/flow/flow-2.0 +/// https://www.voltage.cloud/blog/introducing-flow-v2 +/// https://www.voltage.cloud/blog/deprecating-flow-2-0---paving-the-way-for-a-superior-solution /// -public class VoltageFlow2Jit : IJITService, IScopedHostedService, ILDKEventHandler +public abstract class Flow2Jit : IJITService, IScopedHostedService, ILDKEventHandler { private const string LightningPaymentOriginalPaymentRequest = "OriginalPaymentRequest"; private const string LightningPaymentJITFeeKey = "JITFeeKey"; @@ -26,37 +27,20 @@ public class VoltageFlow2Jit : IJITService, IScopedHostedService, ILDKEventHandl private readonly Network _network; private readonly LDKNode _node; private readonly ChannelManager _channelManager; - private readonly ILogger _logger; + private readonly ILogger _logger; private readonly LDKOpenChannelRequestEventHandler _openChannelRequestEventHandler; private CancellationTokenSource _cts = new(); private readonly ConcurrentDictionary _acceptedChannels = new(); public bool Active { get; } - public virtual string ProviderName => "Voltage"; + public virtual string ProviderName => "Abstract Flow 2.0 Provider"; protected virtual LightMoney NonChannelOpenFee => LightMoney.Zero; private FlowInfoResponse? _info; - - public VoltageFlow2Jit(bool active) - { - Active = active; - } - private readonly SemaphoreSlim _semaphore = new(1, 1); - protected virtual Uri? BaseAddress(Network network) - { - return network switch - { - not null when network == Network.Main => new Uri("https://lsp.voltageapi.com"), - not null when network == Network.TestNet => new Uri("https://testnet-lsp.voltageapi.com"), - // not null when network == Network.RegTest => new Uri("https://localhost:5001/jit-lsp"), - _ => null - }; - } - - public VoltageFlow2Jit(IHttpClientFactory httpClientFactory, Network network, LDKNode node, - ChannelManager channelManager, ILogger logger, + protected Flow2Jit(IHttpClientFactory httpClientFactory, Network network, LDKNode node, + ChannelManager channelManager, ILogger logger, LDKOpenChannelRequestEventHandler openChannelRequestEventHandler) { var httpClientInstance = httpClientFactory.CreateClient("VoltageFlow2JIT"); @@ -71,6 +55,17 @@ public class VoltageFlow2Jit : IJITService, IScopedHostedService, ILDKEventHandl _openChannelRequestEventHandler = openChannelRequestEventHandler; } + protected virtual Uri? BaseAddress(Network network) + { + return network switch + { + not null when network == Network.Main => new Uri("https://lsp.voltageapi.com"), + not null when network == Network.TestNet => new Uri("https://testnet-lsp.voltageapi.com"), + // not null when network == Network.RegTest => new Uri("https://localhost:5001/jit-lsp"), + _ => null + }; + } + private async Task GetInfo(CancellationToken cancellationToken = default) { const string path = "/api/v1/info"; diff --git a/BTCPayApp.Core/LSP/JIT/OlympusFlow2Jit.cs b/BTCPayApp.Core/LSP/JIT/OlympusFlow2Jit.cs index ce1353a..f469601 100644 --- a/BTCPayApp.Core/LSP/JIT/OlympusFlow2Jit.cs +++ b/BTCPayApp.Core/LSP/JIT/OlympusFlow2Jit.cs @@ -6,14 +6,17 @@ using org.ldk.structs; namespace BTCPayApp.Core.LSP.JIT; +/// +/// https://docs.zeusln.app/lsp/services/flow +/// public class OlympusFlow2Jit( IHttpClientFactory httpClientFactory, Network network, LDKNode node, ChannelManager channelManager, - ILogger logger, + ILogger logger, LDKOpenChannelRequestEventHandler openChannelRequestEventHandler) - : VoltageFlow2Jit(httpClientFactory, network, node, channelManager, logger, openChannelRequestEventHandler) + : Flow2Jit(httpClientFactory, network, node, channelManager, logger, openChannelRequestEventHandler) { protected override Uri? BaseAddress(Network network) {