Skip to content

Commit 42a9110

Browse files
committed
Merge bitcoin/bitcoin#28162: refactor: Revert additional univalue check in ParseSighashString
06199a9 refactor: Revert addition of univalue sighash string check (TheCharlatan) 0b47c16 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 ACK 06199a9 jonatack: Tested ACK 06199a9 stickies-v: ACK 06199a9 Tree-SHA512: 3faa6b3d2247624c0973df8d79c09fbf1f90ffb99f1be484e359b528f485c31affea45976759bd206e4c81cbb54ebba5ad0ef4127d1deacbfe2a58153fcc94ee
2 parents 8aa77a7 + 06199a9 commit 42a9110

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

doc/release-notes-28113.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ RPC Wallet
22
----------
33

44
- The `signrawtransactionwithkey`, `signrawtransactionwithwallet`,
5-
`walletprocesspsbt` and `descriptorprocesspsbt` calls now return more
6-
specific RPC_INVALID_PARAMETER instead of RPC_PARSE_ERROR if their
7-
sighashtype argument is malformed or not a string.
5+
`walletprocesspsbt` and `descriptorprocesspsbt` calls now return the more
6+
specific RPC_INVALID_PARAMETER error instead of RPC_MISC_ERROR if their
7+
sighashtype argument is malformed.

src/rpc/util.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,16 @@ UniValue DescribeAddress(const CTxDestination& dest)
313313
return std::visit(DescribeAddressVisitor(), dest);
314314
}
315315

316+
/**
317+
* Returns a sighash value corresponding to the passed in argument.
318+
*
319+
* @pre The sighash argument should be string or null.
320+
*/
316321
int ParseSighashString(const UniValue& sighash)
317322
{
318323
if (sighash.isNull()) {
319324
return SIGHASH_DEFAULT;
320325
}
321-
if (!sighash.isStr()) {
322-
throw JSONRPCError(RPC_INVALID_PARAMETER, "sighash needs to be null or string");
323-
}
324326
const auto result{SighashFromStr(sighash.get_str())};
325327
if (!result) {
326328
throw JSONRPCError(RPC_INVALID_PARAMETER, util::ErrorString(result).original);

src/test/fuzz/parse_univalue.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ FUZZ_TARGET(parse_univalue, .init = initialize_parse_univalue)
6767
} catch (const std::runtime_error&) {
6868
}
6969
try {
70-
(void)ParseSighashString(univalue);
70+
if (univalue.isNull() || univalue.isStr()) (void)ParseSighashString(univalue);
7171
} catch (const UniValue&) {
7272
}
7373
try {

0 commit comments

Comments
 (0)