lnrpc: add node features to LightningNode and NodeInfo

This commit is contained in:
Conner Fromknecht 2019-12-14 07:04:51 -08:00
parent eae45f9ad9
commit db0029d03d
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
5 changed files with 586 additions and 563 deletions

View File

@ -129,6 +129,10 @@ func CreateRPCInvoice(invoice *channeldb.Invoice,
// CreateRPCFeatures maps a feature vector into a list of lnrpc.Features.
func CreateRPCFeatures(fv *lnwire.FeatureVector) []*lnrpc.Feature {
if fv == nil {
return nil
}
features := fv.Features()
rpcFeatures := make([]*lnrpc.Feature, 0, len(features))
for bit := range features {

File diff suppressed because it is too large Load Diff

View File

@ -2069,6 +2069,7 @@ message LightningNode {
string alias = 3 [ json_name = "alias" ];
repeated NodeAddress addresses = 4 [ json_name = "addresses" ];
string color = 5 [ json_name = "color" ];
repeated Feature features = 6 [ json_name = "features" ];
}
message NodeAddress {

View File

@ -2913,6 +2913,12 @@
},
"color": {
"type": "string"
},
"features": {
"type": "array",
"items": {
"$ref": "#/definitions/lnrpcFeature"
}
}
},
"description": "*\nAn individual vertex/node within the channel graph. A node is\nconnected to other nodes by one or more channel edges emanating from it. As the\ngraph is directed, a node will also have an incoming edge attached to it for\neach outgoing edge."

View File

@ -3956,6 +3956,7 @@ func (r *rpcServer) DescribeGraph(ctx context.Context,
Addresses: nodeAddrs,
Alias: node.Alias,
Color: routing.EncodeHexColor(node.Color),
Features: invoicesrpc.CreateRPCFeatures(node.Features),
})
return nil
@ -4137,6 +4138,8 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context,
nodeAddrs = append(nodeAddrs, nodeAddr)
}
features := invoicesrpc.CreateRPCFeatures(node.Features)
return &lnrpc.NodeInfo{
Node: &lnrpc.LightningNode{
LastUpdate: uint32(node.LastUpdate.Unix()),
@ -4144,6 +4147,7 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context,
Addresses: nodeAddrs,
Alias: node.Alias,
Color: routing.EncodeHexColor(node.Color),
Features: features,
},
NumChannels: numChannels,
TotalCapacity: int64(totalCapacity),