Browse Source

Merge #10838: (finally) remove getinfo

aece8a463 (finally) remove getinfo in favor of more module-specific infos (Matt Corallo)

Pull request description:

  I see no reason not to have done this in 0.13, let alone for 0.15.

Tree-SHA512: ed3e36f99e9cb90304089e5957ddfbf74141e3e77d850e498e9e45dd8bc1deb9fe36b3fec4c43243023268670a45808de3c23d660df76fa27db6688814c464a5
0.16
Wladimir J. van der Laan 7 years ago
parent
commit
66a5b419ef
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
  1. 4
      doc/developer-notes.md
  2. 89
      src/rpc/misc.cpp
  3. 2
      src/wallet/wallet.h
  4. 12
      test/functional/bitcoin_cli.py
  5. 3
      test/functional/p2p-versionbits-warning.py
  6. 6
      test/functional/rpcnamedargs.py

4
doc/developer-notes.md

@ -613,8 +613,8 @@ A few guidelines for introducing and reviewing new RPC interfaces:
from there. from there.
- A RPC method must either be a wallet method or a non-wallet method. Do not - A RPC method must either be a wallet method or a non-wallet method. Do not
introduce new methods such as `getinfo` and `signrawtransaction` that differ introduce new methods such as `signrawtransaction` that differ in behavior
in behavior based on presence of a wallet. based on presence of a wallet.
- *Rationale*: as well as complicating the implementation and interfering - *Rationale*: as well as complicating the implementation and interfering
with the introduction of multi-wallet, wallet and non-wallet code should be with the introduction of multi-wallet, wallet and non-wallet code should be

89
src/rpc/misc.cpp

