From 5b2834856eebbe0656c01c3c40756b5372219ca2 Mon Sep 17 00:00:00 2001 From: lmittmann Date: Thu, 15 Aug 2019 12:40:58 +0200 Subject: [PATCH] use hasHexPrefix for 0x prefix check --- common/bytes.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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