feat: support password confirmation of clef newaccount

This commit is contained in:
PolyMa 2023-11-30 18:43:12 +08:00 committed by GitHub
parent fa0df76f3c
commit f94c18ed98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -444,12 +444,25 @@ func (api *SignerAPI) newAccount() (common.Address, error) {
if pwErr := ValidatePasswordFormat(resp.Text); pwErr != nil {
api.UI.ShowError(fmt.Sprintf("Account creation attempt #%d failed due to password requirements: %v", i+1, pwErr))
} else {
// No error
acc, err := be[0].(*keystore.KeyStore).NewAccount(resp.Text)
log.Info("Your new key was generated", "address", acc.Address)
log.Warn("Please backup your key file!", "path", acc.URL.Path)
log.Warn("Please remember your password!")
return acc.Address, err
// Confirm password if no error
confirmResp, err := api.UI.OnInputRequired(UserInputRequest{
"Confirm account password",
"Please confirm your password",
true})
if err != nil {
log.Warn("error obtaining password", "error", err)
break
}
if confirmResp.Text != resp.Text {
api.UI.ShowError("Passwords do not match! Please retry again.")
break
} else {
acc, err := be[0].(*keystore.KeyStore).NewAccount(resp.Text)
log.Info("Your new key was generated", "address", acc.Address)
log.Warn("Please backup your key file!", "path", acc.URL.Path)
log.Warn("Please remember your password!")
return acc.Address, err
}
}
}
// Otherwise fail, with generic error message