From 030cb09af84c4d83d5f3f5dfd325ca175cd50f46 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Wed, 28 Feb 2018 22:56:12 +0900 Subject: [PATCH] Fix bug of address parsing for lightning --- BTCPayServer/BTCPayServer.csproj | 2 +- .../Payments/Lightning/CLightning/GetInfoResponse.cs | 9 ++++++++- .../Payments/Lightning/LightningLikePaymentHandler.cs | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 9b5713ff4..eb701b718 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.1.39 + 1.0.1.40 NU1701,CA1816,CA1308,CA1810,CA2208 diff --git a/BTCPayServer/Payments/Lightning/CLightning/GetInfoResponse.cs b/BTCPayServer/Payments/Lightning/CLightning/GetInfoResponse.cs index 45f16abc6..a02a236ec 100644 --- a/BTCPayServer/Payments/Lightning/CLightning/GetInfoResponse.cs +++ b/BTCPayServer/Payments/Lightning/CLightning/GetInfoResponse.cs @@ -5,11 +5,18 @@ using System.Threading.Tasks; namespace BTCPayServer.Payments.Lightning.CLightning { + //[{"type":"ipv4","address":"52.166.90.122","port":9735}] public class GetInfoResponse { + public class GetInfoAddress + { + public string Type { get; set; } + public string Address { get; set; } + public int Port { get; set; } + } public string Id { get; set; } public int Port { get; set; } - public string[] Address { get; set; } + public GetInfoAddress[] Address { get; set; } public string Version { get; set; } public int BlockHeight { get; set; } public string Network { get; set; } diff --git a/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs b/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs index 5ba66888f..d632c7b45 100644 --- a/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs +++ b/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs @@ -64,7 +64,7 @@ namespace BTCPayServer.Payments.Lightning { throw new Exception($"Error while connecting to the lightning charge {client.Uri} ({ex.Message})"); } - var address = info.Address?.FirstOrDefault(); + var address = info.Address.Select(a=>a.Address).FirstOrDefault(); var port = info.Port; address = address ?? client.Uri.DnsSafeHost;