mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-10 09:19:24 +01:00
Lightning: Relax GetInfo constraint for LNDhub connections (#5083)
* Lightning: Relax GetInfo constraint for LNDhub connections The LNDhub-compatible implementation by LNbits does not support the `GetInfo` call for all their funding sources — see lnbits/lnbits#1182. By catching that exception in combination with the `LndHubLightningClient`, we give people the ability to still use their LNbits-based LNDhub as a Lightning node. Fixes #4482. * Update approach to handling unsupported GetInfo calls
This commit is contained in:
parent
b31dc30878
commit
0d0477d661
2 changed files with 14 additions and 4 deletions
|
@ -48,7 +48,7 @@
|
||||||
<PackageReference Include="YamlDotNet" Version="8.0.0" />
|
<PackageReference Include="YamlDotNet" Version="8.0.0" />
|
||||||
<PackageReference Include="BIP78.Sender" Version="0.2.2" />
|
<PackageReference Include="BIP78.Sender" Version="0.2.2" />
|
||||||
<PackageReference Include="BTCPayServer.Hwi" Version="2.0.2" />
|
<PackageReference Include="BTCPayServer.Hwi" Version="2.0.2" />
|
||||||
<PackageReference Include="BTCPayServer.Lightning.All" Version="1.4.26" />
|
<PackageReference Include="BTCPayServer.Lightning.All" Version="1.4.27" />
|
||||||
<PackageReference Include="CsvHelper" Version="15.0.5" />
|
<PackageReference Include="CsvHelper" Version="15.0.5" />
|
||||||
<PackageReference Include="Dapper" Version="2.0.123" />
|
<PackageReference Include="Dapper" Version="2.0.123" />
|
||||||
<PackageReference Include="Fido2" Version="2.0.2" />
|
<PackageReference Include="Fido2" Version="2.0.2" />
|
||||||
|
|
|
@ -9,6 +9,7 @@ using BTCPayServer.Configuration;
|
||||||
using BTCPayServer.Data;
|
using BTCPayServer.Data;
|
||||||
using BTCPayServer.HostedServices;
|
using BTCPayServer.HostedServices;
|
||||||
using BTCPayServer.Lightning;
|
using BTCPayServer.Lightning;
|
||||||
|
using BTCPayServer.Lightning.LndHub;
|
||||||
using BTCPayServer.Logging;
|
using BTCPayServer.Logging;
|
||||||
using BTCPayServer.Models;
|
using BTCPayServer.Models;
|
||||||
using BTCPayServer.Models.InvoicingModels;
|
using BTCPayServer.Models.InvoicingModels;
|
||||||
|
@ -127,6 +128,11 @@ namespace BTCPayServer.Payments.Lightning
|
||||||
{
|
{
|
||||||
using var cts = new CancellationTokenSource(LightningTimeout);
|
using var cts = new CancellationTokenSource(LightningTimeout);
|
||||||
var client = CreateLightningClient(supportedPaymentMethod, network);
|
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;
|
LightningNodeInformation info;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -136,6 +142,10 @@ namespace BTCPayServer.Payments.Lightning
|
||||||
{
|
{
|
||||||
throw new PaymentMethodUnavailableException("The lightning node did not reply in a timely manner");
|
throw new PaymentMethodUnavailableException("The lightning node did not reply in a timely manner");
|
||||||
}
|
}
|
||||||
|
catch (NotSupportedException) when (isLndHub)
|
||||||
|
{
|
||||||
|
return new NodeInfo[] {};
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new PaymentMethodUnavailableException($"Error while connecting to the API: {ex.Message}" +
|
throw new PaymentMethodUnavailableException($"Error while connecting to the API: {ex.Message}" +
|
||||||
|
@ -148,7 +158,7 @@ namespace BTCPayServer.Payments.Lightning
|
||||||
: info.NodeInfoList.Select(i => i).ToArray();
|
: info.NodeInfoList.Select(i => i).ToArray();
|
||||||
|
|
||||||
var blocksGap = summary.Status.ChainHeight - info.BlockHeight;
|
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)");
|
throw new PaymentMethodUnavailableException($"The lightning node is not synched ({blocksGap} blocks left)");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue