Skip to content

Commit

Permalink
refactor: Use RPCHelpMan::IsValidNumArgs in getrawtransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke authored and Michael Polzer committed Mar 5, 2019
1 parent f5cd48e commit 20fb1db
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/rpc/rawtransaction.cpp
Expand Up @@ -8,8 +8,8 @@
#include <chain.h>
#include <coins.h>
#include <compat/byteswap.h>
#include <consensus/validation.h>
#include <consensus/tx_verify.h>
#include <consensus/validation.h>
#include <core_io.h>
#include <index/txindex.h>
#include <init.h>
Expand Down Expand Up @@ -69,9 +69,7 @@ static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&

static UniValue getrawtransaction(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
throw std::runtime_error(
RPCHelpMan{
const RPCHelpMan help{
"getrawtransaction",
"\nReturn the raw transaction data.\n"

Expand Down Expand Up @@ -149,7 +147,11 @@ static UniValue getrawtransaction(const JSONRPCRequest& request)
+ HelpExampleCli("getrawtransaction", "\"mytxid\" false \"myblockhash\"")
+ HelpExampleCli("getrawtransaction", "\"mytxid\" true \"myblockhash\"")
},
}.ToString());
};

if (request.fHelp || !help.IsValidNumArgs(request.params.size())) {
throw std::runtime_error(help.ToString());
}

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

0 comments on commit 20fb1db

Please sign in to comment.