You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chantools/lnd/graph.go

34 lines
636 B
Go

package lnd
import (
"fmt"
"github.com/lightningnetwork/lnd/lnrpc"
)
func AllNodeChannels(graph *lnrpc.ChannelGraph,
nodePubKey string) []*lnrpc.ChannelEdge {
var result []*lnrpc.ChannelEdge
for _, edge := range graph.Edges {
if edge.Node1Pub != nodePubKey && edge.Node2Pub != nodePubKey {
continue
}
result = append(result, edge)
}
return result
}
func FindNode(graph *lnrpc.ChannelGraph,
nodePubKey string) (*lnrpc.LightningNode, error) {
for _, node := range graph.Nodes {
if node.PubKey == nodePubKey {
return node, nil
}
}
return nil, fmt.Errorf("node %s not found in graph", nodePubKey)
}