mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
crypto/crypto, cmd/geth: added ChecksumAddress
This commit is contained in:
commit
94684a6907
1 changed files with 2 additions and 2 deletions
|
|
@ -355,7 +355,7 @@ func zeroBytes(bytes []byte) {
|
||||||
// The checksum algorithm is discussed in https://github.com/ethereum/EIPs/issues/55
|
// The checksum algorithm is discussed in https://github.com/ethereum/EIPs/issues/55
|
||||||
func ChecksumAddress(a common.Address) string {
|
func ChecksumAddress(a common.Address) string {
|
||||||
address := hex.EncodeToString(a[:]) // hex.EncodeToString is always lower case without 0x prefix
|
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"
|
checksumAddress := "0x"
|
||||||
for i := 0; i < len(address); i++ {
|
for i := 0; i < len(address); i++ {
|
||||||
// If ith character is 8 to f then make it uppercase
|
// If ith character is 8 to f then make it uppercase
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue