crypto/crypto, cmd/geth: added ChecksumAddress

This commit is contained in:
8go 2016-03-11 09:42:51 +01:00
commit 94684a6907

View file

@ -355,7 +355,7 @@ func zeroBytes(bytes []byte) {
// The checksum algorithm is discussed in https://github.com/ethereum/EIPs/issues/55
func ChecksumAddress(a common.Address) string {
address := hex.EncodeToString(a[:]) // hex.EncodeToString is always lower case without 0x prefix
addressHash := hex.EncodeToString(Sha3([]byte(common.Bytes2Hex(a[:]))))
addressHash := hex.EncodeToString(Sha3([]byte(a.Hex()[2:]))) // skip the "0x" at the beginning
checksumAddress := "0x"
for i := 0; i < len(address); i++ {
// If ith character is 8 to f then make it uppercase