lnrpc+lncli: reorder getinfo and use printRespJSON

This commit is contained in:
Conner Fromknecht
2019-12-20 01:05:27 -08:00
parent 8f5d78c875
commit 153cd58c97
4 changed files with 694 additions and 740 deletions

View File

@@ -1938,53 +1938,7 @@ func getInfo(ctx *cli.Context) error {
return err return err
} }
chains := make([]chain, len(resp.Chains)) printRespJSON(resp)
for i, c := range resp.Chains {
chains[i] = chain{
Chain: c.Chain,
Network: c.Network,
}
}
// We print a struct that mimics the proto definition of GetInfoResponse
// but has a better ordering for the same list of fields.
printJSON(struct {
Version string `json:"version"`
IdentityPubkey string `json:"identity_pubkey"`
Alias string `json:"alias"`
Color string `json:"color"`
NumPendingChannels uint32 `json:"num_pending_channels"`
NumActiveChannels uint32 `json:"num_active_channels"`
NumInactiveChannels uint32 `json:"num_inactive_channels"`
NumPeers uint32 `json:"num_peers"`
BlockHeight uint32 `json:"block_height"`
BlockHash string `json:"block_hash"`
BestHeaderTimestamp int64 `json:"best_header_timestamp"`
SyncedToChain bool `json:"synced_to_chain"`
SyncedToGraph bool `json:"synced_to_graph"`
Testnet bool `json:"testnet"`
Chains []chain `json:"chains"`
Uris []string `json:"uris"`
Features map[uint32]*lnrpc.Feature `json:"features"`
}{
Version: resp.Version,
IdentityPubkey: resp.IdentityPubkey,
Alias: resp.Alias,
Color: resp.Color,
NumPendingChannels: resp.NumPendingChannels,
NumActiveChannels: resp.NumActiveChannels,
NumInactiveChannels: resp.NumInactiveChannels,
NumPeers: resp.NumPeers,
BlockHeight: resp.BlockHeight,
BlockHash: resp.BlockHash,
BestHeaderTimestamp: resp.BestHeaderTimestamp,
SyncedToChain: resp.SyncedToChain,
SyncedToGraph: resp.SyncedToGraph,
Testnet: resp.Testnet,
Chains: chains,
Uris: resp.Uris,
Features: resp.Features,
})
return nil return nil
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1505,18 +1505,27 @@ message GetInfoRequest {
} }
message GetInfoResponse { message GetInfoResponse {
/// The version of the LND software that the node is running.
string version = 14 [ json_name = "version" ];
/// The identity pubkey of the current node. /// The identity pubkey of the current node.
string identity_pubkey = 1 [json_name = "identity_pubkey"]; string identity_pubkey = 1 [json_name = "identity_pubkey"];
/// If applicable, the alias of the current node, e.g. "bob" /// If applicable, the alias of the current node, e.g. "bob"
string alias = 2 [json_name = "alias"]; string alias = 2 [json_name = "alias"];
/// The color of the current node in hex code format
string color = 17 [json_name = "color"];
/// Number of pending channels /// Number of pending channels
uint32 num_pending_channels = 3 [json_name = "num_pending_channels"]; uint32 num_pending_channels = 3 [json_name = "num_pending_channels"];
/// Number of active channels /// Number of active channels
uint32 num_active_channels = 4 [json_name = "num_active_channels"]; uint32 num_active_channels = 4 [json_name = "num_active_channels"];
/// Number of inactive channels
uint32 num_inactive_channels = 15 [json_name = "num_inactive_channels"];
/// Number of peers /// Number of peers
uint32 num_peers = 5 [json_name = "num_peers"]; uint32 num_peers = 5 [json_name = "num_peers"];
@@ -1526,9 +1535,15 @@ message GetInfoResponse {
/// The node's current view of the hash of the best block /// The node's current view of the hash of the best block
string block_hash = 8 [json_name = "block_hash"]; string block_hash = 8 [json_name = "block_hash"];
/// Timestamp of the block best known to the wallet
int64 best_header_timestamp = 13 [ json_name = "best_header_timestamp" ];
/// Whether the wallet's view is synced to the main chain /// Whether the wallet's view is synced to the main chain
bool synced_to_chain = 9 [json_name = "synced_to_chain"]; bool synced_to_chain = 9 [json_name = "synced_to_chain"];
// Whether we consider ourselves synced with the public channel graph.
bool synced_to_graph = 18 [json_name = "synced_to_graph"];
/** /**
Whether the current node is connected to testnet. This field is Whether the current node is connected to testnet. This field is
deprecated and the network field should be used instead deprecated and the network field should be used instead
@@ -1537,26 +1552,11 @@ message GetInfoResponse {
reserved 11; reserved 11;
/// The URIs of the current node.
repeated string uris = 12 [json_name = "uris"];
/// Timestamp of the block best known to the wallet
int64 best_header_timestamp = 13 [ json_name = "best_header_timestamp" ];
/// The version of the LND software that the node is running.
string version = 14 [ json_name = "version" ];
/// Number of inactive channels
uint32 num_inactive_channels = 15 [json_name = "num_inactive_channels"];
/// A list of active chains the node is connected to /// A list of active chains the node is connected to
repeated Chain chains = 16 [json_name = "chains"]; repeated Chain chains = 16 [json_name = "chains"];
/// The color of the current node in hex code format /// The URIs of the current node.
string color = 17 [json_name = "color"]; repeated string uris = 12 [json_name = "uris"];
// Whether we consider ourselves synced with the public channel graph.
bool synced_to_graph = 18 [json_name = "synced_to_graph"];
/* /*
Features that our node has advertised in our init message, node Features that our node has advertised in our init message, node

View File

@@ -2453,6 +2453,10 @@
"lnrpcGetInfoResponse": { "lnrpcGetInfoResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"version": {
"type": "string",
"description": "/ The version of the LND software that the node is running."
},
"identity_pubkey": { "identity_pubkey": {
"type": "string", "type": "string",
"description": "/ The identity pubkey of the current node." "description": "/ The identity pubkey of the current node."
@@ -2461,6 +2465,10 @@
"type": "string", "type": "string",
"title": "/ If applicable, the alias of the current node, e.g. \"bob\"" "title": "/ If applicable, the alias of the current node, e.g. \"bob\""
}, },
"color": {
"type": "string",
"title": "/ The color of the current node in hex code format"
},
"num_pending_channels": { "num_pending_channels": {
"type": "integer", "type": "integer",
"format": "int64", "format": "int64",
@@ -2471,6 +2479,11 @@
"format": "int64", "format": "int64",
"title": "/ Number of active channels" "title": "/ Number of active channels"
}, },
"num_inactive_channels": {
"type": "integer",
"format": "int64",
"title": "/ Number of inactive channels"
},
"num_peers": { "num_peers": {
"type": "integer", "type": "integer",
"format": "int64", "format": "int64",
@@ -2485,36 +2498,25 @@
"type": "string", "type": "string",
"title": "/ The node's current view of the hash of the best block" "title": "/ The node's current view of the hash of the best block"
}, },
"synced_to_chain": {
"type": "boolean",
"format": "boolean",
"title": "/ Whether the wallet's view is synced to the main chain"
},
"testnet": {
"type": "boolean",
"format": "boolean",
"title": "* \nWhether the current node is connected to testnet. This field is \ndeprecated and the network field should be used instead"
},
"uris": {
"type": "array",
"items": {
"type": "string"
},
"description": "/ The URIs of the current node."
},
"best_header_timestamp": { "best_header_timestamp": {
"type": "string", "type": "string",
"format": "int64", "format": "int64",
"title": "/ Timestamp of the block best known to the wallet" "title": "/ Timestamp of the block best known to the wallet"
}, },
"version": { "synced_to_chain": {
"type": "string", "type": "boolean",
"description": "/ The version of the LND software that the node is running." "format": "boolean",
"title": "/ Whether the wallet's view is synced to the main chain"
}, },
"num_inactive_channels": { "synced_to_graph": {
"type": "integer", "type": "boolean",
"format": "int64", "format": "boolean",
"title": "/ Number of inactive channels" "description": "Whether we consider ourselves synced with the public channel graph."
},
"testnet": {
"type": "boolean",
"format": "boolean",
"title": "* \nWhether the current node is connected to testnet. This field is \ndeprecated and the network field should be used instead"
}, },
"chains": { "chains": {
"type": "array", "type": "array",
@@ -2523,14 +2525,12 @@
}, },
"title": "/ A list of active chains the node is connected to" "title": "/ A list of active chains the node is connected to"
}, },
"color": { "uris": {
"type": "string", "type": "array",
"title": "/ The color of the current node in hex code format" "items": {
}, "type": "string"
"synced_to_graph": { },
"type": "boolean", "description": "/ The URIs of the current node."
"format": "boolean",
"description": "Whether we consider ourselves synced with the public channel graph."
}, },
"features": { "features": {
"type": "object", "type": "object",