diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj
index 0ced6931a..f88d55907 100644
--- a/BTCPayServer/BTCPayServer.csproj
+++ b/BTCPayServer/BTCPayServer.csproj
@@ -31,10 +31,10 @@
-
+
-
+
diff --git a/BTCPayServer/ExplorerClientProvider.cs b/BTCPayServer/ExplorerClientProvider.cs
index b377ac84b..8b546189d 100644
--- a/BTCPayServer/ExplorerClientProvider.cs
+++ b/BTCPayServer/ExplorerClientProvider.cs
@@ -77,7 +77,7 @@ namespace BTCPayServer
public bool IsAvailable(string cryptoCode)
{
- return _Clients.ContainsKey(cryptoCode) && _Dashboard.IsFullySynched(cryptoCode);
+ return _Clients.ContainsKey(cryptoCode) && _Dashboard.IsFullySynched(cryptoCode, out var unused);
}
public BTCPayNetwork GetNetwork(string cryptoCode)
diff --git a/BTCPayServer/HostedServices/NBXplorerWaiter.cs b/BTCPayServer/HostedServices/NBXplorerWaiter.cs
index 7aaf2a391..f66b544d6 100644
--- a/BTCPayServer/HostedServices/NBXplorerWaiter.cs
+++ b/BTCPayServer/HostedServices/NBXplorerWaiter.cs
@@ -41,9 +41,11 @@ namespace BTCPayServer.HostedServices
return _Summaries.All(s => s.Value.Status != null && s.Value.Status.IsFullySynched);
}
- public bool IsFullySynched(string cryptoCode)
+ public bool IsFullySynched(string cryptoCode, out NBXplorerSummary summary)
{
- return _Summaries.Any(s => s.Key.Equals(cryptoCode, StringComparison.OrdinalIgnoreCase) && s.Value.Status != null && s.Value.Status.IsFullySynched);
+ return _Summaries.TryGetValue(cryptoCode, out summary) &&
+ summary.Status != null &&
+ summary.Status.IsFullySynched;
}
public IEnumerable GetAll()
diff --git a/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs b/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs
index 5d0cad131..61bc332a4 100644
--- a/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs
+++ b/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs
@@ -5,6 +5,7 @@ using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
+using BTCPayServer.HostedServices;
using BTCPayServer.Payments.Lightning.CLightning;
using BTCPayServer.Services.Invoices;
@@ -12,10 +13,10 @@ namespace BTCPayServer.Payments.Lightning
{
public class LightningLikePaymentHandler : PaymentMethodHandlerBase
{
- ExplorerClientProvider _ExplorerClientProvider;
- public LightningLikePaymentHandler(ExplorerClientProvider explorerClientProvider)
+ NBXplorerDashboard _Dashboard;
+ public LightningLikePaymentHandler(NBXplorerDashboard dashboard)
{
- _ExplorerClientProvider = explorerClientProvider;
+ _Dashboard = dashboard;
}
public override async Task CreatePaymentMethodDetails(LightningSupportedPaymentMethod supportedPaymentMethod, PaymentMethod paymentMethod, BTCPayNetwork network)
{
@@ -47,13 +48,12 @@ namespace BTCPayServer.Payments.Lightning
public async Task Test(LightningSupportedPaymentMethod supportedPaymentMethod, BTCPayNetwork network)
{
- if (!_ExplorerClientProvider.IsAvailable(network))
+ if (!_Dashboard.IsFullySynched(network.CryptoCode, out var summary))
throw new Exception($"Full node not available");
- var explorerClient = _ExplorerClientProvider.GetExplorerClient(network);
+
var cts = new CancellationTokenSource(5000);
var client = GetClient(supportedPaymentMethod, network);
- var status = explorerClient.GetStatusAsync();
GetInfoResponse info = null;
try
{
@@ -73,7 +73,7 @@ namespace BTCPayServer.Payments.Lightning
throw new Exception($"Lightning node network {info.Network}, but expected is {network.CLightningNetworkName}");
}
- var blocksGap = Math.Abs(info.BlockHeight - (await status).ChainHeight);
+ var blocksGap = Math.Abs(info.BlockHeight - summary.Status.ChainHeight);
if (blocksGap > 10)
{
throw new Exception($"The lightning is not synched ({blocksGap} blocks)");