Skip to content

Commit

Permalink
Merge pull request #2313 from barton2526/ParseHash
Browse files Browse the repository at this point in the history
rpc: ParseHash: Fail when length is not 64
  • Loading branch information
jamescowens committed Sep 1, 2021
2 parents 0862230 + f962d70 commit b2339fd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ uint256 ParseHashV(const UniValue& v, string strName)
strHex = v.get_str();
if (!IsHex(strHex)) // Note: IsHex("") is false
throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
if (64 != strHex.length())
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s must be of length %d (not %d)", strName, 64, strHex.length()));
uint256 result;
result.SetHex(strHex);
return result;
Expand Down

0 comments on commit b2339fd

Please sign in to comment.