diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 347d60944..e6d131559 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -48,7 +48,7 @@ - + diff --git a/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs b/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs index 3d9fee8c8..7c2252301 100644 --- a/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs +++ b/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs @@ -9,6 +9,7 @@ using BTCPayServer.Configuration; using BTCPayServer.Data; using BTCPayServer.HostedServices; using BTCPayServer.Lightning; +using BTCPayServer.Lightning.LndHub; using BTCPayServer.Logging; using BTCPayServer.Models; using BTCPayServer.Models.InvoicingModels; @@ -122,11 +123,16 @@ namespace BTCPayServer.Payments.Lightning { if (!_Dashboard.IsFullySynched(network.CryptoCode, out var summary)) throw new PaymentMethodUnavailableException("Full node not available"); - + try { using var cts = new CancellationTokenSource(LightningTimeout); var client = CreateLightningClient(supportedPaymentMethod, network); + + // LNDhub-compatible implementations might not offer all of GetInfo data. + // Skip checks in those cases, see https://github.com/lnbits/lnbits/issues/1182 + var isLndHub = client is LndHubLightningClient; + LightningNodeInformation info; try { @@ -136,6 +142,10 @@ namespace BTCPayServer.Payments.Lightning { throw new PaymentMethodUnavailableException("The lightning node did not reply in a timely manner"); } + catch (NotSupportedException) when (isLndHub) + { + return new NodeInfo[] {}; + } catch (Exception ex) { throw new PaymentMethodUnavailableException($"Error while connecting to the API: {ex.Message}" + @@ -146,9 +156,9 @@ namespace BTCPayServer.Payments.Lightning var nodeInfo = preferOnion != null && info.NodeInfoList.Any(i => i.IsTor == preferOnion) ? info.NodeInfoList.Where(i => i.IsTor == preferOnion.Value).ToArray() : info.NodeInfoList.Select(i => i).ToArray(); - + var blocksGap = summary.Status.ChainHeight - info.BlockHeight; - if (blocksGap > 10) + if (blocksGap > 10 && !(isLndHub && info.BlockHeight == 0)) { throw new PaymentMethodUnavailableException($"The lightning node is not synched ({blocksGap} blocks left)"); }