-
Notifications
You must be signed in to change notification settings - Fork 4
/
inspect.go
50 lines (39 loc) · 1.19 KB
/
inspect.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
package keys
import (
"fmt"
"github.com/mosaicnetworks/monetd/src/crypto"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var _showPrivate bool
// newInspectCmd returns the command that inspects an Ethereum keyfile
func newInspectCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "inspect [moniker]",
Short: "inspect a keyfile",
Long: `
Display the contents of a keyfile.
The output contains the corresponding address and public key. If --private is
specified, the keyfile will be decrypted with the passphrase and the raw private
key will also be returned. If --passfile is not specified, the user will be
prompted to enter the passphrase manually.
`,
Args: cobra.ExactArgs(1),
RunE: inspect,
}
addInspectFlags(cmd)
return cmd
}
// addInspectFlags adds flags to the Inspect command
func addInspectFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(&_showPrivate, "private", false, "include the private key in the output")
viper.BindPFlags(cmd.Flags())
}
func inspect(cmd *cobra.Command, args []string) error {
moniker := args[0]
err := crypto.InspectKeyByMoniker(_keystore, moniker, _passwordFile, _showPrivate, _outputJSON)
if err != nil {
fmt.Println(err)
}
return nil
}