mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-22 15:35:10 +01:00
identify node by pubkey
This commit is contained in:
@@ -3,6 +3,7 @@ package de.cotto.lndmanagej.service;
|
||||
import de.cotto.lndmanagej.grpc.GrpcChannels;
|
||||
import de.cotto.lndmanagej.model.Channel;
|
||||
import de.cotto.lndmanagej.model.Node;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -16,9 +17,14 @@ public class ChannelService {
|
||||
this.grpcChannels = grpcChannels;
|
||||
}
|
||||
|
||||
public Set<Channel> getOpenChannelsWith(Node node) {
|
||||
public Set<Channel> getOpenChannelsWith(Pubkey peer) {
|
||||
Node peerNode = Node.forPubkey(peer);
|
||||
return getOpenChannelsWith(peerNode);
|
||||
}
|
||||
|
||||
public Set<Channel> getOpenChannelsWith(Node peer) {
|
||||
return grpcChannels.getChannels().stream()
|
||||
.filter(c -> c.getNodes().contains(node))
|
||||
.filter(c -> c.getNodes().contains(peer))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,9 +40,8 @@ public class NodeService {
|
||||
.build(loader);
|
||||
}
|
||||
|
||||
public List<ChannelId> getOpenChannelIds(Pubkey pubkey) {
|
||||
Node node = getNode(pubkey);
|
||||
return channelService.getOpenChannelsWith(node).stream()
|
||||
public List<ChannelId> getOpenChannelIds(Pubkey peer) {
|
||||
return channelService.getOpenChannelsWith(peer).stream()
|
||||
.map(Channel::getId)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Reference in New Issue
Block a user