mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-24 08:24:20 +01:00
include waiting close and pending force closing channel IDs in node details
This commit is contained in:
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@@ -47,8 +48,10 @@ public class NodeController {
|
||||
return new NodeDetailsDto(
|
||||
pubkey,
|
||||
node.alias(),
|
||||
getChannelIdsForPubkey(pubkey),
|
||||
getClosedChannelIdsForPubkey(pubkey),
|
||||
toSortedList(channelService.getOpenChannelsWith(pubkey)),
|
||||
toSortedList(channelService.getClosedChannelsWith(pubkey)),
|
||||
toSortedList(channelService.getWaitingCloseChannelsFor(pubkey)),
|
||||
toSortedList(channelService.getForceClosingChannelsFor(pubkey)),
|
||||
node.online()
|
||||
);
|
||||
}
|
||||
@@ -56,19 +59,12 @@ public class NodeController {
|
||||
@GetMapping("/open-channels")
|
||||
public ChannelsForNodeDto getOpenChannelIdsForPubkey(@PathVariable Pubkey pubkey) {
|
||||
mark("getOpenChannelIdsForPubkey");
|
||||
List<ChannelId> channels = getChannelIdsForPubkey(pubkey);
|
||||
List<ChannelId> channels = toSortedList(channelService.getOpenChannelsWith(pubkey));
|
||||
return new ChannelsForNodeDto(pubkey, channels);
|
||||
}
|
||||
|
||||
private List<ChannelId> getChannelIdsForPubkey(Pubkey pubkey) {
|
||||
return channelService.getOpenChannelsWith(pubkey).stream()
|
||||
.map(Channel::getId)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<ChannelId> getClosedChannelIdsForPubkey(Pubkey pubkey) {
|
||||
return channelService.getClosedChannelsWith(pubkey).stream()
|
||||
private List<ChannelId> toSortedList(Set<? extends Channel> channels) {
|
||||
return channels.stream()
|
||||
.map(Channel::getId)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -12,6 +12,8 @@ public record NodeDetailsDto(
|
||||
String alias,
|
||||
List<ChannelId> channels,
|
||||
List<ChannelId> closedChannels,
|
||||
List<ChannelId> waitingCloseChannels,
|
||||
List<ChannelId> pendingForceClosingChannels,
|
||||
boolean online
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -101,6 +101,18 @@ public class ChannelService {
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Set<WaitingCloseChannel> getWaitingCloseChannelsFor(Pubkey peer) {
|
||||
return getWaitingCloseChannels().stream()
|
||||
.filter(c -> peer.equals(c.getRemotePubkey()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Set<ForceClosingChannel> getForceClosingChannelsFor(Pubkey peer) {
|
||||
return getForceClosingChannels().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