0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-10 10:52:31 -05:00

rpc: remove unneeded RPCTypeCheckArgument checks

No-behavior change.

Since #25629, we check the univalue type internally.
This commit is contained in:
furszy 2022-07-29 10:35:10 -03:00
parent 55566630c6
commit e68d380797
No known key found for this signature in database
GPG key ID: 5DD23CCC686AA623
4 changed files with 2 additions and 15 deletions

View file

@ -64,7 +64,6 @@ static RPCHelpMan estimatesmartfee()
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{ {
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR}); RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR});
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
CBlockPolicyEstimator& fee_estimator = EnsureAnyFeeEstimator(request.context); CBlockPolicyEstimator& fee_estimator = EnsureAnyFeeEstimator(request.context);
const NodeContext& node = EnsureAnyNodeContext(request.context); const NodeContext& node = EnsureAnyNodeContext(request.context);
@ -157,7 +156,6 @@ static RPCHelpMan estimaterawfee()
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{ {
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true); RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true);
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
CBlockPolicyEstimator& fee_estimator = EnsureAnyFeeEstimator(request.context); CBlockPolicyEstimator& fee_estimator = EnsureAnyFeeEstimator(request.context);

View file

@ -605,8 +605,7 @@ static RPCHelpMan gettxspendingprevout()
}, },
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{ {
RPCTypeCheckArgument(request.params[0], UniValue::VARR); const UniValue& output_params = request.params[0].get_array();
const UniValue& output_params = request.params[0];
if (output_params.empty()) { if (output_params.empty()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, outputs are missing"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, outputs are missing");
} }

View file

@ -290,8 +290,6 @@ RPCHelpMan lockunspent()
LOCK(pwallet->cs_wallet); LOCK(pwallet->cs_wallet);
RPCTypeCheckArgument(request.params[0], UniValue::VBOOL);
bool fUnlock = request.params[0].get_bool(); bool fUnlock = request.params[0].get_bool();
const bool persistent{request.params[2].isNull() ? false : request.params[2].get_bool()}; const bool persistent{request.params[2].isNull() ? false : request.params[2].get_bool()};
@ -304,9 +302,7 @@ RPCHelpMan lockunspent()
return true; return true;
} }
RPCTypeCheckArgument(request.params[1], UniValue::VARR); const UniValue& output_params = request.params[1].get_array();
const UniValue& output_params = request.params[1];
// Create and validate the COutPoints first. // Create and validate the COutPoints first.
@ -566,19 +562,16 @@ RPCHelpMan listunspent()
int nMinDepth = 1; int nMinDepth = 1;
if (!request.params[0].isNull()) { if (!request.params[0].isNull()) {
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
nMinDepth = request.params[0].getInt<int>(); nMinDepth = request.params[0].getInt<int>();
} }
int nMaxDepth = 9999999; int nMaxDepth = 9999999;
if (!request.params[1].isNull()) { if (!request.params[1].isNull()) {
RPCTypeCheckArgument(request.params[1], UniValue::VNUM);
nMaxDepth = request.params[1].getInt<int>(); nMaxDepth = request.params[1].getInt<int>();
} }
std::set<CTxDestination> destinations; std::set<CTxDestination> destinations;
if (!request.params[2].isNull()) { if (!request.params[2].isNull()) {
RPCTypeCheckArgument(request.params[2], UniValue::VARR);
UniValue inputs = request.params[2].get_array(); UniValue inputs = request.params[2].get_array();
for (unsigned int idx = 0; idx < inputs.size(); idx++) { for (unsigned int idx = 0; idx < inputs.size(); idx++) {
const UniValue& input = inputs[idx]; const UniValue& input = inputs[idx];
@ -594,7 +587,6 @@ RPCHelpMan listunspent()
bool include_unsafe = true; bool include_unsafe = true;
if (!request.params[3].isNull()) { if (!request.params[3].isNull()) {
RPCTypeCheckArgument(request.params[3], UniValue::VBOOL);
include_unsafe = request.params[3].get_bool(); include_unsafe = request.params[3].get_bool();
} }

View file

@ -503,7 +503,6 @@ void FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& fee_out,
coinControl.fAllowWatchOnly = options.get_bool(); coinControl.fAllowWatchOnly = options.get_bool();
} }
else { else {
RPCTypeCheckArgument(options, UniValue::VOBJ);
RPCTypeCheckObj(options, RPCTypeCheckObj(options,
{ {
{"add_inputs", UniValueType(UniValue::VBOOL)}, {"add_inputs", UniValueType(UniValue::VBOOL)},
@ -1644,7 +1643,6 @@ RPCHelpMan walletcreatefundedpsbt()
bool rbf{wallet.m_signal_rbf}; bool rbf{wallet.m_signal_rbf};
const UniValue &replaceable_arg = options["replaceable"]; const UniValue &replaceable_arg = options["replaceable"];
if (!replaceable_arg.isNull()) { if (!replaceable_arg.isNull()) {
RPCTypeCheckArgument(replaceable_arg, UniValue::VBOOL);
rbf = replaceable_arg.isTrue(); rbf = replaceable_arg.isTrue();
} }
CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf); CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf);