[rpc] ParseHash: Fail when length is not 64
Github-Pull: #9042 Rebased-From: fa326193ad739d1f93da456b3fa73af0bbf9fdd1
This commit is contained in:
@@ -146,6 +146,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;
|
||||
|
||||
Reference in New Issue
Block a user