mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
Merge bitcoin/bitcoin#28162: refactor: Revert additional univalue check in ParseSighashString
06199a995f
refactor: Revert addition of univalue sighash string check (TheCharlatan)0b47c16215
doc: Correct release-notes for sighashtype exceptions (TheCharlatan) Pull request description: This is a follow up for #28113. The string type check is already done by the rpc parser / RPCHelpMan. Re-doing it is adding dead code. Instead, throwing an exception when the assumption does not hold is the already correct behavior. Pointed out in this [comment](https://github.com/bitcoin/bitcoin/pull/28113/files#r1274568557). Also correct the release note for the correct sighashtype exception change. There is no change in the handling of non-string sighashtype arugments. Pointed out in this [comment](https://github.com/bitcoin/bitcoin/pull/28113/files#r1274567555). ACKs for top commit: MarcoFalke: lgtm ACK06199a995f
jonatack: Tested ACK06199a995f
stickies-v: ACK06199a995f
Tree-SHA512: 3faa6b3d2247624c0973df8d79c09fbf1f90ffb99f1be484e359b528f485c31affea45976759bd206e4c81cbb54ebba5ad0ef4127d1deacbfe2a58153fcc94ee
This commit is contained in:
commit
42a9110899
3 changed files with 9 additions and 7 deletions
|
@ -2,6 +2,6 @@ RPC Wallet
|
||||||
----------
|
----------
|
||||||
|
|
||||||
- The `signrawtransactionwithkey`, `signrawtransactionwithwallet`,
|
- The `signrawtransactionwithkey`, `signrawtransactionwithwallet`,
|
||||||
`walletprocesspsbt` and `descriptorprocesspsbt` calls now return more
|
`walletprocesspsbt` and `descriptorprocesspsbt` calls now return the more
|
||||||
specific RPC_INVALID_PARAMETER instead of RPC_PARSE_ERROR if their
|
specific RPC_INVALID_PARAMETER error instead of RPC_MISC_ERROR if their
|
||||||
sighashtype argument is malformed or not a string.
|
sighashtype argument is malformed.
|
||||||
|
|
|
@ -313,14 +313,16 @@ UniValue DescribeAddress(const CTxDestination& dest)
|
||||||
return std::visit(DescribeAddressVisitor(), 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)
|
int ParseSighashString(const UniValue& sighash)
|
||||||
{
|
{
|
||||||
if (sighash.isNull()) {
|
if (sighash.isNull()) {
|
||||||
return SIGHASH_DEFAULT;
|
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())};
|
const auto result{SighashFromStr(sighash.get_str())};
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, util::ErrorString(result).original);
|
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&) {
|
} catch (const std::runtime_error&) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
(void)ParseSighashString(univalue);
|
if (univalue.isNull() || univalue.isStr()) (void)ParseSighashString(univalue);
|
||||||
} catch (const UniValue&) {
|
} catch (const UniValue&) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue