diff --git a/common/bytes.go b/common/bytes.go index c82e616241..b1cca130af 100644 --- a/common/bytes.go +++ b/common/bytes.go @@ -43,10 +43,8 @@ func ToHexArray(b [][]byte) []string { // FromHex returns the bytes represented by the hexadecimal string s. // s may be prefixed with "0x". func FromHex(s string) []byte { - if len(s) > 1 { - if s[0:2] == "0x" || s[0:2] == "0X" { - s = s[2:] - } + if hasHexPrefix(s) { + s = s[2:] } if len(s)%2 == 1 { s = "0" + s