Merge PR #4220: Empty mnemonic should return error during key recovery

This commit is contained in:
Frank Yang
2019-04-29 12:49:35 -04:00
committed by Alexander Bezobchuk
parent 6bb94ae814
commit 5344e8d768
4 changed files with 12 additions and 13 deletions
+4 -10
View File
@@ -33,11 +33,6 @@ const (
flagNoSort = "nosort"
)
const (
maxValidAccountValue = int(0x80000000 - 1)
maxValidIndexalue = int(0x80000000 - 1)
)
func addKeyCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "add <name>",
@@ -200,6 +195,10 @@ func runAddCmd(_ *cobra.Command, args []string) error {
if err != nil {
return err
}
if !bip39.IsMnemonicValid(mnemonic) {
return errors.New("invalid mnemonic")
}
}
if len(mnemonic) == 0 {
@@ -215,11 +214,6 @@ func runAddCmd(_ *cobra.Command, args []string) error {
}
}
if !bip39.IsMnemonicValid(mnemonic) {
fmt.Fprintf(os.Stderr, "Error: Mnemonic is not valid.\n")
return nil
}
// override bip39 passphrase
if interactive {
bip39Passphrase, err = client.GetString(