Skip to content

Commit 9999879

Browse files
author
MarcoFalke
committed
refactor: Use RPCHelpMan::IsValidNumArgs in getrawtransaction
1 parent fa9ff8f commit 9999879

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#include <chain.h>
77
#include <coins.h>
88
#include <compat/byteswap.h>
9-
#include <consensus/validation.h>
109
#include <consensus/tx_verify.h>
10+
#include <consensus/validation.h>
1111
#include <core_io.h>
1212
#include <index/txindex.h>
1313
#include <init.h>
@@ -67,9 +67,7 @@ static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
6767

6868
static UniValue getrawtransaction(const JSONRPCRequest& request)
6969
{
70-
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
71-
throw std::runtime_error(
72-
RPCHelpMan{
70+
const RPCHelpMan help{
7371
"getrawtransaction",
7472
"\nReturn the raw transaction data.\n"
7573

@@ -147,7 +145,11 @@ static UniValue getrawtransaction(const JSONRPCRequest& request)
147145
+ HelpExampleCli("getrawtransaction", "\"mytxid\" false \"myblockhash\"")
148146
+ HelpExampleCli("getrawtransaction", "\"mytxid\" true \"myblockhash\"")
149147
},
150-
}.ToString());
148+
};
149+
150+
if (request.fHelp || !help.IsValidNumArgs(request.params.size())) {
151+
throw std::runtime_error(help.ToString());
152+
}
151153

152154
bool in_active_chain = true;
153155
uint256 hash = ParseHashV(request.params[0], "parameter 1");

0 commit comments

Comments
 (0)