R4R: add command asks for encryption password once too many (#2970)

* add command asks for encryption password once too many

* keep additional explanatory text
This commit is contained in:
Alessio Treglia
2018-11-30 15:00:53 -08:00
committed by Jack Zampolin
parent 956c2229bf
commit 535822ca68
2 changed files with 9 additions and 17 deletions
+7 -15
View File
@@ -69,7 +69,7 @@ output
func runAddCmd(cmd *cobra.Command, args []string) error {
var kb keys.Keybase
var err error
var pass string
var encrypPassword string
buf := client.BufferStdin()
name := args[0]
@@ -77,7 +77,7 @@ func runAddCmd(cmd *cobra.Command, args []string) error {
// we throw this away, so don't enforce args,
// we want to get a new random seed phrase quickly
kb = client.MockKeyBase()
pass = "throwing-this-key-away"
encrypPassword = "throwing-this-key-away"
} else {
kb, err = GetKeyBaseWithWritePerm()
if err != nil {
@@ -95,9 +95,9 @@ func runAddCmd(cmd *cobra.Command, args []string) error {
// ask for a password when generating a local key
if !viper.GetBool(client.FlagUseLedger) {
pass, err = client.GetCheckPassword(
"> Enter a passphrase for your key:",
"> Repeat the passphrase:", buf)
encrypPassword, err = client.GetCheckPassword(
"Enter a passphrase to encrypt your key to disk:",
"Repeat the passphrase:", buf)
if err != nil {
return err
}
@@ -135,7 +135,7 @@ func runAddCmd(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
info, err := kb.CreateKey(name, seed, pass)
info, err := kb.CreateKey(name, seed, encrypPassword)
if err != nil {
return err
}
@@ -189,15 +189,7 @@ func runAddCmd(cmd *cobra.Command, args []string) error {
}
}
// get the encryption password
encryptPassword, err := client.GetCheckPassword(
"> Enter a passphrase to encrypt your key to disk:",
"> Repeat the passphrase:", buf)
if err != nil {
return err
}
info, err := kb.Derive(name, mnemonic, bip39Passphrase, encryptPassword, *bip44Params)
info, err := kb.Derive(name, mnemonic, bip39Passphrase, encrypPassword, *bip44Params)
if err != nil {
return err
}
+2 -2
View File
@@ -618,8 +618,8 @@ func initializeFixtures(t *testing.T) (chainID, servAddr, port string) {
os.RemoveAll(filepath.Join(gaiadHome, "config", "gentx"))
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s --force foo", gaiacliHome))
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s --force bar", gaiacliHome))
executeWriteCheckErr(t, fmt.Sprintf("gaiacli keys add --home=%s foo", gaiacliHome), app.DefaultKeyPass, app.DefaultKeyPass)
executeWriteCheckErr(t, fmt.Sprintf("gaiacli keys add --home=%s bar", gaiacliHome), app.DefaultKeyPass, app.DefaultKeyPass)
executeWriteCheckErr(t, fmt.Sprintf("gaiacli keys add --home=%s foo", gaiacliHome), app.DefaultKeyPass)
executeWriteCheckErr(t, fmt.Sprintf("gaiacli keys add --home=%s bar", gaiacliHome), app.DefaultKeyPass)
fooAddr, _ := executeGetAddrPK(t, fmt.Sprintf(
"gaiacli keys show foo --output=json --home=%s", gaiacliHome))
chainID = executeInit(t, fmt.Sprintf("gaiad init -o --moniker=foo --home=%s", gaiadHome))