-
Notifications
You must be signed in to change notification settings - Fork 4
/
keys.go
56 lines (47 loc) · 1.79 KB
/
keys.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
52
53
54
55
56
package keys
import (
"github.com/mosaicnetworks/monetd/src/configuration"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// Global variables for persistent Keys options
var (
_keystore = configuration.DefaultKeystoreDir()
_passwordFile string
_outputJSON bool
)
// KeysCmd is an Ethereum key manager
var KeysCmd = &cobra.Command{
Use: "keys",
Short: "manage keys",
Long: `
Manage keys in the <keystore> folder.
Note that other Monet tools, like monetcli and monet-wallet, use the same
default keystore.
+------------------------------------------------------------------------------+
| Please take all the necessary precautions to secure these files and remember |
| the passwords, as it will be impossible to recover the keys without them. |
+------------------------------------------------------------------------------+
Keys are associated with monikers and encrypted in password-protected files in
<keystore>/[moniker].json. Keyfiles contain JSON encoded objects, which Ethereum
users will recognise as the de-facto Ethereum keyfile format. Indeed, Monet and
the underlying consensus algorithm, Babble, use the same type of keys as
Ethereum. A key can be used to run a validator node, or to control an account
with a token balance.
`,
TraverseChildren: true,
}
func init() {
// Keys subcommands
KeysCmd.AddCommand(
newInspectCmd(),
newUpdateCmd(),
newNewCmd(),
newListCmd(),
)
// Flags that are common to all Keys subcommands
KeysCmd.PersistentFlags().StringVar(&_keystore, "keystore", _keystore, "keystore directory")
KeysCmd.PersistentFlags().StringVar(&_passwordFile, "passfile", "", "file containing the passphrase")
KeysCmd.PersistentFlags().BoolVar(&_outputJSON, "json", false, "output JSON instead of human-readable format")
viper.BindPFlags(KeysCmd.Flags())
}