mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Greenfield: Extend LN GetInfo data (#4167)
Matching the data added in btcpayserver/BTCPayServer.Lightning#97.
This commit is contained in:
@@ -9,6 +9,13 @@ namespace BTCPayServer.Client.Models
|
||||
[JsonProperty("nodeURIs", ItemConverterType = typeof(NodeUriJsonConverter))]
|
||||
public NodeInfo[] NodeURIs { get; set; }
|
||||
public int BlockHeight { get; set; }
|
||||
public string Alias { get; set; }
|
||||
public string Color { get; set; }
|
||||
public string Version { get; set; }
|
||||
public long? PeersCount { get; set; }
|
||||
public long? ActiveChannelsCount { get; set; }
|
||||
public long? InactiveChannelsCount { get; set; }
|
||||
public long? PendingChannelsCount { get; set; }
|
||||
}
|
||||
|
||||
public class LightningChannelData
|
||||
|
||||
@@ -1653,11 +1653,11 @@ namespace BTCPayServer.Tests
|
||||
await tester.StartAsync();
|
||||
await tester.EnsureChannelsSetup();
|
||||
var user = tester.NewAccount();
|
||||
user.GrantAccess(true);
|
||||
await user.GrantAccessAsync(true);
|
||||
user.RegisterLightningNode("BTC", LightningConnectionType.CLightning, false);
|
||||
|
||||
var merchant = tester.NewAccount();
|
||||
merchant.GrantAccess(true);
|
||||
await merchant.GrantAccessAsync(true);
|
||||
merchant.RegisterLightningNode("BTC", LightningConnectionType.LndREST);
|
||||
var merchantClient = await merchant.CreateClient($"{Policies.CanUseLightningNodeInStore}:{merchant.StoreId}");
|
||||
var merchantInvoice = await merchantClient.CreateLightningInvoice(merchant.StoreId, "BTC", new CreateLightningInvoiceRequest(LightMoney.Satoshis(1_000), "hey", TimeSpan.FromSeconds(60)));
|
||||
@@ -1667,6 +1667,13 @@ namespace BTCPayServer.Tests
|
||||
var info = await client.GetLightningNodeInfo("BTC");
|
||||
Assert.Single(info.NodeURIs);
|
||||
Assert.NotEqual(0, info.BlockHeight);
|
||||
Assert.NotNull(info.Alias);
|
||||
Assert.NotNull(info.Color);
|
||||
Assert.NotNull(info.Version);
|
||||
Assert.NotNull(info.PeersCount);
|
||||
Assert.NotNull(info.ActiveChannelsCount);
|
||||
Assert.NotNull(info.InactiveChannelsCount);
|
||||
Assert.NotNull(info.PendingChannelsCount);
|
||||
|
||||
await AssertAPIError("lightning-node-unavailable", () => client.GetLightningNodeChannels("BTC"));
|
||||
// Not permission for the store!
|
||||
|
||||
@@ -46,7 +46,14 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
return Ok(new LightningNodeInformationData
|
||||
{
|
||||
BlockHeight = info.BlockHeight,
|
||||
NodeURIs = info.NodeInfoList.Select(nodeInfo => nodeInfo).ToArray()
|
||||
NodeURIs = info.NodeInfoList.Select(nodeInfo => nodeInfo).ToArray(),
|
||||
Alias = info.Alias,
|
||||
Color = info.Color,
|
||||
Version = info.Version,
|
||||
PeersCount = info.PeersCount,
|
||||
ActiveChannelsCount = info.ActiveChannelsCount,
|
||||
InactiveChannelsCount = info.InactiveChannelsCount,
|
||||
PendingChannelsCount = info.PendingChannelsCount
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -194,6 +194,41 @@
|
||||
"blockHeight": {
|
||||
"type": "integer",
|
||||
"description": "The block height of the lightning node"
|
||||
},
|
||||
"alias": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The alias of the lightning node"
|
||||
},
|
||||
"color": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The color attribute of the lightning node"
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The version name of the lightning node"
|
||||
},
|
||||
"peersCount": {
|
||||
"type": "integer",
|
||||
"nullable": true,
|
||||
"description": "The number of peers"
|
||||
},
|
||||
"activeChannelsCount": {
|
||||
"type": "integer",
|
||||
"nullable": true,
|
||||
"description": "The number of active channels"
|
||||
},
|
||||
"inactiveChannelsCount": {
|
||||
"type": "integer",
|
||||
"nullable": true,
|
||||
"description": "The number of inactive channels"
|
||||
},
|
||||
"pendingChannelsCount": {
|
||||
"type": "integer",
|
||||
"nullable": true,
|
||||
"description": "The number of pending channels"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user