From 8a69d34b9696cdcce526d14f7cb70da020bb4ee1 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Wed, 29 Jul 2020 00:06:18 +0800 Subject: [PATCH] Fix Accounts Creation Error (#6748) * add check * Merge refs/heads/master into fixAccountsError * Merge refs/heads/master into fixAccountsError --- validator/accounts/v2/accounts_create.go | 15 +++++++++++++++ validator/accounts/v2/prompt.go | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/validator/accounts/v2/accounts_create.go b/validator/accounts/v2/accounts_create.go index 51bd9b686f..04431d7792 100644 --- a/validator/accounts/v2/accounts_create.go +++ b/validator/accounts/v2/accounts_create.go @@ -20,6 +20,21 @@ var log = logrus.WithField("prefix", "accounts-v2") // a wallet from the user's specified path. func CreateAccount(cliCtx *cli.Context) error { ctx := context.Background() + walletDir, err := inputDirectory(cliCtx, walletDirPromptText, flags.WalletDirFlag) + if err != nil { + return errors.Wrapf(err, "Could not retrieve input directory") + } + ok, err := hasDir(walletDir) + if err != nil { + return err + } + // Create a new wallet if no directory exists. + if !ok { + err = CreateWallet(cliCtx) + if err != nil { + return errors.Wrapf(err, "Could not create wallet") + } + } wallet, err := OpenWallet(cliCtx) if err != nil { return errors.Wrap(err, "could not open wallet") diff --git a/validator/accounts/v2/prompt.go b/validator/accounts/v2/prompt.go index 8ed1f25ae1..9a65f5bc4e 100644 --- a/validator/accounts/v2/prompt.go +++ b/validator/accounts/v2/prompt.go @@ -117,7 +117,6 @@ func inputPassword(cliCtx *cli.Context, promptText string, confirmPassword passw } return strings.TrimRight(enteredPassword, "\r\n"), nil } - var hasValidPassword bool var walletPassword string var err error @@ -132,7 +131,6 @@ func inputPassword(cliCtx *cli.Context, promptText string, confirmPassword passw if err != nil { return "", fmt.Errorf("could not read account password: %v", formatPromptError(err)) } - if confirmPassword == confirmPass { prompt = promptui.Prompt{ Label: confirmPasswordPromptText,