@@ -431,9 +431,7 @@ static UniValue createrawtransaction(const JSONRPCRequest& request)
431431
432432static UniValue decoderawtransaction (const JSONRPCRequest& request)
433433{
434- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
435- throw std::runtime_error (
436- RPCHelpMan{" decoderawtransaction" ,
434+ const RPCHelpMan help{" decoderawtransaction" ,
437435 " \n Return a JSON object representing the serialized, hex-encoded transaction.\n " ,
438436 {
439437 {" hexstring" , RPCArg::Type::STR_HEX, RPCArg::Optional::NO, " The transaction hex string" },
@@ -485,7 +483,11 @@ static UniValue decoderawtransaction(const JSONRPCRequest& request)
485483 HelpExampleCli (" decoderawtransaction" , " \" hexstring\" " )
486484 + HelpExampleRpc (" decoderawtransaction" , " \" hexstring\" " )
487485 },
488- }.ToString ());
486+ };
487+
488+ if (request.fHelp || !help.IsValidNumArgs (request.params .size ())) {
489+ throw std::runtime_error (help.ToString ());
490+ }
489491
490492 RPCTypeCheck (request.params , {UniValue::VSTR, UniValue::VBOOL});
491493
@@ -1415,9 +1417,7 @@ UniValue createpsbt(const JSONRPCRequest& request)
14151417
14161418UniValue converttopsbt (const JSONRPCRequest& request)
14171419{
1418- if (request.fHelp || request.params .size () < 1 || request.params .size () > 3 )
1419- throw std::runtime_error (
1420- RPCHelpMan{" converttopsbt" ,
1420+ const RPCHelpMan help{" converttopsbt" ,
14211421 " \n Converts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction\n "
14221422 " createpsbt and walletcreatefundedpsbt should be used for new applications.\n " ,
14231423 {
@@ -1438,7 +1438,11 @@ UniValue converttopsbt(const JSONRPCRequest& request)
14381438 " \n Convert the transaction to a PSBT\n "
14391439 + HelpExampleCli (" converttopsbt" , " \" rawtransaction\" " )
14401440 },
1441- }.ToString ());
1441+ };
1442+
1443+ if (request.fHelp || !help.IsValidNumArgs (request.params .size ())) {
1444+ throw std::runtime_error (help.ToString ());
1445+ }
14421446
14431447
14441448 RPCTypeCheck (request.params , {UniValue::VSTR, UniValue::VBOOL, UniValue::VBOOL}, true );
0 commit comments