common: unify hex prefix check code (#19937)

This commit is contained in:
lmittmann
2019-08-22 11:45:07 +02:00
committed by Felix Lange
parent 7c229941ac
commit 1cd5bf080e
2 changed files with 5 additions and 7 deletions

View File

@@ -193,7 +193,7 @@ func HexToAddress(s string) Address { return BytesToAddress(FromHex(s)) }
// IsHexAddress verifies whether a string can represent a valid hex-encoded
// Ethereum address or not.
func IsHexAddress(s string) bool {
if hasHexPrefix(s) {
if has0xPrefix(s) {
s = s[2:]
}
return len(s) == 2*AddressLength && isHex(s)