forked from btcsuite/btcd
-
Notifications
You must be signed in to change notification settings - Fork 26
/
cmd_version.go
51 lines (42 loc) · 1.26 KB
/
cmd_version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"context"
"fmt"
"github.com/pkt-cash/pktd/btcutil/er"
"github.com/pkt-cash/pktd/lnd/lnrpc/lnclipb"
"github.com/pkt-cash/pktd/lnd/lnrpc/verrpc"
"github.com/pkt-cash/pktd/pktconfig/version"
"github.com/urfave/cli"
)
var versionCommand = cli.Command{
Name: "version",
Usage: "Display pldctl and pld version info.",
Description: `
Returns version information about both pldctl and pld. If pldctl is unable
to connect to pld, the command fails but still prints the pldctl version.
`,
Action: actionDecorator(v),
}
func v(ctx *cli.Context) er.R {
conn := getClientConn(ctx, false)
defer conn.Close()
versions := &lnclipb.VersionResponse{
Pldctl: &verrpc.Version{
Version: version.Version(),
AppMajor: uint32(version.AppMajorVersion()),
AppMinor: uint32(version.AppMinorVersion()),
AppPatch: uint32(version.AppPatchVersion()),
AppPreRelease: fmt.Sprintf("%v", version.IsPrerelease()),
},
}
client := verrpc.NewVersionerClient(conn)
ctxb := context.Background()
lndVersion, err := client.GetVersion(ctxb, &verrpc.VersionRequest{})
if err != nil {
printRespJSON(versions)
return er.Errorf("unable fetch version from pld: %v", err)
}
versions.Pld = lndVersion
printRespJSON(versions)
return nil
}