@ -31,94 +31,6 @@
#include <univalue.h> #include <univalue.h>
/**
* @note Do not add or change anything in the information returned by this
* method. `getinfo` exists for backwards-compatibility only. It combines
* information from wildly different sources in the program, which is a mess,
* and is thus planned to be deprecated eventually.
*
* Based on the source of the information, new information should be added to:
* - `getblockchaininfo`,
* - `getnetworkinfo` or
* - `getwalletinfo`
*
* Or alternatively, create a specific query method for the information.
**/
UniValue getinfo(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
"getinfo\n"
"\nDEPRECATED. Returns an object containing various state info.\n"
"\nResult:\n"
"{\n"
" \"deprecation-warning\": \"...\" (string) warning that the getinfo command is deprecated and will be removed in 0.16\n"
" \"version\": xxxxx, (numeric) the server version\n"
" \"protocolversion\": xxxxx, (numeric) the protocol version\n"
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
" \"balance\": xxxxxxx, (numeric) the total bitcoin balance of the wallet\n"
" \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
" \"timeoffset\": xxxxx, (numeric) the time offset\n"
" \"connections\": xxxxx, (numeric) the number of connections\n"
" \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
" \"testnet\": true|false, (boolean) if the server is using testnet or not\n"
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\n"
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
" \"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"
" \"paytxfee\": x.xxxx, (numeric) the transaction fee set in " + CURRENCY_UNIT + "/kB\n"
" \"relayfee\": x.xxxx, (numeric) minimum relay fee for transactions in " + CURRENCY_UNIT + "/kB\n"
" \"errors\": \"...\" (string) any error messages\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getinfo", "")
+ HelpExampleRpc("getinfo", "")
);
#ifdef ENABLE_WALLET
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr);
#else
LOCK(cs_main);
#endif
proxyType proxy;
GetProxy(NET_IPV4, proxy);
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("deprecation-warning", "WARNING: getinfo is deprecated and will be fully removed in 0.16."
" Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16"));
obj.push_back(Pair("version", CLIENT_VERSION));
obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
#ifdef ENABLE_WALLET
if (pwallet) {
obj.push_back(Pair("walletversion", pwallet->GetVersion()));
obj.push_back(Pair("balance", ValueFromAmount(pwallet->GetBalance())));
}
#endif
obj.push_back(Pair("blocks", (int)chainActive.Height()));
obj.push_back(Pair("timeoffset", GetTimeOffset()));
if(g_connman)
obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL)));
obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string())));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("testnet", Params().NetworkIDString() == CBaseChainParams::TESTNET));
#ifdef ENABLE_WALLET
if (pwallet) {
obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize()));
}
if (pwallet && pwallet->IsCrypted()) {
obj.push_back(Pair("unlocked_until", pwallet->nRelockTime));
}
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
#endif
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
return obj;
}
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
class DescribeAddressVisitor : public boost::static_visitor<UniValue> class DescribeAddressVisitor : public boost::static_visitor<UniValue>
{ {
@ -651,7 +563,6 @@ UniValue echo(const JSONRPCRequest& request)
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) argNames { // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ---------- // --------------------- ------------------------ ----------------------- ----------
{ "control", "getinfo", &getinfo, {} }, /* uses wallet if enabled */
{ "control", "getmemoryinfo", &getmemoryinfo, {"mode"} }, { "control", "getmemoryinfo", &getmemoryinfo, {"mode"} },
{ "util", "validateaddress", &validateaddress, {"address"} }, /* uses wallet if enabled */ { "util", "validateaddress", &validateaddress, {"address"} }, /* uses wallet if enabled */
{ "util", "createmultisig", &createmultisig, {"nrequired","keys"} }, { "util", "createmultisig", &createmultisig, {"nrequired","keys"} },

2
src/wallet/wallet.h

@ -87,7 +87,7 @@ enum class FeeEstimateMode;
/** (client) version numbers for particular wallet features */ /** (client) version numbers for particular wallet features */
enum WalletFeature enum WalletFeature
{ {
FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getinfo's clientversion output) FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getwalletinfo's clientversion output)
FEATURE_WALLETCRYPT = 40000, // wallet encryption FEATURE_WALLETCRYPT = 40000, // wallet encryption
FEATURE_COMPRPUBKEY = 60000, // compressed public keys FEATURE_COMPRPUBKEY = 60000, // compressed public keys

12
test/functional/bitcoin_cli.py

@ -15,9 +15,15 @@ class TestBitcoinCli(BitcoinTestFramework):
def run_test(self): def run_test(self):
"""Main test logic""" """Main test logic"""
self.log.info("Compare responses from getinfo RPC and `bitcoin-cli getinfo`") self.log.info("Compare responses from gewalletinfo RPC and `bitcoin-cli getwalletinfo`")
cli_get_info = self.nodes[0].cli.getinfo() cli_get_info = self.nodes[0].cli.getwalletinfo()
rpc_get_info = self.nodes[0].getinfo() rpc_get_info = self.nodes[0].getwalletinfo()
assert_equal(cli_get_info, rpc_get_info)
self.log.info("Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`")
cli_get_info = self.nodes[0].cli.getblockchaininfo()
rpc_get_info = self.nodes[0].getblockchaininfo()
assert_equal(cli_get_info, rpc_get_info) assert_equal(cli_get_info, rpc_get_info)

3
test/functional/p2p-versionbits-warning.py

@ -87,7 +87,6 @@ class VersionBitsWarningTest(BitcoinTestFramework):
self.nodes[0].generate(VB_PERIOD - VB_THRESHOLD + 1) self.nodes[0].generate(VB_PERIOD - VB_THRESHOLD + 1)
# Check that we're not getting any versionbit-related errors in # Check that we're not getting any versionbit-related errors in
# get*info() # get*info()
assert(not VB_PATTERN.match(self.nodes[0].getinfo()["errors"]))
assert(not VB_PATTERN.match(self.nodes[0].getmininginfo()["errors"])) assert(not VB_PATTERN.match(self.nodes[0].getmininginfo()["errors"]))
assert(not VB_PATTERN.match(self.nodes[0].getnetworkinfo()["warnings"])) assert(not VB_PATTERN.match(self.nodes[0].getnetworkinfo()["warnings"]))
@ -99,7 +98,6 @@ class VersionBitsWarningTest(BitcoinTestFramework):
# have gotten a different alert due to more than 51/100 blocks # have gotten a different alert due to more than 51/100 blocks
# being of unexpected version. # being of unexpected version.
# Check that get*info() shows some kind of error. # Check that get*info() shows some kind of error.
assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getinfo()["errors"])
assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getmininginfo()["errors"]) assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getmininginfo()["errors"])
assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getnetworkinfo()["warnings"]) assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getnetworkinfo()["warnings"])
@ -115,7 +113,6 @@ class VersionBitsWarningTest(BitcoinTestFramework):
# Connecting one block should be enough to generate an error. # Connecting one block should be enough to generate an error.
self.nodes[0].generate(1) self.nodes[0].generate(1)
assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getinfo()["errors"])
assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getmininginfo()["errors"]) assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getmininginfo()["errors"])
assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getnetworkinfo()["warnings"]) assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getnetworkinfo()["warnings"])
self.stop_nodes() self.stop_nodes()

6
test/functional/rpcnamedargs.py

@ -16,10 +16,10 @@ class NamedArgumentTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
node = self.nodes[0] node = self.nodes[0]
h = node.help(command='getinfo') h = node.help(command='getblockchaininfo')
assert(h.startswith('getinfo\n')) assert(h.startswith('getblockchaininfo\n'))
assert_raises_jsonrpc(-8, 'Unknown named parameter', node.help, random='getinfo') assert_raises_jsonrpc(-8, 'Unknown named parameter', node.help, random='getblockchaininfo')
h = node.getblockhash(height=0) h = node.getblockhash(height=0)
node.getblock(blockhash=h) node.getblock(blockhash=h)

Loading…
Cancel
Save