Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2776,7 +2776,7 @@ static RPCHelpMan scantxoutset()
throw JSONRPCError(RPC_INVALID_PARAMETER, "Scan already in progress, use action \"abort\" or \"status\"");
}

if (request.params.size() < 2) {
if (request.params[1].isNull()) {
throw JSONRPCError(RPC_MISC_ERROR, "scanobjects argument is required for the start action");
}

Expand Down
6 changes: 3 additions & 3 deletions src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ static RPCHelpMan deriveaddresses()
int64_t range_begin = 0;
int64_t range_end = 0;

if (request.params.size() >= 2 && !request.params[1].isNull()) {
if (!request.params[1].isNull()) {
std::tie(range_begin, range_end) = ParseDescriptorRange(request.params[1]);
}

Expand All @@ -310,11 +310,11 @@ static RPCHelpMan deriveaddresses()
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, error);
}

if (!desc->IsRange() && request.params.size() > 1) {
if (!desc->IsRange() && !request.params[1].isNull()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Range should not be specified for an un-ranged descriptor");
}

if (desc->IsRange() && request.params.size() == 1) {
if (desc->IsRange() && request.params[1].isNull()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Range must be specified for a ranged descriptor");
}

Expand Down
2 changes: 1 addition & 1 deletion src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static RPCHelpMan help()
[&](const RPCHelpMan& self, const JSONRPCRequest& jsonRequest) -> UniValue
{
std::string strCommand;
if (jsonRequest.params.size() > 0) {
if (!jsonRequest.params[0].isNull()) {
strCommand = jsonRequest.params[0].get_str();
}
if (strCommand == "dump_all_command_conversions") {
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/rpc/coins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ RPCHelpMan getreceivedbyaddress()
LOCK(pwallet->cs_wallet);

std::string asset = "";
if (request.params.size() > 2 && request.params[2].isStr()) {
if (!request.params[2].isNull() && request.params[2].isStr()) {
asset = request.params[2].get_str();
}

Expand Down Expand Up @@ -193,7 +193,7 @@ RPCHelpMan getreceivedbylabel()
LOCK(pwallet->cs_wallet);

std::string asset = "";
if (request.params.size() > 2 && request.params[2].isStr()) {
if (!request.params[2].isNull() && request.params[2].isStr()) {
asset = request.params[2].get_str();
}

Expand Down
22 changes: 11 additions & 11 deletions src/wallet/rpc/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ RPCHelpMan initpegoutwallet()

// Generate a new key that is added to wallet or set from argument
CPubKey online_pubkey;
if (request.params.size() < 3) {
if (request.params[2].isNull()) {
std::string error;
if (!pwallet->GetOnlinePakKey(online_pubkey, error)) {
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, error);
Expand All @@ -347,7 +347,7 @@ RPCHelpMan initpegoutwallet()

// Parse offline counter
int counter = 0;
if (request.params.size() > 1) {
if (!request.params[1].isNull()) {
counter = request.params[1].get_int();
if (counter < 0 || counter > 1000000000) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "bip32_counter must be between 0 and 1,000,000,000, inclusive.");
Expand Down Expand Up @@ -502,7 +502,7 @@ RPCHelpMan sendtomainchain_base()
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");

bool subtract_fee = false;
if (request.params.size() > 2) {
if (!request.params[2].isNull()) {
subtract_fee = request.params[2].get_bool();
}

Expand Down Expand Up @@ -615,7 +615,7 @@ RPCHelpMan sendtomainchain_pak()
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount for send, must send more than 0.00100000 BTC");

bool subtract_fee = false;
if (request.params.size() > 2) {
if (!request.params[2].isNull()) {
subtract_fee = request.params[2].get_bool();
}

Expand Down Expand Up @@ -827,7 +827,7 @@ static UniValue createrawpegin(const JSONRPCRequest& request, T_tx_ref& txBTCRef
std::vector<unsigned char> txOutProofData = ParseHex(request.params[1].get_str());

std::set<CScript> claim_scripts;
if (request.params.size() > 2) {
if (!request.params[2].isNull()) {
const std::string claim_script = request.params[2].get_str();
if (!IsHex(claim_script)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Given claim_script is not hex.");
Expand Down Expand Up @@ -1273,12 +1273,12 @@ RPCHelpMan blindrawtransaction()
}

bool ignore_blind_fail = true;
if (request.params.size() > 1) {
if (!request.params[1].isNull()) {
ignore_blind_fail = request.params[1].get_bool();
}

std::vector<std::vector<unsigned char> > auxiliary_generators;
if (request.params.size() > 2) {
if (!request.params[2].isNull()) {
UniValue assetCommitments = request.params[2].get_array();
if (assetCommitments.size() != 0 && assetCommitments.size() < tx.vin.size()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Asset commitment array must have at least as many entries as transaction inputs.");
Expand Down Expand Up @@ -1539,11 +1539,11 @@ RPCHelpMan issueasset()
throw JSONRPCError(RPC_TYPE_ERROR, "Issuance must have one non-zero component");
}

bool blind_issuances = request.params.size() < 3 || request.params[2].get_bool();
bool blind_issuances = request.params[2].isNull() || request.params[2].get_bool();

// Check for optional contract to hash into definition
uint256 contract_hash;
if (request.params.size() >= 4) {
if (!request.params[3].isNull()) {
contract_hash = ParseHashV(request.params[3], "contract_hash");
}

Expand Down Expand Up @@ -1730,7 +1730,7 @@ RPCHelpMan listissuances()

std::string assetstr;
CAsset asset_filter;
if (request.params.size() > 0) {
if (!request.params[0].isNull()) {
assetstr = request.params[0].get_str();
asset_filter = GetAssetFromString(assetstr);
}
Expand Down Expand Up @@ -1828,7 +1828,7 @@ RPCHelpMan destroyamount()
}

mapValue_t mapValue;
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()) {
mapValue["comment"] = request.params[2].get_str();
}

Expand Down
2 changes: 1 addition & 1 deletion src/wallet/rpc/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ RPCHelpMan sendtoaddress()
coin_control.m_avoid_partial_spends |= coin_control.m_avoid_address_reuse;

std::string strasset = Params().GetConsensus().pegged_asset.GetHex();
if (request.params.size() > 9 && request.params[9].isStr() && !request.params[9].get_str().empty()) {
if (!request.params[9].isNull() && request.params[9].isStr() && !request.params[9].get_str().empty()) {
strasset = request.params[9].get_str();
}
CAsset asset = GetAssetFromString(strasset);
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/rpc/transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static UniValue ListReceived(const CWallet& wallet, const UniValue& params, cons
}

std::string strasset = "";
if (params.size() > 4 && params[4].isStr()) {
if (!params[4].isNull() && params[4].isStr()) {
strasset = params[4].get_str();
}
CAsset asset;
Expand Down