mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 13:26:47 +01:00
Lightning: Fix connection display name in LN settings (#5569)
* Lightning: Fix connection display name in LN settings Builds on btcpayserver/BTCPayServer.Lightning#153. * Upgrade Lightning lib
This commit is contained in:
parent
93ab219124
commit
5114a3a2ea
@ -94,20 +94,21 @@ namespace BTCPayServer
|
||||
public static string GetDisplayName(this ILightningClient client)
|
||||
{
|
||||
LightningConnectionStringHelper.ExtractValues(client.ToString(), out var type);
|
||||
|
||||
var field = typeof(LightningConnectionType).GetField(type, BindingFlags.Public | BindingFlags.Static);
|
||||
|
||||
var lncType = typeof(LightningConnectionType);
|
||||
var fields = lncType.GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
var field = fields.FirstOrDefault(f => f.GetValue(lncType)?.ToString() == type);
|
||||
if (field == null) return type;
|
||||
DisplayAttribute attr = field.GetCustomAttribute<DisplayAttribute>();
|
||||
return attr?.Name ?? type;
|
||||
|
||||
}
|
||||
|
||||
public static bool IsSafe(this ILightningClient connectionString)
|
||||
public static bool IsSafe(this ILightningClient client)
|
||||
{
|
||||
var kv = LightningConnectionStringHelper.ExtractValues(connectionString.ToString(), out var type);
|
||||
if (kv.TryGetValue("cookiefilepath", out var cookieFilePath) ||
|
||||
kv.TryGetValue("macaroondirectorypath", out var macaroonDirectoryPath) ||
|
||||
kv.TryGetValue("macaroonfilepath", out var macaroonFilePath) )
|
||||
var kv = LightningConnectionStringHelper.ExtractValues(client.ToString(), out var type);
|
||||
if (kv.TryGetValue("cookiefilepath", out _) ||
|
||||
kv.TryGetValue("macaroondirectorypath", out _) ||
|
||||
kv.TryGetValue("macaroonfilepath", out _) )
|
||||
return false;
|
||||
|
||||
if (!kv.TryGetValue("server", out var server))
|
||||
@ -117,7 +118,7 @@ namespace BTCPayServer
|
||||
var uri = new Uri(server, UriKind.Absolute);
|
||||
if (uri.Scheme.Equals("unix", StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
if (!Utils.TryParseEndpoint(uri.DnsSafeHost, 80, out var endpoint))
|
||||
if (!Utils.TryParseEndpoint(uri.DnsSafeHost, 80, out _))
|
||||
return false;
|
||||
return !IsLocalNetwork(uri.DnsSafeHost);
|
||||
}
|
||||
|
@ -30,11 +30,11 @@ namespace BTCPayServer.Payments.Lightning
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
|
||||
public void SetLightningUrl(ILightningClient connectionString)
|
||||
public void SetLightningUrl(ILightningClient client)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(connectionString);
|
||||
ArgumentNullException.ThrowIfNull(client);
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
LightningConnectionString = connectionString.ToString();
|
||||
LightningConnectionString = client.ToString();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
@try
|
||||
{
|
||||
var client = LightningClientFactoryService.Create(Model.ConnectionString, NetworkProvider.GetNetwork<BTCPayNetwork>(Model.CryptoCode));
|
||||
client.GetDisplayName();
|
||||
<span>@client.GetDisplayName()</span>
|
||||
var uri = client.GetServerUri();
|
||||
if (uri is not null)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@
|
||||
@try
|
||||
{
|
||||
var client = LightningClientFactoryService.Create(Model.ConnectionString, NetworkProvider.GetNetwork<BTCPayNetwork>(Model.CryptoCode));
|
||||
client.GetDisplayName();
|
||||
<span>@client.GetDisplayName()</span>
|
||||
var uri = client.GetServerUri();
|
||||
if (uri is not null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user