From 7d43551e034a607e536a46bef3f678208188680d Mon Sep 17 00:00:00 2001 From: devopsbo3 <69951731+devopsbo3@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:53 -0600 Subject: [PATCH] Revert "internal/ethapi: make NewAccount return EIP-55 format (#26973)" This reverts commit 0c076b96f97cf68fd81309e3eae061e4ef58e56e. --- common/types.go | 13 ------------- common/types_test.go | 24 ------------------------ internal/ethapi/api.go | 11 +++++------ 3 files changed, 5 insertions(+), 43 deletions(-) diff --git a/common/types.go b/common/types.go index 3712df2fee..0b68a19dd3 100644 --- a/common/types.go +++ b/common/types.go @@ -429,16 +429,3 @@ func (ma *MixedcaseAddress) ValidChecksum() bool { func (ma *MixedcaseAddress) Original() string { return ma.original } - -// AddressEIP55 is an alias of Address with a customized json marshaller -type AddressEIP55 Address - -// String returns the hex representation of the address in the manner of EIP55. -func (addr AddressEIP55) String() string { - return Address(addr).Hex() -} - -// MarshalJSON marshals the address in the manner of EIP55. -func (addr AddressEIP55) MarshalJSON() ([]byte, error) { - return json.Marshal(addr.String()) -} diff --git a/common/types_test.go b/common/types_test.go index ad892671b5..88c642522d 100644 --- a/common/types_test.go +++ b/common/types_test.go @@ -559,27 +559,3 @@ func TestHash_Format(t *testing.T) { }) } } - -func TestAddressEIP55(t *testing.T) { - addr := HexToAddress("0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed") - addrEIP55 := AddressEIP55(addr) - - if addr.Hex() != addrEIP55.String() { - t.Fatal("AddressEIP55 should match original address hex") - } - - blob, err := addrEIP55.MarshalJSON() - if err != nil { - t.Fatal("Failed to marshal AddressEIP55", err) - } - if strings.Trim(string(blob), "\"") != addr.Hex() { - t.Fatal("Address with checksum is expected") - } - var dec Address - if err := json.Unmarshal(blob, &dec); err != nil { - t.Fatal("Failed to unmarshal AddressEIP55", err) - } - if addr != dec { - t.Fatal("Unexpected address after unmarshal") - } -} diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 9a821be0c1..5ebb6924ef 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -354,20 +354,19 @@ 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.AddressEIP55, error) { +func (s *PersonalAccountAPI) NewAccount(password string) (common.Address, error) { ks, err := fetchKeystore(s.am) if err != nil { - return common.AddressEIP55{}, err + return common.Address{}, err } acc, err := ks.NewAccount(password) if err == nil { - addrEIP55 := common.AddressEIP55(acc.Address) - log.Info("Your new key was generated", "address", addrEIP55.String()) + 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 addrEIP55, nil + return acc.Address, nil } - return common.AddressEIP55{}, err + return common.Address{}, err } // fetchKeystore retrieves the encrypted keystore from the account manager.