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 <ty@oncoder.com>
pull/25889/head
TY 2 years ago committed by GitHub
parent 85aafcfb2b
commit 88132afc3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      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")

Loading…
Cancel
Save