Skip to content

Commit

Permalink
lnrpc: expose network name in GetInfo
Browse files Browse the repository at this point in the history
Previously only a testnet boolean was available which
made it impossible to distinguish between regtest and
mainnet.
  • Loading branch information
joostjager committed Jan 7, 2019
1 parent f63ab4b commit 6494080
Show file tree
Hide file tree
Showing 5 changed files with 662 additions and 568 deletions.
17 changes: 15 additions & 2 deletions cmd/lncli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -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,
Expand All @@ -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
Expand Down
Loading

0 comments on commit 6494080

Please sign in to comment.