refactor: Use RPCHelpMan::IsValidNumArgs in getrawtransaction

This commit is contained in:
MarcoFalke 2019-02-25 14:54:22 -05:00
parent fa9ff8fe21
commit 9999879f56
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -6,8 +6,8 @@
#include <chain.h> #include <chain.h>
#include <coins.h> #include <coins.h>
#include <compat/byteswap.h> #include <compat/byteswap.h>
#include <consensus/validation.h>
#include <consensus/tx_verify.h> #include <consensus/tx_verify.h>
#include <consensus/validation.h>
#include <core_io.h> #include <core_io.h>
#include <index/txindex.h> #include <index/txindex.h>
#include <init.h> #include <init.h>
@ -67,9 +67,7 @@ static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
static UniValue getrawtransaction(const JSONRPCRequest& request) static UniValue getrawtransaction(const JSONRPCRequest& request)
{ {
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3) const RPCHelpMan help{
throw std::runtime_error(
RPCHelpMan{
"getrawtransaction", "getrawtransaction",
"\nReturn the raw transaction data.\n" "\nReturn the raw transaction data.\n"
@ -147,7 +145,11 @@ static UniValue getrawtransaction(const JSONRPCRequest& request)
+ HelpExampleCli("getrawtransaction", "\"mytxid\" false \"myblockhash\"") + HelpExampleCli("getrawtransaction", "\"mytxid\" false \"myblockhash\"")
+ HelpExampleCli("getrawtransaction", "\"mytxid\" true \"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; bool in_active_chain = true;
uint256 hash = ParseHashV(request.params[0], "parameter 1"); uint256 hash = ParseHashV(request.params[0], "parameter 1");