From ae7cfe90abe8f0dd5bcfedbea53121a72275dd5d Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 22 Mar 2018 12:02:38 +0900 Subject: [PATCH] Show the NodeInfo when testing connection --- BTCPayServer/BTCPayServer.csproj | 2 +- BTCPayServer/Controllers/StoresController.LightningLike.cs | 6 +++--- .../Payments/Lightning/CLightning/CLightningRPCClient.cs | 1 + BTCPayServer/Payments/Lightning/CLightning/NodeInfo.cs | 5 +++++ BTCPayServer/Payments/Lightning/Charge/ChargeClient.cs | 1 + BTCPayServer/Payments/Lightning/ILightningInvoiceClient.cs | 1 + .../Payments/Lightning/LightningLikePaymentHandler.cs | 3 ++- 7 files changed, 14 insertions(+), 5 deletions(-) diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index fe4728c07..0a252e868 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.1.55 + 1.0.1.56 NU1701,CA1816,CA1308,CA1810,CA2208 diff --git a/BTCPayServer/Controllers/StoresController.LightningLike.cs b/BTCPayServer/Controllers/StoresController.LightningLike.cs index 4f3defaa0..fed781576 100644 --- a/BTCPayServer/Controllers/StoresController.LightningLike.cs +++ b/BTCPayServer/Controllers/StoresController.LightningLike.cs @@ -125,14 +125,14 @@ namespace BTCPayServer.Controllers var handler = (LightningLikePaymentHandler)_ServiceProvider.GetRequiredService>(); 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) { vm.StatusMessage = $"Error: {ex.Message}"; return View(vm); - } - vm.StatusMessage = "Connection to the lightning node succeed"; + } return View(vm); } } diff --git a/BTCPayServer/Payments/Lightning/CLightning/CLightningRPCClient.cs b/BTCPayServer/Payments/Lightning/CLightning/CLightningRPCClient.cs index 44e0b52a2..a9ad78053 100644 --- a/BTCPayServer/Payments/Lightning/CLightning/CLightningRPCClient.cs +++ b/BTCPayServer/Payments/Lightning/CLightning/CLightningRPCClient.cs @@ -216,6 +216,7 @@ namespace BTCPayServer.Payments.Lightning.CLightning var port = info.Port; return new LightningNodeInformation() { + NodeId = info.Id, P2PPort = port, Address = address, BlockHeight = info.BlockHeight diff --git a/BTCPayServer/Payments/Lightning/CLightning/NodeInfo.cs b/BTCPayServer/Payments/Lightning/CLightning/NodeInfo.cs index 87e5f4184..6eb75b3d1 100644 --- a/BTCPayServer/Payments/Lightning/CLightning/NodeInfo.cs +++ b/BTCPayServer/Payments/Lightning/CLightning/NodeInfo.cs @@ -20,5 +20,10 @@ namespace BTCPayServer.Payments.Lightning.CLightning public string NodeId { get; private set; } public string Host { get; private set; } public int Port { get; private set; } + + public override string ToString() + { + return $"{NodeId}:{Host}:{Port}"; + } } } diff --git a/BTCPayServer/Payments/Lightning/Charge/ChargeClient.cs b/BTCPayServer/Payments/Lightning/Charge/ChargeClient.cs index 0c1062736..d40c3bb8f 100644 --- a/BTCPayServer/Payments/Lightning/Charge/ChargeClient.cs +++ b/BTCPayServer/Payments/Lightning/Charge/ChargeClient.cs @@ -163,6 +163,7 @@ namespace BTCPayServer.Payments.Lightning.Charge var port = info.Port; return new LightningNodeInformation() { + NodeId = info.Id, P2PPort = port, Address = address, BlockHeight = info.BlockHeight diff --git a/BTCPayServer/Payments/Lightning/ILightningInvoiceClient.cs b/BTCPayServer/Payments/Lightning/ILightningInvoiceClient.cs index b95769d99..b036c68c6 100644 --- a/BTCPayServer/Payments/Lightning/ILightningInvoiceClient.cs +++ b/BTCPayServer/Payments/Lightning/ILightningInvoiceClient.cs @@ -21,6 +21,7 @@ namespace BTCPayServer.Payments.Lightning public class LightningNodeInformation { + public string NodeId { get; set; } public string Address { get; internal set; } public int P2PPort { get; internal set; } public int BlockHeight { get; set; } diff --git a/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs b/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs index a73e75d5a..fbfd4346d 100644 --- a/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs +++ b/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs @@ -54,7 +54,7 @@ namespace BTCPayServer.Payments.Lightning /// public bool SkipP2PTest { get; set; } - public async Task Test(LightningSupportedPaymentMethod supportedPaymentMethod, BTCPayNetwork network) + public async Task Test(LightningSupportedPaymentMethod supportedPaymentMethod, BTCPayNetwork network) { if (!_Dashboard.IsFullySynched(network.CryptoCode, out var summary)) 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})"); } + return new NodeInfo(info.NodeId, info.Address, info.P2PPort); } private async Task TestConnection(string addressStr, int port, CancellationToken cancellation)