mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Show Lightning node availability in navigation (#5951)
* Show Lightning node availability in navigation Instead of simply communicating the setup state of the store's LN node, this now also checks its availability. Closes #5940. * Cleanups * Add Selenium test for public node page and status in nav * Cache the available lightning node result --------- Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Abstractions.Constants;
|
||||
using BTCPayServer.Client;
|
||||
@@ -15,6 +18,7 @@ using BTCPayServer.Payments.Lightning;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NBitcoin;
|
||||
using NBitcoin.DataEncoders;
|
||||
|
||||
namespace BTCPayServer.Controllers;
|
||||
|
||||
@@ -161,10 +165,19 @@ public partial class UIStoresController
|
||||
CryptoCode = lnNetwork.CryptoCode,
|
||||
PaymentMethodId = handler.PaymentMethodId,
|
||||
Address = lightning?.GetDisplayableConnectionString(),
|
||||
Enabled = isEnabled
|
||||
});
|
||||
Enabled = isEnabled,
|
||||
CacheKey = GetCacheKey(lightning)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string? GetCacheKey(LightningPaymentMethodConfig? lightning)
|
||||
{
|
||||
if (lightning is null)
|
||||
return null;
|
||||
var connStr = lightning.IsInternalNode ? lightning.InternalNodeRef : lightning.ConnectionString;
|
||||
connStr ??= string.Empty;
|
||||
return "LN-INFO-" + Encoders.Hex.EncodeData(SHA256.HashData(Encoding.UTF8.GetBytes(connStr))[0..4]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user