lnrpc: expose network name in GetInfo

Previously only a testnet boolean was available which
made it impossible to distinguish between regtest and
mainnet.
This commit is contained in:
Joost Jager
2019-01-02 16:10:12 +01:00
parent f63ab4beda
commit 649408003d
5 changed files with 661 additions and 567 deletions

View File

@@ -1669,6 +1669,11 @@ var getInfoCommand = cli.Command{
Action: actionDecorator(getInfo),
}
type chain struct {
Chain string `json:"chain"`
Network string `json:"network"`
}
func getInfo(ctx *cli.Context) error {
ctxb := context.Background()
client, cleanUp := getClient(ctx)
@@ -1680,6 +1685,14 @@ func getInfo(ctx *cli.Context) error {
return err
}
chains := make([]chain, len(resp.Chains))
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 {
@@ -1695,7 +1708,7 @@ func getInfo(ctx *cli.Context) error {
BestHeaderTimestamp int64 `json:"best_header_timestamp"`
SyncedToChain bool `json:"synced_to_chain"`
Testnet bool `json:"testnet"`
Chains []string `json:"chains"`
Chains []chain `json:"chains"`
Uris []string `json:"uris"`
}{
Version: resp.Version,
@@ -1710,7 +1723,7 @@ func getInfo(ctx *cli.Context) error {
BestHeaderTimestamp: resp.BestHeaderTimestamp,
SyncedToChain: resp.SyncedToChain,
Testnet: resp.Testnet,
Chains: resp.Chains,
Chains: chains,
Uris: resp.Uris,
})
return nil