mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Get rid of redundant RPC params.size() checks
No change in behavior.
This commit is contained in:
@@ -462,26 +462,26 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
|
||||
|
||||
// Wallet comments
|
||||
CWalletTx wtx;
|
||||
if (request.params.size() > 2 && !request.params[2].isNull() && !request.params[2].get_str().empty())
|
||||
if (!request.params[2].isNull() && !request.params[2].get_str().empty())
|
||||
wtx.mapValue["comment"] = request.params[2].get_str();
|
||||
if (request.params.size() > 3 && !request.params[3].isNull() && !request.params[3].get_str().empty())
|
||||
if (!request.params[3].isNull() && !request.params[3].get_str().empty())
|
||||
wtx.mapValue["to"] = request.params[3].get_str();
|
||||
|
||||
bool fSubtractFeeFromAmount = false;
|
||||
if (request.params.size() > 4 && !request.params[4].isNull()) {
|
||||
if (!request.params[4].isNull()) {
|
||||
fSubtractFeeFromAmount = request.params[4].get_bool();
|
||||
}
|
||||
|
||||
CCoinControl coin_control;
|
||||
if (request.params.size() > 5 && !request.params[5].isNull()) {
|
||||
if (!request.params[5].isNull()) {
|
||||
coin_control.signalRbf = request.params[5].get_bool();
|
||||
}
|
||||
|
||||
if (request.params.size() > 6 && !request.params[6].isNull()) {
|
||||
if (!request.params[6].isNull()) {
|
||||
coin_control.m_confirm_target = ParseConfirmTarget(request.params[6]);
|
||||
}
|
||||
|
||||
if (request.params.size() > 7 && !request.params[7].isNull()) {
|
||||
if (!request.params[7].isNull()) {
|
||||
if (!FeeModeFromString(request.params[7].get_str(), coin_control.m_fee_mode)) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid estimate_mode parameter");
|
||||
}
|
||||
@@ -904,9 +904,9 @@ UniValue sendfrom(const JSONRPCRequest& request)
|
||||
|
||||
CWalletTx wtx;
|
||||
wtx.strFromAccount = strAccount;
|
||||
if (request.params.size() > 4 && !request.params[4].isNull() && !request.params[4].get_str().empty())
|
||||
if (!request.params[4].isNull() && !request.params[4].get_str().empty())
|
||||
wtx.mapValue["comment"] = request.params[4].get_str();
|
||||
if (request.params.size() > 5 && !request.params[5].isNull() && !request.params[5].get_str().empty())
|
||||
if (!request.params[5].isNull() && !request.params[5].get_str().empty())
|
||||
wtx.mapValue["to"] = request.params[5].get_str();
|
||||
|
||||
EnsureWalletIsUnlocked(pwallet);
|
||||
@@ -986,23 +986,23 @@ UniValue sendmany(const JSONRPCRequest& request)
|
||||
|
||||
CWalletTx wtx;
|
||||
wtx.strFromAccount = strAccount;
|
||||
if (request.params.size() > 3 && !request.params[3].isNull() && !request.params[3].get_str().empty())
|
||||
if (!request.params[3].isNull() && !request.params[3].get_str().empty())
|
||||
wtx.mapValue["comment"] = request.params[3].get_str();
|
||||
|
||||
UniValue subtractFeeFromAmount(UniValue::VARR);
|
||||
if (request.params.size() > 4 && !request.params[4].isNull())
|
||||
if (!request.params[4].isNull())
|
||||
subtractFeeFromAmount = request.params[4].get_array();
|
||||
|
||||
CCoinControl coin_control;
|
||||
if (request.params.size() > 5 && !request.params[5].isNull()) {
|
||||
if (!request.params[5].isNull()) {
|
||||
coin_control.signalRbf = request.params[5].get_bool();
|
||||
}
|
||||
|
||||
if (request.params.size() > 6 && !request.params[6].isNull()) {
|
||||
if (!request.params[6].isNull()) {
|
||||
coin_control.m_confirm_target = ParseConfirmTarget(request.params[6]);
|
||||
}
|
||||
|
||||
if (request.params.size() > 7 && !request.params[7].isNull()) {
|
||||
if (!request.params[7].isNull()) {
|
||||
if (!FeeModeFromString(request.params[7].get_str(), coin_control.m_fee_mode)) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid estimate_mode parameter");
|
||||
}
|
||||
@@ -2670,19 +2670,19 @@ UniValue listunspent(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
int nMinDepth = 1;
|
||||
if (request.params.size() > 0 && !request.params[0].isNull()) {
|
||||
if (!request.params[0].isNull()) {
|
||||
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
|
||||
nMinDepth = request.params[0].get_int();
|
||||
}
|
||||
|
||||
int nMaxDepth = 9999999;
|
||||
if (request.params.size() > 1 && !request.params[1].isNull()) {
|
||||
if (!request.params[1].isNull()) {
|
||||
RPCTypeCheckArgument(request.params[1], UniValue::VNUM);
|
||||
nMaxDepth = request.params[1].get_int();
|
||||
}
|
||||
|
||||
std::set<CBitcoinAddress> setAddress;
|
||||
if (request.params.size() > 2 && !request.params[2].isNull()) {
|
||||
if (!request.params[2].isNull()) {
|
||||
RPCTypeCheckArgument(request.params[2], UniValue::VARR);
|
||||
UniValue inputs = request.params[2].get_array();
|
||||
for (unsigned int idx = 0; idx < inputs.size(); idx++) {
|
||||
@@ -2697,7 +2697,7 @@ UniValue listunspent(const JSONRPCRequest& request)
|
||||
}
|
||||
|
||||
bool include_unsafe = true;
|
||||
if (request.params.size() > 3 && !request.params[3].isNull()) {
|
||||
if (!request.params[3].isNull()) {
|
||||
RPCTypeCheckArgument(request.params[3], UniValue::VBOOL);
|
||||
include_unsafe = request.params[3].get_bool();
|
||||
}
|
||||
@@ -3112,7 +3112,7 @@ UniValue generate(const JSONRPCRequest& request)
|
||||
|
||||
int num_generate = request.params[0].get_int();
|
||||
uint64_t max_tries = 1000000;
|
||||
if (request.params.size() > 1 && !request.params[1].isNull()) {
|
||||
if (!request.params[1].isNull()) {
|
||||
max_tries = request.params[1].get_int();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user