internal/ethapi: make NewAccount return EIP-55 format (#26973)

This change implements returning the address as EIP-55 encoded when creating a new account.
This commit is contained in:
Alex Mylonas
2023-05-17 04:29:56 -04:00
committed by GitHub
parent 2f2959d003
commit ae1d90e710
3 changed files with 43 additions and 5 deletions
+6 -5
View File
@@ -354,19 +354,20 @@ func (s *PersonalAccountAPI) DeriveAccount(url string, path string, pin *bool) (
}
// NewAccount will create a new account and returns the address for the new account.
func (s *PersonalAccountAPI) NewAccount(password string) (common.Address, error) {
func (s *PersonalAccountAPI) NewAccount(password string) (common.AddressEIP55, error) {
ks, err := fetchKeystore(s.am)
if err != nil {
return common.Address{}, err
return common.AddressEIP55{}, err
}
acc, err := ks.NewAccount(password)
if err == nil {
log.Info("Your new key was generated", "address", acc.Address)
addrEIP55 := common.AddressEIP55(acc.Address)
log.Info("Your new key was generated", "address", addrEIP55.String())
log.Warn("Please backup your key file!", "path", acc.URL.Path)
log.Warn("Please remember your password!")
return acc.Address, nil
return addrEIP55, nil
}
return common.Address{}, err
return common.AddressEIP55{}, err
}
// fetchKeystore retrieves the encrypted keystore from the account manager.