| 115 | } |
| 116 | |
| 117 | uint256 ParseHashV(const UniValue& v, std::string_view name) |
| 118 | { |
| 119 | const std::string& strHex(v.get_str()); |
| 120 | if (auto rv{uint256::FromHex(strHex)}) return *rv; |
| 121 | if (auto expected_len{uint256::size() * 2}; strHex.length() != expected_len) { |
| 122 | throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s must be of length %d (not %d, for '%s')", name, expected_len, strHex.length(), strHex)); |
| 123 | } |
| 124 | throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s must be hexadecimal string (not '%s')", name, strHex)); |
| 125 | } |
| 126 | uint256 ParseHashO(const UniValue& o, std::string_view strKey) |
| 127 | { |
| 128 | return ParseHashV(o.find_value(strKey), strKey); |
no test coverage detected