Merge pull request #3837 from cfromknecht/node-features-rpc
lnrpc: display node and peer features via rpc
This commit is contained in:
5 files changed
+667
-626
No files matched your search
@@ -128,16 +128,19 @@ func CreateRPCInvoice(invoice *channeldb.Invoice,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateRPCFeatures maps a feature vector into a list of lnrpc.Features.
|
// CreateRPCFeatures maps a feature vector into a list of lnrpc.Features.
|
||||||
func CreateRPCFeatures(fv *lnwire.FeatureVector) []*lnrpc.Feature {
|
func CreateRPCFeatures(fv *lnwire.FeatureVector) map[uint32]*lnrpc.Feature {
|
||||||
|
if fv == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
features := fv.Features()
|
features := fv.Features()
|
||||||
rpcFeatures := make([]*lnrpc.Feature, 0, len(features))
|
rpcFeatures := make(map[uint32]*lnrpc.Feature, len(features))
|
||||||
for bit := range features {
|
for bit := range features {
|
||||||
rpcFeatures = append(rpcFeatures, &lnrpc.Feature{
|
rpcFeatures[uint32(bit)] = &lnrpc.Feature{
|
||||||
Bit: uint32(bit),
|
|
||||||
Name: fv.Name(bit),
|
Name: fv.Name(bit),
|
||||||
IsRequired: bit.IsRequired(),
|
IsRequired: bit.IsRequired(),
|
||||||
IsKnown: fv.IsKnown(bit),
|
IsKnown: fv.IsKnown(bit),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcFeatures
|
return rpcFeatures
|
||||||
|
|||||||
+627
-610
File diff suppressed because it is too large.
Load diff
+6
-3
@@ -1449,6 +1449,9 @@ message Peer {
|
|||||||
|
|
||||||
// The type of sync we are currently performing with this peer.
|
// The type of sync we are currently performing with this peer.
|
||||||
SyncType sync_type = 10 [json_name = "sync_type"];
|
SyncType sync_type = 10 [json_name = "sync_type"];
|
||||||
|
|
||||||
|
/// Features advertised by the remote peer in their init message.
|
||||||
|
map<uint32, Feature> features = 11 [json_name = "features"];
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListPeersRequest {
|
message ListPeersRequest {
|
||||||
@@ -2069,6 +2072,7 @@ message LightningNode {
|
|||||||
string alias = 3 [ json_name = "alias" ];
|
string alias = 3 [ json_name = "alias" ];
|
||||||
repeated NodeAddress addresses = 4 [ json_name = "addresses" ];
|
repeated NodeAddress addresses = 4 [ json_name = "addresses" ];
|
||||||
string color = 5 [ json_name = "color" ];
|
string color = 5 [ json_name = "color" ];
|
||||||
|
map<uint32, Feature> features = 6 [ json_name = "features" ];
|
||||||
}
|
}
|
||||||
|
|
||||||
message NodeAddress {
|
message NodeAddress {
|
||||||
@@ -2373,7 +2377,7 @@ message Invoice {
|
|||||||
repeated InvoiceHTLC htlcs = 22 [json_name = "htlcs"];
|
repeated InvoiceHTLC htlcs = 22 [json_name = "htlcs"];
|
||||||
|
|
||||||
/// List of features advertised on the invoice.
|
/// List of features advertised on the invoice.
|
||||||
repeated Feature features = 24 [json_name = "features"];
|
map<uint32, Feature> features = 24 [json_name = "features"];
|
||||||
}
|
}
|
||||||
|
|
||||||
enum InvoiceHTLCState {
|
enum InvoiceHTLCState {
|
||||||
@@ -2634,11 +2638,10 @@ message PayReq {
|
|||||||
repeated RouteHint route_hints = 10 [json_name = "route_hints"];
|
repeated RouteHint route_hints = 10 [json_name = "route_hints"];
|
||||||
bytes payment_addr = 11 [json_name = "payment_addr"];
|
bytes payment_addr = 11 [json_name = "payment_addr"];
|
||||||
int64 num_msat = 12 [json_name = "num_msat"];
|
int64 num_msat = 12 [json_name = "num_msat"];
|
||||||
repeated Feature features = 13 [json_name = "features"];
|
map<uint32, Feature> features = 13 [json_name = "features"];
|
||||||
}
|
}
|
||||||
|
|
||||||
message Feature {
|
message Feature {
|
||||||
uint32 bit = 1 [json_name = "bit"];
|
|
||||||
string name = 2 [json_name = "name"];
|
string name = 2 [json_name = "name"];
|
||||||
bool is_required = 3 [json_name = "is_required"];
|
bool is_required = 3 [json_name = "is_required"];
|
||||||
bool is_known = 4 [json_name = "is_known"];
|
bool is_known = 4 [json_name = "is_known"];
|
||||||
|
|||||||
+17
-8
@@ -2246,10 +2246,6 @@
|
|||||||
"lnrpcFeature": {
|
"lnrpcFeature": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"bit": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "int64"
|
|
||||||
},
|
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -2804,8 +2800,8 @@
|
|||||||
"description": "/ List of HTLCs paying to this invoice [EXPERIMENTAL]."
|
"description": "/ List of HTLCs paying to this invoice [EXPERIMENTAL]."
|
||||||
},
|
},
|
||||||
"features": {
|
"features": {
|
||||||
"type": "array",
|
"type": "object",
|
||||||
"items": {
|
"additionalProperties": {
|
||||||
"$ref": "#/definitions/lnrpcFeature"
|
"$ref": "#/definitions/lnrpcFeature"
|
||||||
},
|
},
|
||||||
"description": "/ List of features advertised on the invoice."
|
"description": "/ List of features advertised on the invoice."
|
||||||
@@ -2913,6 +2909,12 @@
|
|||||||
},
|
},
|
||||||
"color": {
|
"color": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"features": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"$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."
|
"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."
|
||||||
@@ -3305,8 +3307,8 @@
|
|||||||
"format": "int64"
|
"format": "int64"
|
||||||
},
|
},
|
||||||
"features": {
|
"features": {
|
||||||
"type": "array",
|
"type": "object",
|
||||||
"items": {
|
"additionalProperties": {
|
||||||
"$ref": "#/definitions/lnrpcFeature"
|
"$ref": "#/definitions/lnrpcFeature"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3431,6 +3433,13 @@
|
|||||||
"sync_type": {
|
"sync_type": {
|
||||||
"$ref": "#/definitions/PeerSyncType",
|
"$ref": "#/definitions/PeerSyncType",
|
||||||
"description": "The type of sync we are currently performing with this peer."
|
"description": "The type of sync we are currently performing with this peer."
|
||||||
|
},
|
||||||
|
"features": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/definitions/lnrpcFeature"
|
||||||
|
},
|
||||||
|
"description": "/ Features advertised by the remote peer in their init message."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2258,6 +2258,10 @@ func (r *rpcServer) ListPeers(ctx context.Context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
features := invoicesrpc.CreateRPCFeatures(
|
||||||
|
serverPeer.RemoteFeatures(),
|
||||||
|
)
|
||||||
|
|
||||||
peer := &lnrpc.Peer{
|
peer := &lnrpc.Peer{
|
||||||
PubKey: hex.EncodeToString(nodePub[:]),
|
PubKey: hex.EncodeToString(nodePub[:]),
|
||||||
Address: serverPeer.conn.RemoteAddr().String(),
|
Address: serverPeer.conn.RemoteAddr().String(),
|
||||||
@@ -2268,6 +2272,7 @@ func (r *rpcServer) ListPeers(ctx context.Context,
|
|||||||
SatRecv: satRecv,
|
SatRecv: satRecv,
|
||||||
PingTime: serverPeer.PingTime(),
|
PingTime: serverPeer.PingTime(),
|
||||||
SyncType: lnrpcSyncType,
|
SyncType: lnrpcSyncType,
|
||||||
|
Features: features,
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.Peers = append(resp.Peers, peer)
|
resp.Peers = append(resp.Peers, peer)
|
||||||
@@ -3956,6 +3961,7 @@ func (r *rpcServer) DescribeGraph(ctx context.Context,
|
|||||||
Addresses: nodeAddrs,
|
Addresses: nodeAddrs,
|
||||||
Alias: node.Alias,
|
Alias: node.Alias,
|
||||||
Color: routing.EncodeHexColor(node.Color),
|
Color: routing.EncodeHexColor(node.Color),
|
||||||
|
Features: invoicesrpc.CreateRPCFeatures(node.Features),
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -4137,6 +4143,8 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context,
|
|||||||
nodeAddrs = append(nodeAddrs, nodeAddr)
|
nodeAddrs = append(nodeAddrs, nodeAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
features := invoicesrpc.CreateRPCFeatures(node.Features)
|
||||||
|
|
||||||
return &lnrpc.NodeInfo{
|
return &lnrpc.NodeInfo{
|
||||||
Node: &lnrpc.LightningNode{
|
Node: &lnrpc.LightningNode{
|
||||||
LastUpdate: uint32(node.LastUpdate.Unix()),
|
LastUpdate: uint32(node.LastUpdate.Unix()),
|
||||||
@@ -4144,6 +4152,7 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context,
|
|||||||
Addresses: nodeAddrs,
|
Addresses: nodeAddrs,
|
||||||
Alias: node.Alias,
|
Alias: node.Alias,
|
||||||
Color: routing.EncodeHexColor(node.Color),
|
Color: routing.EncodeHexColor(node.Color),
|
||||||
|
Features: features,
|
||||||
},
|
},
|
||||||
NumChannels: numChannels,
|
NumChannels: numChannels,
|
||||||
TotalCapacity: int64(totalCapacity),
|
TotalCapacity: int64(totalCapacity),
|
||||||
|
|||||||
Reference in new issue
Block a user