Merge pull request #3212 from cfromknecht/getnodeinfo-hide-chans-default

rpcserver: hide channels in getnodeinfo by default
This commit is contained in:
Olaoluwa Osuntokun authored and GitHub committed 2019-06-18 17:24:20 -07:00
commit b89b27e6ef
6 files changed
+543 -502

No files matched your search

+7 -1
View File
@@ -2925,6 +2925,11 @@ var getNodeInfoCommand = cli.Command{
Usage: "the 33-byte hex-encoded compressed public of the target " + Usage: "the 33-byte hex-encoded compressed public of the target " +
"node", "node",
}, },
cli.BoolFlag{
Name: "include_channels",
Usage: "if true, will return all known channels " +
"associated with the node",
},
}, },
Action: actionDecorator(getNodeInfo), Action: actionDecorator(getNodeInfo),
} }
@@ -2947,7 +2952,8 @@ func getNodeInfo(ctx *cli.Context) error {
} }
req := &lnrpc.NodeInfoRequest{ req := &lnrpc.NodeInfoRequest{
PubKey: pubKey, PubKey: pubKey,
IncludeChannels: ctx.Bool("include_channels"),
} }
nodeInfo, err := client.GetNodeInfo(ctxb, req) nodeInfo, err := client.GetNodeInfo(ctxb, req)
+502 -492
View File
File diff suppressed because it is too large. Load diff
+8
View File
@@ -628,6 +628,10 @@ func request_Lightning_GetChanInfo_0(ctx context.Context, marshaler runtime.Mars
} }
var (
filter_Lightning_GetNodeInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{"pub_key": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
)
func request_Lightning_GetNodeInfo_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { func request_Lightning_GetNodeInfo_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq NodeInfoRequest var protoReq NodeInfoRequest
var metadata runtime.ServerMetadata var metadata runtime.ServerMetadata
@@ -650,6 +654,10 @@ func request_Lightning_GetNodeInfo_0(ctx context.Context, marshaler runtime.Mars
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pub_key", err) return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pub_key", err)
} }
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Lightning_GetNodeInfo_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetNodeInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) msg, err := client.GetNodeInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err return msg, metadata, err
+3
View File
@@ -1726,6 +1726,9 @@ message Route {
message NodeInfoRequest { message NodeInfoRequest {
/// The 33-byte hex-encoded compressed public of the target node /// The 33-byte hex-encoded compressed public of the target node
string pub_key = 1; string pub_key = 1;
/// If true, will include all known channels associated with the node.
bool include_channels = 2;
} }
message NodeInfo { message NodeInfo {
+8
View File
@@ -640,6 +640,14 @@
"in": "path", "in": "path",
"required": true, "required": true,
"type": "string" "type": "string"
},
{
"name": "include_channels",
"description": "/ If true, will include all known channels associated with the node.",
"in": "query",
"required": false,
"type": "boolean",
"format": "boolean"
} }
], ],
"tags": [ "tags": [
+15 -9
View File
@@ -3815,21 +3815,27 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context,
channels []*lnrpc.ChannelEdge channels []*lnrpc.ChannelEdge
) )
if err := node.ForEachChannel(nil, func(_ *bbolt.Tx, edge *channeldb.ChannelEdgeInfo, if err := node.ForEachChannel(nil, func(_ *bbolt.Tx,
edge *channeldb.ChannelEdgeInfo,
c1, c2 *channeldb.ChannelEdgePolicy) error { c1, c2 *channeldb.ChannelEdgePolicy) error {
numChannels++ numChannels++
totalCapacity += edge.Capacity totalCapacity += edge.Capacity
// Do not include unannounced channels - private channels or public // Only populate the node's channels if the user requested them.
// channels whose authentication proof were not confirmed yet. if in.IncludeChannels {
if edge.AuthProof == nil { // Do not include unannounced channels - private
return nil // channels or public channels whose authentication
} // proof were not confirmed yet.
if edge.AuthProof == nil {
return nil
}
// Convert the database's edge format into the network/RPC edge format. // Convert the database's edge format into the
channelEdge := marshalDbEdge(edge, c1, c2) // network/RPC edge format.
channels = append(channels, channelEdge) channelEdge := marshalDbEdge(edge, c1, c2)
channels = append(channels, channelEdge)
}
return nil return nil
}); err != nil { }); err != nil {