lnrpc+lncli: add feature bits to GetInfo
This commit is contained in:
5 files changed
+641
-595
No files matched your search
+18
-16
@@ -1949,22 +1949,23 @@ func getInfo(ctx *cli.Context) error {
|
|||||||
// We print a struct that mimics the proto definition of GetInfoResponse
|
// We print a struct that mimics the proto definition of GetInfoResponse
|
||||||
// but has a better ordering for the same list of fields.
|
// but has a better ordering for the same list of fields.
|
||||||
printJSON(struct {
|
printJSON(struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
IdentityPubkey string `json:"identity_pubkey"`
|
IdentityPubkey string `json:"identity_pubkey"`
|
||||||
Alias string `json:"alias"`
|
Alias string `json:"alias"`
|
||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
NumPendingChannels uint32 `json:"num_pending_channels"`
|
NumPendingChannels uint32 `json:"num_pending_channels"`
|
||||||
NumActiveChannels uint32 `json:"num_active_channels"`
|
NumActiveChannels uint32 `json:"num_active_channels"`
|
||||||
NumInactiveChannels uint32 `json:"num_inactive_channels"`
|
NumInactiveChannels uint32 `json:"num_inactive_channels"`
|
||||||
NumPeers uint32 `json:"num_peers"`
|
NumPeers uint32 `json:"num_peers"`
|
||||||
BlockHeight uint32 `json:"block_height"`
|
BlockHeight uint32 `json:"block_height"`
|
||||||
BlockHash string `json:"block_hash"`
|
BlockHash string `json:"block_hash"`
|
||||||
BestHeaderTimestamp int64 `json:"best_header_timestamp"`
|
BestHeaderTimestamp int64 `json:"best_header_timestamp"`
|
||||||
SyncedToChain bool `json:"synced_to_chain"`
|
SyncedToChain bool `json:"synced_to_chain"`
|
||||||
SyncedToGraph bool `json:"synced_to_graph"`
|
SyncedToGraph bool `json:"synced_to_graph"`
|
||||||
Testnet bool `json:"testnet"`
|
Testnet bool `json:"testnet"`
|
||||||
Chains []chain `json:"chains"`
|
Chains []chain `json:"chains"`
|
||||||
Uris []string `json:"uris"`
|
Uris []string `json:"uris"`
|
||||||
|
Features map[uint32]*lnrpc.Feature `json:"features"`
|
||||||
}{
|
}{
|
||||||
Version: resp.Version,
|
Version: resp.Version,
|
||||||
IdentityPubkey: resp.IdentityPubkey,
|
IdentityPubkey: resp.IdentityPubkey,
|
||||||
@@ -1982,6 +1983,7 @@ func getInfo(ctx *cli.Context) error {
|
|||||||
Testnet: resp.Testnet,
|
Testnet: resp.Testnet,
|
||||||
Chains: chains,
|
Chains: chains,
|
||||||
Uris: resp.Uris,
|
Uris: resp.Uris,
|
||||||
|
Features: resp.Features,
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
+593
-579
File diff suppressed because it is too large.
Load diff
@@ -1539,6 +1539,12 @@ message GetInfoResponse {
|
|||||||
|
|
||||||
// Whether we consider ourselves synced with the public channel graph.
|
// Whether we consider ourselves synced with the public channel graph.
|
||||||
bool synced_to_graph = 18 [json_name = "synced_to_graph"];
|
bool synced_to_graph = 18 [json_name = "synced_to_graph"];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Features that our node has advertised in our init message, node
|
||||||
|
announcements and invoices.
|
||||||
|
*/
|
||||||
|
map<uint32, Feature> features = 19 [json_name = "features"];
|
||||||
}
|
}
|
||||||
|
|
||||||
message Chain {
|
message Chain {
|
||||||
|
|||||||
@@ -2504,6 +2504,13 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"format": "boolean",
|
"format": "boolean",
|
||||||
"description": "Whether we consider ourselves synced with the public channel graph."
|
"description": "Whether we consider ourselves synced with the public channel graph."
|
||||||
|
},
|
||||||
|
"features": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/definitions/lnrpcFeature"
|
||||||
|
},
|
||||||
|
"description": "Features that our node has advertised in our init message, node\nannouncements and invoices."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2215,6 +2215,22 @@ func (r *rpcServer) GetInfo(ctx context.Context,
|
|||||||
|
|
||||||
isGraphSynced := r.server.authGossiper.SyncManager().IsGraphSynced()
|
isGraphSynced := r.server.authGossiper.SyncManager().IsGraphSynced()
|
||||||
|
|
||||||
|
features := make(map[uint32]*lnrpc.Feature)
|
||||||
|
sets := r.server.featureMgr.ListSets()
|
||||||
|
|
||||||
|
for _, set := range sets {
|
||||||
|
// Get the a list of lnrpc features for each set we support.
|
||||||
|
featureVector := r.server.featureMgr.Get(set)
|
||||||
|
rpcFeatures := invoicesrpc.CreateRPCFeatures(featureVector)
|
||||||
|
|
||||||
|
// Add the features to our map of features, allowing over writing of
|
||||||
|
// existing values because features in different sets with the same bit
|
||||||
|
// are duplicated across sets.
|
||||||
|
for bit, feature := range rpcFeatures {
|
||||||
|
features[bit] = feature
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(roasbeef): add synced height n stuff
|
// TODO(roasbeef): add synced height n stuff
|
||||||
return &lnrpc.GetInfoResponse{
|
return &lnrpc.GetInfoResponse{
|
||||||
IdentityPubkey: encodedIDPub,
|
IdentityPubkey: encodedIDPub,
|
||||||
@@ -2233,6 +2249,7 @@ func (r *rpcServer) GetInfo(ctx context.Context,
|
|||||||
BestHeaderTimestamp: int64(bestHeaderTimestamp),
|
BestHeaderTimestamp: int64(bestHeaderTimestamp),
|
||||||
Version: build.Version(),
|
Version: build.Version(),
|
||||||
SyncedToGraph: isGraphSynced,
|
SyncedToGraph: isGraphSynced,
|
||||||
|
Features: features,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user