diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -3,3 +3,4 @@ This release includes the following features and fixes: + - Remove `getinfo` RPC in favor of `getblockchaininfo`, `getnetworkinfo` and `getwalletinfo`. diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -33,110 +33,6 @@ #include #endif -/** - * @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. - **/ -static UniValue getinfo(const Config &config, 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" - " \"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 " - "non-free 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.pushKV("version", CLIENT_VERSION); - obj.pushKV("protocolversion", PROTOCOL_VERSION); -#ifdef ENABLE_WALLET - if (pwallet) { - obj.pushKV("walletversion", pwallet->GetVersion()); - obj.pushKV("balance", ValueFromAmount(pwallet->GetBalance())); - } -#endif - obj.pushKV("blocks", (int)chainActive.Height()); - obj.pushKV("timeoffset", GetTimeOffset()); - if (g_connman) { - obj.pushKV("connections", - (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL)); - } - obj.pushKV("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() - : std::string())); - obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); - obj.pushKV("testnet", config.GetChainParams().NetworkIDString() == - CBaseChainParams::TESTNET); -#ifdef ENABLE_WALLET - if (pwallet) { - obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime()); - obj.pushKV("keypoolsize", (int)pwallet->GetKeyPoolSize()); - } - if (pwallet && pwallet->IsCrypted()) { - obj.pushKV("unlocked_until", pwallet->nRelockTime); - } - obj.pushKV("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())); -#endif - obj.pushKV("relayfee", - ValueFromAmount(config.GetMinFeePerKB().GetFeePerK())); - obj.pushKV("errors", GetWarnings("statusbar")); - return obj; -} - #ifdef ENABLE_WALLET class DescribeAddressVisitor : public boost::static_visitor { public: @@ -710,7 +606,6 @@ static const ContextFreeRPCCommand commands[] = { // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- - { "control", "getinfo", getinfo, {} }, /* uses wallet if enabled */ { "control", "getmemoryinfo", getmemoryinfo, {"mode"} }, { "util", "validateaddress", validateaddress, {"address"} }, /* uses wallet if enabled */ { "util", "createmultisig", createmultisig, {"nrequired","keys"} }, diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -73,8 +73,8 @@ /** (client) version numbers for particular wallet features */ enum WalletFeature { - // the earliest version new wallets supports (only useful for getinfo's - // clientversion output) + // the earliest version new wallets supports (only useful for + // getwalletinfo's clientversion output) FEATURE_BASE = 10500, // wallet encryption diff --git a/test/functional/rpc_named_arguments.py b/test/functional/rpc_named_arguments.py --- a/test/functional/rpc_named_arguments.py +++ b/test/functional/rpc_named_arguments.py @@ -13,11 +13,11 @@ def run_test(self): node = self.nodes[0] - h = node.help(command='getinfo') - assert(h.startswith('getinfo\n')) + h = node.help(command='getblockchaininfo') + assert(h.startswith('getblockchaininfo\n')) assert_raises_rpc_error(-8, 'Unknown named parameter', - node.help, random='getinfo') + node.help, random='getblockchaininfo') h = node.getblockhash(height=0) node.getblock(blockhash=h)