Skip to content

Commit f54f200

Browse files
committed
(finally) remove getinfo in favor of more module-specific infos
1 parent a90e6d2 commit f54f200

File tree

5 files changed

+13
-99
lines changed

5 files changed

+13
-99
lines changed

src/rpc/misc.cpp

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -31,94 +31,6 @@
3131

3232
#include <univalue.h>
3333

34-
/**
35-
* @note Do not add or change anything in the information returned by this
36-
* method. `getinfo` exists for backwards-compatibility only. It combines
37-
* information from wildly different sources in the program, which is a mess,
38-
* and is thus planned to be deprecated eventually.
39-
*
40-
* Based on the source of the information, new information should be added to:
41-
* - `getblockchaininfo`,
42-
* - `getnetworkinfo` or
43-
* - `getwalletinfo`
44-
*
45-
* Or alternatively, create a specific query method for the information.
46-
**/
47-
UniValue getinfo(const JSONRPCRequest& request)
48-
{
49-
if (request.fHelp || request.params.size() != 0)
50-
throw std::runtime_error(
51-
"getinfo\n"
52-
"\nDEPRECATED. Returns an object containing various state info.\n"
53-
"\nResult:\n"
54-
"{\n"
55-
" \"deprecation-warning\": \"...\" (string) warning that the getinfo command is deprecated and will be removed in 0.16\n"
56-
" \"version\": xxxxx, (numeric) the server version\n"
57-
" \"protocolversion\": xxxxx, (numeric) the protocol version\n"
58-
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
59-
" \"balance\": xxxxxxx, (numeric) the total bitcoin balance of the wallet\n"
60-
" \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
61-
" \"timeoffset\": xxxxx, (numeric) the time offset\n"
62-
" \"connections\": xxxxx, (numeric) the number of connections\n"
63-
" \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
64-
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
65-
" \"testnet\": true|false, (boolean) if the server is using testnet or not\n"
66-
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\n"
67-
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
68-
" \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
69-
" \"paytxfee\": x.xxxx, (numeric) the transaction fee set in " + CURRENCY_UNIT + "/kB\n"
70-
" \"relayfee\": x.xxxx, (numeric) minimum relay fee for transactions in " + CURRENCY_UNIT + "/kB\n"
71-
" \"errors\": \"...\" (string) any error messages\n"
72-
"}\n"
73-
"\nExamples:\n"
74-
+ HelpExampleCli("getinfo", "")
75-
+ HelpExampleRpc("getinfo", "")
76-
);
77-
78-
#ifdef ENABLE_WALLET
79-
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
80-
81-
LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr);
82-
#else
83-
LOCK(cs_main);
84-
#endif
85-
86-
proxyType proxy;
87-
GetProxy(NET_IPV4, proxy);
88-
89-
UniValue obj(UniValue::VOBJ);
90-
obj.push_back(Pair("deprecation-warning", "WARNING: getinfo is deprecated and will be fully removed in 0.16."
91-
" Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16"));
92-
obj.push_back(Pair("version", CLIENT_VERSION));
93-
obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
94-
#ifdef ENABLE_WALLET
95-
if (pwallet) {
96-
obj.push_back(Pair("walletversion", pwallet->GetVersion()));
97-
obj.push_back(Pair("balance", ValueFromAmount(pwallet->GetBalance())));
98-
}
99-
#endif
100-
obj.push_back(Pair("blocks", (int)chainActive.Height()));
101-
obj.push_back(Pair("timeoffset", GetTimeOffset()));
102-
if(g_connman)
103-
obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL)));
104-
obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string())));
105-
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
106-
obj.push_back(Pair("testnet", Params().NetworkIDString() == CBaseChainParams::TESTNET));
107-
#ifdef ENABLE_WALLET
108-
if (pwallet) {
109-
obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime()));
110-
obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize()));
111-
}
112-
if (pwallet && pwallet->IsCrypted()) {
113-
obj.push_back(Pair("unlocked_until", pwallet->nRelockTime));
114-
}
115-
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
116-
#endif
117-
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
118-
obj.push_back(Pair("errors", GetWarnings("statusbar")));
119-
return obj;
120-
}
121-
12234
#ifdef ENABLE_WALLET
12335
class DescribeAddressVisitor : public boost::static_visitor<UniValue>
12436
{
@@ -651,7 +563,6 @@ UniValue echo(const JSONRPCRequest& request)
651563
static const CRPCCommand commands[] =
652564
{ // category name actor (function) okSafeMode
653565
// --------------------- ------------------------ ----------------------- ----------
654-
{ "control", "getinfo", &getinfo, true, {} }, /* uses wallet if enabled */
655566
{ "control", "getmemoryinfo", &getmemoryinfo, true, {"mode"} },
656567
{ "util", "validateaddress", &validateaddress, true, {"address"} }, /* uses wallet if enabled */
657568
{ "util", "createmultisig", &createmultisig, true, {"nrequired","keys"} },

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ enum class FeeEstimateMode;
8787
/** (client) version numbers for particular wallet features */
8888
enum WalletFeature
8989
{
90-
FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getinfo's clientversion output)
90+
FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getwalletinfo's clientversion output)
9191

9292
FEATURE_WALLETCRYPT = 40000, // wallet encryption
9393
FEATURE_COMPRPUBKEY = 60000, // compressed public keys

test/functional/bitcoin_cli.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ def __init__(self):
1616
def run_test(self):
1717
"""Main test logic"""
1818

19-
self.log.info("Compare responses from getinfo RPC and `bitcoin-cli getinfo`")
20-
cli_get_info = self.nodes[0].cli.getinfo()
21-
rpc_get_info = self.nodes[0].getinfo()
19+
self.log.info("Compare responses from gewallettinfo RPC and `bitcoin-cli getwalletinfo`")
20+
cli_get_info = self.nodes[0].cli.getwalletinfo()
21+
rpc_get_info = self.nodes[0].getwalletinfo()
22+
23+
assert_equal(cli_get_info, rpc_get_info)
24+
25+
self.log.info("Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`")
26+
cli_get_info = self.nodes[0].cli.getblockchaininfo()
27+
rpc_get_info = self.nodes[0].getblockchaininfo()
2228

2329
assert_equal(cli_get_info, rpc_get_info)
2430

test/functional/p2p-versionbits-warning.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ def run_test(self):
8888
self.nodes[0].generate(VB_PERIOD - VB_THRESHOLD + 1)
8989
# Check that we're not getting any versionbit-related errors in
9090
# get*info()
91-
assert(not VB_PATTERN.match(self.nodes[0].getinfo()["errors"]))
9291
assert(not VB_PATTERN.match(self.nodes[0].getmininginfo()["errors"]))
9392
assert(not VB_PATTERN.match(self.nodes[0].getnetworkinfo()["warnings"]))
9493

@@ -100,7 +99,6 @@ def run_test(self):
10099
# have gotten a different alert due to more than 51/100 blocks
101100
# being of unexpected version.
102101
# Check that get*info() shows some kind of error.
103-
assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getinfo()["errors"])
104102
assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getmininginfo()["errors"])
105103
assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getnetworkinfo()["warnings"])
106104

@@ -116,7 +114,6 @@ def run_test(self):
116114

117115
# Connecting one block should be enough to generate an error.
118116
self.nodes[0].generate(1)
119-
assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getinfo()["errors"])
120117
assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getmininginfo()["errors"])
121118
assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getnetworkinfo()["warnings"])
122119
self.stop_nodes()

test/functional/rpcnamedargs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def __init__(self):
2323

2424
def run_test(self):
2525
node = self.nodes[0]
26-
h = node.help(command='getinfo')
27-
assert(h.startswith('getinfo\n'))
26+
h = node.help(command='getblockchaininfo')
27+
assert(h.startswith('getblockchaininfo\n'))
2828

29-
assert_raises_jsonrpc(-8, 'Unknown named parameter', node.help, random='getinfo')
29+
assert_raises_jsonrpc(-8, 'Unknown named parameter', node.help, random='getblockchaininfo')
3030

3131
h = node.getblockhash(height=0)
3232
node.getblock(blockhash=h)

0 commit comments

Comments
 (0)