mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
Parsing of node info and returning it for GetInfo
This commit is contained in:
parent
cfd083bed5
commit
9b540273fc
2 changed files with 18 additions and 7 deletions
|
@ -493,14 +493,14 @@ namespace BTCPayServer.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CanSendLightningPaymentLnd()
|
public void CanSendLightningPaymentLnd()
|
||||||
{
|
{
|
||||||
// For easier debugging and testing
|
|
||||||
LightningLikePaymentHandler.LIGHTNING_TIMEOUT = int.MaxValue;
|
|
||||||
|
|
||||||
ProcessLightningPayment(LightningConnectionType.Lnd);
|
ProcessLightningPayment(LightningConnectionType.Lnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessLightningPayment(LightningConnectionType type)
|
void ProcessLightningPayment(LightningConnectionType type)
|
||||||
{
|
{
|
||||||
|
// For easier debugging and testing
|
||||||
|
LightningLikePaymentHandler.LIGHTNING_TIMEOUT = int.MaxValue;
|
||||||
|
|
||||||
using (var tester = ServerTester.Create())
|
using (var tester = ServerTester.Create())
|
||||||
{
|
{
|
||||||
tester.Start();
|
tester.Start();
|
||||||
|
|
|
@ -57,10 +57,16 @@ namespace BTCPayServer.Payments.Lightning.Lnd
|
||||||
NodeId = resp.Identity_pubkey
|
NodeId = resp.Identity_pubkey
|
||||||
};
|
};
|
||||||
|
|
||||||
// Lnd doesn't return this data as Clightning, find alternative ways to supply
|
|
||||||
// it always should be merchant_lnd:9735 because of docker
|
var node = await _rpcClient.GetNodeInfoAsync(resp.Identity_pubkey, cancellation);
|
||||||
nodeInfo.Address = null;
|
if (node.Node.Addresses == null || node.Node.Addresses.Count == 0)
|
||||||
nodeInfo.P2PPort = 9735;
|
throw new Exception("Lnd External IP not set, make sure you use --externalip=$EXTERNALIP parameter on lnd");
|
||||||
|
|
||||||
|
var firstNodeInfo = node.Node.Addresses.First();
|
||||||
|
var externalHostPort = firstNodeInfo.Addr.Split(':');
|
||||||
|
|
||||||
|
nodeInfo.Address = externalHostPort[0];
|
||||||
|
nodeInfo.P2PPort = ConvertInv.ToInt32(externalHostPort[1]);
|
||||||
|
|
||||||
return nodeInfo;
|
return nodeInfo;
|
||||||
}
|
}
|
||||||
|
@ -129,6 +135,11 @@ namespace BTCPayServer.Payments.Lightning.Lnd
|
||||||
// Invariant culture conversion
|
// Invariant culture conversion
|
||||||
public static class ConvertInv
|
public static class ConvertInv
|
||||||
{
|
{
|
||||||
|
public static int ToInt32(string str)
|
||||||
|
{
|
||||||
|
return Convert.ToInt32(str, CultureInfo.InvariantCulture.NumberFormat);
|
||||||
|
}
|
||||||
|
|
||||||
public static long ToInt64(string str)
|
public static long ToInt64(string str)
|
||||||
{
|
{
|
||||||
return Convert.ToInt64(str, CultureInfo.InvariantCulture.NumberFormat);
|
return Convert.ToInt64(str, CultureInfo.InvariantCulture.NumberFormat);
|
||||||
|
|
Loading…
Add table
Reference in a new issue