accounts: don't use common.Address for address field

common.Address JSON encoding now enforces the 0x prefix, but key files
don't have the prefix.
This commit is contained in:
Felix Lange 2016-11-28 01:30:54 +01:00
parent 37e5816bcd
commit ec5f531f4b

View File

@ -225,7 +225,7 @@ func (ac *addrCache) scan() ([]Account, error) {
buf = new(bufio.Reader) buf = new(bufio.Reader)
addrs []Account addrs []Account
keyJSON struct { keyJSON struct {
Address common.Address `json:"address"` Address string `json:"address"`
} }
) )
for _, fi := range files { for _, fi := range files {
@ -241,15 +241,16 @@ func (ac *addrCache) scan() ([]Account, error) {
} }
buf.Reset(fd) buf.Reset(fd)
// Parse the address. // Parse the address.
keyJSON.Address = common.Address{} keyJSON.Address = ""
err = json.NewDecoder(buf).Decode(&keyJSON) err = json.NewDecoder(buf).Decode(&keyJSON)
addr := common.HexToAddress(keyJSON.Address)
switch { switch {
case err != nil: case err != nil:
glog.V(logger.Debug).Infof("can't decode key %s: %v", path, err) glog.V(logger.Debug).Infof("can't decode key %s: %v", path, err)
case (keyJSON.Address == common.Address{}): case (addr == common.Address{}):
glog.V(logger.Debug).Infof("can't decode key %s: missing or zero address", path) glog.V(logger.Debug).Infof("can't decode key %s: missing or zero address", path)
default: default:
addrs = append(addrs, Account{Address: keyJSON.Address, File: path}) addrs = append(addrs, Account{Address: addr, File: path})
} }
fd.Close() fd.Close()
} }