mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-22 14:52:41 +02:00
cli -getinfo: use getbalances instead of deprecated getwalletinfo balance
This commit is contained in:
parent
661bd5dea3
commit
75019774c9
@ -228,6 +228,7 @@ public:
|
||||
const int ID_NETWORKINFO = 0;
|
||||
const int ID_BLOCKCHAININFO = 1;
|
||||
const int ID_WALLETINFO = 2;
|
||||
const int ID_BALANCES = 3;
|
||||
|
||||
/** Create a simulated `getinfo` request. */
|
||||
UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) override
|
||||
@ -239,6 +240,7 @@ public:
|
||||
result.push_back(JSONRPCRequestObj("getnetworkinfo", NullUniValue, ID_NETWORKINFO));
|
||||
result.push_back(JSONRPCRequestObj("getblockchaininfo", NullUniValue, ID_BLOCKCHAININFO));
|
||||
result.push_back(JSONRPCRequestObj("getwalletinfo", NullUniValue, ID_WALLETINFO));
|
||||
result.push_back(JSONRPCRequestObj("getbalances", NullUniValue, ID_BALANCES));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -246,9 +248,9 @@ public:
|
||||
UniValue ProcessReply(const UniValue &batch_in) override
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
std::vector<UniValue> batch = JSONRPCProcessBatchReply(batch_in, 3);
|
||||
// Errors in getnetworkinfo() and getblockchaininfo() are fatal, pass them on
|
||||
// getwalletinfo() is allowed to fail in case there is no wallet.
|
||||
std::vector<UniValue> batch = JSONRPCProcessBatchReply(batch_in, batch_in.size());
|
||||
// Errors in getnetworkinfo() and getblockchaininfo() are fatal, pass them on;
|
||||
// getwalletinfo() and getbalances() are allowed to fail if there is no wallet.
|
||||
if (!batch[ID_NETWORKINFO]["error"].isNull()) {
|
||||
return batch[ID_NETWORKINFO];
|
||||
}
|
||||
@ -265,13 +267,15 @@ public:
|
||||
result.pushKV("difficulty", batch[ID_BLOCKCHAININFO]["result"]["difficulty"]);
|
||||
result.pushKV("chain", UniValue(batch[ID_BLOCKCHAININFO]["result"]["chain"]));
|
||||
if (!batch[ID_WALLETINFO]["result"].isNull()) {
|
||||
result.pushKV("balance", batch[ID_WALLETINFO]["result"]["balance"]);
|
||||
result.pushKV("keypoolsize", batch[ID_WALLETINFO]["result"]["keypoolsize"]);
|
||||
if (!batch[ID_WALLETINFO]["result"]["unlocked_until"].isNull()) {
|
||||
result.pushKV("unlocked_until", batch[ID_WALLETINFO]["result"]["unlocked_until"]);
|
||||
}
|
||||
result.pushKV("paytxfee", batch[ID_WALLETINFO]["result"]["paytxfee"]);
|
||||
}
|
||||
if (!batch[ID_BALANCES]["result"].isNull()) {
|
||||
result.pushKV("balance", batch[ID_BALANCES]["result"]["mine"]["trusted"]);
|
||||
}
|
||||
result.pushKV("relayfee", batch[ID_NETWORKINFO]["result"]["relayfee"]);
|
||||
result.pushKV("warnings", batch[ID_NETWORKINFO]["result"]["warnings"]);
|
||||
return JSONRPCReplyObj(result, NullUniValue, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user