refactor: Use RPCHelpMan::IsValidNumArgs in getrawtransaction
This commit is contained in:
parent
fa9ff8fe21
commit
9999879f56
1 changed files with 7 additions and 5 deletions
|
@ -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");
|
||||||
|
|
Loading…
Add table
Reference in a new issue