mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Lightning: Better handling for non-public nodes (#4263)
Fixes #4246. `LightningLikePaymentHandler.GetNodeInfo` needed the `throws` argument to handle the cases as previously, otherwise the catch case in `ShowLightningNodeInfo` never occured. State with this PR: A node can be available, but not have any public addresses. The latter will now be reported when testing the connection and on the public node info page.
This commit is contained in:
@@ -194,12 +194,15 @@ namespace BTCPayServer.Controllers
|
||||
try
|
||||
{
|
||||
var info = await handler.GetNodeInfo(paymentMethod, network, new InvoiceLogs(), Request.IsOnion(), true);
|
||||
if (!vm.SkipPortTest)
|
||||
var hasPublicAddress = info.Any();
|
||||
if (!vm.SkipPortTest && hasPublicAddress)
|
||||
{
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(20));
|
||||
await handler.TestConnection(info.First(), cts.Token);
|
||||
}
|
||||
TempData[WellKnownTempData.SuccessMessage] = $"Connection to the Lightning node successful. Your node address: {info.First()}";
|
||||
TempData[WellKnownTempData.SuccessMessage] = "Connection to the Lightning node successful" + (hasPublicAddress
|
||||
? $". Your node address: {info.First()}"
|
||||
: ", but no public address has been configured");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -225,7 +228,7 @@ namespace BTCPayServer.Controllers
|
||||
var lightning = GetExistingLightningSupportedPaymentMethod(cryptoCode, store);
|
||||
if (lightning == null)
|
||||
{
|
||||
TempData[WellKnownTempData.ErrorMessage] = $"You need to connect to a Lightning node before adjusting its settings.";
|
||||
TempData[WellKnownTempData.ErrorMessage] = "You need to connect to a Lightning node before adjusting its settings.";
|
||||
|
||||
return RedirectToAction(nameof(SetupLightningNode), new { storeId, cryptoCode });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user