mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
feat: improve hexutil.Decode (#571)
This commit is contained in:
parent
932d6e371c
commit
f9d396cf57
1 changed files with 4 additions and 0 deletions
|
|
@ -64,6 +64,10 @@ func Decode(input string) ([]byte, error) {
|
||||||
if !has0xPrefix(input) {
|
if !has0xPrefix(input) {
|
||||||
return nil, ErrMissingPrefix
|
return nil, ErrMissingPrefix
|
||||||
}
|
}
|
||||||
|
// better compatible with odd size string
|
||||||
|
if len(input)%2 != 0 {
|
||||||
|
input = "0x0" + input[2:]
|
||||||
|
}
|
||||||
b, err := hex.DecodeString(input[2:])
|
b, err := hex.DecodeString(input[2:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = mapError(err)
|
err = mapError(err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue