Fix bug of address parsing for lightning

This commit is contained in:
nicolas.dorier 2018-02-28 22:56:12 +09:00
parent 9f734349da
commit 030cb09af8
3 changed files with 10 additions and 3 deletions

View file

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<Version>1.0.1.39</Version> <Version>1.0.1.40</Version>
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn> <NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View file

@ -5,11 +5,18 @@ using System.Threading.Tasks;
namespace BTCPayServer.Payments.Lightning.CLightning namespace BTCPayServer.Payments.Lightning.CLightning
{ {
//[{"type":"ipv4","address":"52.166.90.122","port":9735}]
public class GetInfoResponse 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 string Id { get; set; }
public int Port { get; set; } public int Port { get; set; }
public string[] Address { get; set; } public GetInfoAddress[] Address { get; set; }
public string Version { get; set; } public string Version { get; set; }
public int BlockHeight { get; set; } public int BlockHeight { get; set; }
public string Network { get; set; } public string Network { get; set; }

View file

@ -64,7 +64,7 @@ namespace BTCPayServer.Payments.Lightning
{ {
throw new Exception($"Error while connecting to the lightning charge {client.Uri} ({ex.Message})"); 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; var port = info.Port;
address = address ?? client.Uri.DnsSafeHost; address = address ?? client.Uri.DnsSafeHost;