mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
refactor: Revert addition of univalue sighash string check
This check is already done by the rpc parser. Re-doing it is adding dead code. Instead, throwing an exception when the assumption does not hold is the already correct behavior. To make the fuzz test more accurate and not swallow all runtime errors, add a check that the passed in UniValue sighash argument is either a string or null. Co-authored-by: stickies-v <stickies-v@protonmail.com>
This commit is contained in:
parent
0b47c16215
commit
06199a995f
2 changed files with 6 additions and 4 deletions
|
@ -313,14 +313,16 @@ UniValue DescribeAddress(const CTxDestination& dest)
|
|||
return std::visit(DescribeAddressVisitor(), dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sighash value corresponding to the passed in argument.
|
||||
*
|
||||
* @pre The sighash argument should be string or null.
|
||||
*/
|
||||
int ParseSighashString(const UniValue& sighash)
|
||||
{
|
||||
if (sighash.isNull()) {
|
||||
return SIGHASH_DEFAULT;
|
||||
}
|
||||
if (!sighash.isStr()) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "sighash needs to be null or string");
|
||||
}
|
||||
const auto result{SighashFromStr(sighash.get_str())};
|
||||
if (!result) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, util::ErrorString(result).original);
|
||||
|
|
|
@ -67,7 +67,7 @@ FUZZ_TARGET(parse_univalue, .init = initialize_parse_univalue)
|
|||
} catch (const std::runtime_error&) {
|
||||
}
|
||||
try {
|
||||
(void)ParseSighashString(univalue);
|
||||
if (univalue.isNull() || univalue.isStr()) (void)ParseSighashString(univalue);
|
||||
} catch (const UniValue&) {
|
||||
}
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue