mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Do not throw when local node is not synced and using external ln node (#5859)
* Do not throw when local node is not synced and using external ln node * Fix additional bug when ln conn strings without server would crash
This commit is contained in:
parent
6b0087ab69
commit
6b45eb0d3d
2 changed files with 16 additions and 6 deletions
|
@ -132,7 +132,7 @@ namespace BTCPayServer.Payments.Lightning
|
|||
// 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
|
||||
{
|
||||
|
@ -163,11 +163,14 @@ namespace BTCPayServer.Payments.Lightning
|
|||
? 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 && !(isLndHub && info.BlockHeight == 0))
|
||||
if (summary.Status is not null)
|
||||
{
|
||||
throw new PaymentMethodUnavailableException(
|
||||
$"The lightning node is not synched ({blocksGap} blocks left)");
|
||||
var blocksGap = summary.Status.ChainHeight - info.BlockHeight;
|
||||
if (blocksGap > 10 && !(isLndHub && info.BlockHeight == 0))
|
||||
{
|
||||
throw new PaymentMethodUnavailableException(
|
||||
$"The lightning node is not synched ({blocksGap} blocks left)");
|
||||
}
|
||||
}
|
||||
return nodeInfo;
|
||||
}
|
||||
|
|
|
@ -508,8 +508,15 @@ namespace BTCPayServer.Payments.Lightning
|
|||
try
|
||||
{
|
||||
var lightningClient = _lightningClientFactory.Create(ConnectionString, _network);
|
||||
if(lightningClient is null)
|
||||
return;
|
||||
uri = lightningClient.GetServerUri();
|
||||
logUrl = string.IsNullOrEmpty(uri.UserInfo) ? uri.ToString() : uri.ToString().Replace(uri.UserInfo, "***");
|
||||
logUrl = uri switch
|
||||
{
|
||||
null when LightningConnectionStringHelper.ExtractValues(ConnectionString, out var type) is not null => type,
|
||||
null => string.Empty,
|
||||
_ => string.IsNullOrEmpty(uri.UserInfo) ? uri.ToString() : uri.ToString().Replace(uri.UserInfo, "***")
|
||||
};
|
||||
Logs.PayServer.LogInformation("{CryptoCode} (Lightning): Start listening {Uri}", _network.CryptoCode, logUrl);
|
||||
using var session = await lightningClient.Listen(cancellation);
|
||||
// Just in case the payment arrived after our last poll but before we listened.
|
||||
|
|
Loading…
Add table
Reference in a new issue