mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
scripted-diff: Use UniValue::find_value method
-BEGIN VERIFY SCRIPT- sed --regexp-extended -i 's/find_value\(([^ ,]+), /\1.find_value(/g' $(git grep -l find_value) -END VERIFY SCRIPT-
This commit is contained in:
@@ -870,7 +870,7 @@ static UniValue ConnectAndCallRPC(BaseRequestHandler* rh, const std::string& str
|
||||
try {
|
||||
response = CallRPC(rh, strMethod, args, rpcwallet);
|
||||
if (fWait) {
|
||||
const UniValue& error = find_value(response, "error");
|
||||
const UniValue& error = response.find_value("error");
|
||||
if (!error.isNull() && error["code"].getInt<int>() == RPC_IN_WARMUP) {
|
||||
throw CConnectionFailed("server in warmup");
|
||||
}
|
||||
@@ -898,8 +898,8 @@ static void ParseResult(const UniValue& result, std::string& strPrint)
|
||||
static void ParseError(const UniValue& error, std::string& strPrint, int& nRet)
|
||||
{
|
||||
if (error.isObject()) {
|
||||
const UniValue& err_code = find_value(error, "code");
|
||||
const UniValue& err_msg = find_value(error, "message");
|
||||
const UniValue& err_code = error.find_value("code");
|
||||
const UniValue& err_msg = error.find_value("message");
|
||||
if (!err_code.isNull()) {
|
||||
strPrint = "error code: " + err_code.getValStr() + "\n";
|
||||
}
|
||||
@@ -925,15 +925,15 @@ static void GetWalletBalances(UniValue& result)
|
||||
{
|
||||
DefaultRequestHandler rh;
|
||||
const UniValue listwallets = ConnectAndCallRPC(&rh, "listwallets", /* args=*/{});
|
||||
if (!find_value(listwallets, "error").isNull()) return;
|
||||
const UniValue& wallets = find_value(listwallets, "result");
|
||||
if (!listwallets.find_value("error").isNull()) return;
|
||||
const UniValue& wallets = listwallets.find_value("result");
|
||||
if (wallets.size() <= 1) return;
|
||||
|
||||
UniValue balances(UniValue::VOBJ);
|
||||
for (const UniValue& wallet : wallets.getValues()) {
|
||||
const std::string& wallet_name = wallet.get_str();
|
||||
const UniValue getbalances = ConnectAndCallRPC(&rh, "getbalances", /* args=*/{}, wallet_name);
|
||||
const UniValue& balance = find_value(getbalances, "result")["mine"]["trusted"];
|
||||
const UniValue& balance = getbalances.find_value("result")["mine"]["trusted"];
|
||||
balances.pushKV(wallet_name, balance);
|
||||
}
|
||||
result.pushKV("balances", balances);
|
||||
@@ -969,7 +969,7 @@ static void GetProgressBar(double progress, std::string& progress_bar)
|
||||
*/
|
||||
static void ParseGetInfoResult(UniValue& result)
|
||||
{
|
||||
if (!find_value(result, "error").isNull()) return;
|
||||
if (!result.find_value("error").isNull()) return;
|
||||
|
||||
std::string RESET, GREEN, BLUE, YELLOW, MAGENTA, CYAN;
|
||||
bool should_colorize = false;
|
||||
@@ -1181,9 +1181,9 @@ static int CommandLineRPC(int argc, char *argv[])
|
||||
rh.reset(new NetinfoRequestHandler());
|
||||
} else if (gArgs.GetBoolArg("-generate", false)) {
|
||||
const UniValue getnewaddress{GetNewAddress()};
|
||||
const UniValue& error{find_value(getnewaddress, "error")};
|
||||
const UniValue& error{getnewaddress.find_value("error")};
|
||||
if (error.isNull()) {
|
||||
SetGenerateToAddressArgs(find_value(getnewaddress, "result").get_str(), args);
|
||||
SetGenerateToAddressArgs(getnewaddress.find_value("result").get_str(), args);
|
||||
rh.reset(new GenerateToAddressRequestHandler());
|
||||
} else {
|
||||
ParseError(error, strPrint, nRet);
|
||||
@@ -1205,8 +1205,8 @@ static int CommandLineRPC(int argc, char *argv[])
|
||||
const UniValue reply = ConnectAndCallRPC(rh.get(), method, args, wallet_name);
|
||||
|
||||
// Parse reply
|
||||
UniValue result = find_value(reply, "result");
|
||||
const UniValue& error = find_value(reply, "error");
|
||||
UniValue result = reply.find_value("result");
|
||||
const UniValue& error = reply.find_value("error");
|
||||
if (error.isNull()) {
|
||||
if (gArgs.GetBoolArg("-getinfo", false)) {
|
||||
if (!gArgs.IsArgSet("-rpcwallet")) {
|
||||
|
||||
Reference in New Issue
Block a user