mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
use hasHexPrefix for 0x prefix check
This commit is contained in:
parent
d9258162ca
commit
5b2834856e
1 changed files with 2 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue