mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
feat: support password confirmation of clef newaccount
This commit is contained in:
parent
fa0df76f3c
commit
f94c18ed98
1 changed files with 19 additions and 6 deletions
|
|
@ -444,7 +444,19 @@ func (api *SignerAPI) newAccount() (common.Address, error) {
|
||||||
if pwErr := ValidatePasswordFormat(resp.Text); pwErr != nil {
|
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))
|
api.UI.ShowError(fmt.Sprintf("Account creation attempt #%d failed due to password requirements: %v", i+1, pwErr))
|
||||||
} else {
|
} else {
|
||||||
// No error
|
// 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)
|
acc, err := be[0].(*keystore.KeyStore).NewAccount(resp.Text)
|
||||||
log.Info("Your new key was generated", "address", acc.Address)
|
log.Info("Your new key was generated", "address", acc.Address)
|
||||||
log.Warn("Please backup your key file!", "path", acc.URL.Path)
|
log.Warn("Please backup your key file!", "path", acc.URL.Path)
|
||||||
|
|
@ -452,6 +464,7 @@ func (api *SignerAPI) newAccount() (common.Address, error) {
|
||||||
return acc.Address, err
|
return acc.Address, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Otherwise fail, with generic error message
|
// Otherwise fail, with generic error message
|
||||||
return common.Address{}, errors.New("account creation failed")
|
return common.Address{}, errors.New("account creation failed")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue