Fix Accounts Creation Error (#6748)

* add check
* Merge refs/heads/master into fixAccountsError
* Merge refs/heads/master into fixAccountsError
This commit is contained in:
Nishant Das 2020-07-29 00:06:18 +08:00 committed by GitHub
parent 7861005990
commit 8a69d34b96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -20,6 +20,21 @@ var log = logrus.WithField("prefix", "accounts-v2")
// a wallet from the user's specified path. // a wallet from the user's specified path.
func CreateAccount(cliCtx *cli.Context) error { func CreateAccount(cliCtx *cli.Context) error {
ctx := context.Background() 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) wallet, err := OpenWallet(cliCtx)
if err != nil { if err != nil {
return errors.Wrap(err, "could not open wallet") return errors.Wrap(err, "could not open wallet")

View File

@ -117,7 +117,6 @@ func inputPassword(cliCtx *cli.Context, promptText string, confirmPassword passw
} }
return strings.TrimRight(enteredPassword, "\r\n"), nil return strings.TrimRight(enteredPassword, "\r\n"), nil
} }
var hasValidPassword bool var hasValidPassword bool
var walletPassword string var walletPassword string
var err error var err error
@ -132,7 +131,6 @@ func inputPassword(cliCtx *cli.Context, promptText string, confirmPassword passw
if err != nil { if err != nil {
return "", fmt.Errorf("could not read account password: %v", formatPromptError(err)) return "", fmt.Errorf("could not read account password: %v", formatPromptError(err))
} }
if confirmPassword == confirmPass { if confirmPassword == confirmPass {
prompt = promptui.Prompt{ prompt = promptui.Prompt{
Label: confirmPasswordPromptText, Label: confirmPasswordPromptText,