From 1dd9e9a5e74d095c9fa88904fb3d9353cee66332 Mon Sep 17 00:00:00 2001 From: TY <45994721+tylerK1294@users.noreply.github.com> Date: Thu, 29 Sep 2022 01:55:44 +0900 Subject: [PATCH] internal/ethapi: handle odd length hex in decodeHash (#25883) This change adds zero-padding (prefix) of odd nibbles in the decodeHash function. Co-authored-by: ty --- internal/ethapi/api.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 2e410605222c..64b389612aba 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -714,6 +714,9 @@ func decodeHash(s string) (common.Hash, error) { if strings.HasPrefix(s, "0x") || strings.HasPrefix(s, "0X") { s = s[2:] } + if (len(s) & 1) > 0 { + s = "0" + s + } b, err := hex.DecodeString(s) if err != nil { return common.Hash{}, fmt.Errorf("hex string invalid")