Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"

"github.com/defiweb/go-rlp"
"golang.org/x/crypto/sha3"

"github.com/defiweb/go-eth/hexutil"
)
Expand Down Expand Up @@ -114,7 +115,15 @@ func (t Address) Bytes() []byte {

// String returns the hex representation of the address.
func (t Address) String() string {
return hexutil.BytesToHex(t[:])
keccak := func(data ...[]byte) Hash {
h := sha3.NewLegacyKeccak256()
for _, i := range data {
h.Write(i)
}
return MustHashFromBytes(h.Sum(nil), PadNone)
}

return t.Checksum(keccak)
}

// Checksum returns the address with the checksum calculated according to
Expand Down