mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-12 02:08:32 +01:00
Show the NodeInfo when testing connection
This commit is contained in:
parent
718a36ddd0
commit
ae7cfe90ab
7 changed files with 14 additions and 5 deletions
|
@ -2,7 +2,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
<Version>1.0.1.55</Version>
|
<Version>1.0.1.56</Version>
|
||||||
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
|
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -125,14 +125,14 @@ namespace BTCPayServer.Controllers
|
||||||
var handler = (LightningLikePaymentHandler)_ServiceProvider.GetRequiredService<IPaymentMethodHandler<Payments.Lightning.LightningSupportedPaymentMethod>>();
|
var handler = (LightningLikePaymentHandler)_ServiceProvider.GetRequiredService<IPaymentMethodHandler<Payments.Lightning.LightningSupportedPaymentMethod>>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await handler.Test(paymentMethod, network);
|
var info = await handler.Test(paymentMethod, network);
|
||||||
|
vm.StatusMessage = $"Connection to the lightning node succeed ({info})";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
vm.StatusMessage = $"Error: {ex.Message}";
|
vm.StatusMessage = $"Error: {ex.Message}";
|
||||||
return View(vm);
|
return View(vm);
|
||||||
}
|
}
|
||||||
vm.StatusMessage = "Connection to the lightning node succeed";
|
|
||||||
return View(vm);
|
return View(vm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,7 @@ namespace BTCPayServer.Payments.Lightning.CLightning
|
||||||
var port = info.Port;
|
var port = info.Port;
|
||||||
return new LightningNodeInformation()
|
return new LightningNodeInformation()
|
||||||
{
|
{
|
||||||
|
NodeId = info.Id,
|
||||||
P2PPort = port,
|
P2PPort = port,
|
||||||
Address = address,
|
Address = address,
|
||||||
BlockHeight = info.BlockHeight
|
BlockHeight = info.BlockHeight
|
||||||
|
|
|
@ -20,5 +20,10 @@ namespace BTCPayServer.Payments.Lightning.CLightning
|
||||||
public string NodeId { get; private set; }
|
public string NodeId { get; private set; }
|
||||||
public string Host { get; private set; }
|
public string Host { get; private set; }
|
||||||
public int Port { get; private set; }
|
public int Port { get; private set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{NodeId}:{Host}:{Port}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,6 +163,7 @@ namespace BTCPayServer.Payments.Lightning.Charge
|
||||||
var port = info.Port;
|
var port = info.Port;
|
||||||
return new LightningNodeInformation()
|
return new LightningNodeInformation()
|
||||||
{
|
{
|
||||||
|
NodeId = info.Id,
|
||||||
P2PPort = port,
|
P2PPort = port,
|
||||||
Address = address,
|
Address = address,
|
||||||
BlockHeight = info.BlockHeight
|
BlockHeight = info.BlockHeight
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace BTCPayServer.Payments.Lightning
|
||||||
|
|
||||||
public class LightningNodeInformation
|
public class LightningNodeInformation
|
||||||
{
|
{
|
||||||
|
public string NodeId { get; set; }
|
||||||
public string Address { get; internal set; }
|
public string Address { get; internal set; }
|
||||||
public int P2PPort { get; internal set; }
|
public int P2PPort { get; internal set; }
|
||||||
public int BlockHeight { get; set; }
|
public int BlockHeight { get; set; }
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace BTCPayServer.Payments.Lightning
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool SkipP2PTest { get; set; }
|
public bool SkipP2PTest { get; set; }
|
||||||
|
|
||||||
public async Task Test(LightningSupportedPaymentMethod supportedPaymentMethod, BTCPayNetwork network)
|
public async Task<NodeInfo> Test(LightningSupportedPaymentMethod supportedPaymentMethod, BTCPayNetwork network)
|
||||||
{
|
{
|
||||||
if (!_Dashboard.IsFullySynched(network.CryptoCode, out var summary))
|
if (!_Dashboard.IsFullySynched(network.CryptoCode, out var summary))
|
||||||
throw new Exception($"Full node not available");
|
throw new Exception($"Full node not available");
|
||||||
|
@ -91,6 +91,7 @@ namespace BTCPayServer.Payments.Lightning
|
||||||
{
|
{
|
||||||
throw new Exception($"Error while connecting to the lightning node via {info.Address}:{info.P2PPort} ({ex.Message})");
|
throw new Exception($"Error while connecting to the lightning node via {info.Address}:{info.P2PPort} ({ex.Message})");
|
||||||
}
|
}
|
||||||
|
return new NodeInfo(info.NodeId, info.Address, info.P2PPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> TestConnection(string addressStr, int port, CancellationToken cancellation)
|
private async Task<bool> TestConnection(string addressStr, int port, CancellationToken cancellation)
|
||||||
|
|
Loading…
Add table
Reference in a new issue