mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-24 08:24:20 +01:00
include closed channel IDs in node details
This commit is contained in:
@@ -44,7 +44,13 @@ public class NodeController {
|
||||
public NodeDetailsDto getDetails(@PathVariable Pubkey pubkey) {
|
||||
mark("getDetails");
|
||||
Node node = nodeService.getNode(pubkey);
|
||||
return new NodeDetailsDto(pubkey, node.alias(), getChannelIdsForPubkey(pubkey), node.online());
|
||||
return new NodeDetailsDto(
|
||||
pubkey,
|
||||
node.alias(),
|
||||
getChannelIdsForPubkey(pubkey),
|
||||
getClosedChannelIdsForPubkey(pubkey),
|
||||
node.online()
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/open-channels")
|
||||
@@ -61,6 +67,13 @@ public class NodeController {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<ChannelId> getClosedChannelIdsForPubkey(Pubkey pubkey) {
|
||||
return channelService.getClosedChannelsWith(pubkey).stream()
|
||||
.map(Channel::getId)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void mark(String getDetails) {
|
||||
metrics.mark(MetricRegistry.name(getClass(), getDetails));
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ public record NodeDetailsDto(
|
||||
@JsonSerialize(using = ToStringSerializer.class) Pubkey node,
|
||||
String alias,
|
||||
List<ChannelId> channels,
|
||||
List<ChannelId> closedChannels,
|
||||
boolean online
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -95,6 +95,12 @@ public class ChannelService {
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Set<ClosedChannel> getClosedChannelsWith(Pubkey peer) {
|
||||
return getClosedChannels().stream()
|
||||
.filter(c -> peer.equals(c.getRemotePubkey()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Set<LocalChannel> getAllChannelsWith(Pubkey peer) {
|
||||
return getAllLocalChannels()
|
||||
.filter(c -> peer.equals(c.getRemotePubkey()))
|
||||
|
||||
Reference in New Issue
Block a user