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

rpcserver: hide channels in getnodeinfo by default
This commit is contained in:
Olaoluwa Osuntokun 2019-06-18 17:24:20 -07:00 committed by GitHub
commit b89b27e6ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 543 additions and 502 deletions

@ -2925,6 +2925,11 @@ var getNodeInfoCommand = cli.Command{
Usage: "the 33-byte hex-encoded compressed public of the target " +
"node",
},
cli.BoolFlag{
Name: "include_channels",
Usage: "if true, will return all known channels " +
"associated with the node",
},
},
Action: actionDecorator(getNodeInfo),
}
@ -2947,7 +2952,8 @@ func getNodeInfo(ctx *cli.Context) error {
}
req := &lnrpc.NodeInfoRequest{
PubKey: pubKey,
PubKey: pubKey,
IncludeChannels: ctx.Bool("include_channels"),
}
nodeInfo, err := client.GetNodeInfo(ctxb, req)

File diff suppressed because it is too large Load Diff

@ -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) {
var protoReq NodeInfoRequest
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)
}
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))
return msg, metadata, err

@ -1726,6 +1726,9 @@ message Route {
message NodeInfoRequest {
/// The 33-byte hex-encoded compressed public of the target node
string pub_key = 1;
/// If true, will include all known channels associated with the node.
bool include_channels = 2;
}
message NodeInfo {

@ -640,6 +640,14 @@
"in": "path",
"required": true,
"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": [

@ -3815,21 +3815,27 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context,
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 {
numChannels++
totalCapacity += edge.Capacity
// Do not include unannounced channels - private channels or public
// channels whose authentication proof were not confirmed yet.
if edge.AuthProof == nil {
return nil
}
// Only populate the node's channels if the user requested them.
if in.IncludeChannels {
// Do not include unannounced channels - private
// 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.
channelEdge := marshalDbEdge(edge, c1, c2)
channels = append(channels, channelEdge)
// Convert the database's edge format into the
// network/RPC edge format.
channelEdge := marshalDbEdge(edge, c1, c2)
channels = append(channels, channelEdge)
}
return nil
}); err != nil {