Skip to content

Commit 16bc9aa

Browse files
committed
Move getinfo from rpcnet to rpcmisc
`getinfo` is a general info method which shows information from multiple sources, it doesn't belong in rpcnet.cpp or any of the other current RPC implementation files.
1 parent 652e156 commit 16bc9aa

File tree

2 files changed

+63
-62
lines changed

2 files changed

+63
-62
lines changed

src/rpcmisc.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,66 @@ using namespace boost;
2626
using namespace boost::assign;
2727
using namespace json_spirit;
2828

29+
Value getinfo(const Array& params, bool fHelp)
30+
{
31+
if (fHelp || params.size() != 0)
32+
throw runtime_error(
33+
"getinfo\n"
34+
"Returns an object containing various state info.\n"
35+
"\nResult:\n"
36+
"{\n"
37+
" \"version\": xxxxx, (numeric) the server version\n"
38+
" \"protocolversion\": xxxxx, (numeric) the protocol version\n"
39+
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
40+
" \"balance\": xxxxxxx, (numeric) the total bitcoin balance of the wallet\n"
41+
" \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
42+
" \"timeoffset\": xxxxx, (numeric) the time offset\n"
43+
" \"connections\": xxxxx, (numeric) the number of connections\n"
44+
" \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
45+
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
46+
" \"testnet\": true|false, (boolean) if the server is using testnet or not\n"
47+
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n"
48+
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
49+
" \"paytxfee\": x.xxxx, (numeric) the transaction fee set in btc\n"
50+
" \"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"
51+
" \"errors\": \"...\" (string) any error messages\n"
52+
"}\n"
53+
"\nExamples:\n"
54+
+ HelpExampleCli("getinfo", "")
55+
+ HelpExampleRpc("getinfo", "")
56+
);
57+
58+
proxyType proxy;
59+
GetProxy(NET_IPV4, proxy);
60+
61+
Object obj;
62+
obj.push_back(Pair("version", (int)CLIENT_VERSION));
63+
obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION));
64+
#ifdef ENABLE_WALLET
65+
if (pwalletMain) {
66+
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
67+
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
68+
}
69+
#endif
70+
obj.push_back(Pair("blocks", (int)chainActive.Height()));
71+
obj.push_back(Pair("timeoffset", (boost::int64_t)GetTimeOffset()));
72+
obj.push_back(Pair("connections", (int)vNodes.size()));
73+
obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string())));
74+
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
75+
obj.push_back(Pair("testnet", TestNet()));
76+
#ifdef ENABLE_WALLET
77+
if (pwalletMain) {
78+
obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime()));
79+
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize()));
80+
}
81+
#endif
82+
obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee)));
83+
#ifdef ENABLE_WALLET
84+
if (pwalletMain && pwalletMain->IsCrypted())
85+
obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime));
86+
#endif
87+
obj.push_back(Pair("errors", GetWarnings("statusbar")));
88+
return obj;
89+
}
90+
91+

src/rpcnet.cpp

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -338,65 +338,3 @@ Value getnettotals(const Array& params, bool fHelp)
338338
obj.push_back(Pair("timemillis", static_cast<boost::int64_t>(GetTimeMillis())));
339339
return obj;
340340
}
341-
342-
Value getinfo(const Array& params, bool fHelp)
343-
{
344-
if (fHelp || params.size() != 0)
345-
throw runtime_error(
346-
"getinfo\n"
347-
"Returns an object containing various state info.\n"
348-
"\nResult:\n"
349-
"{\n"
350-
" \"version\": xxxxx, (numeric) the server version\n"
351-
" \"protocolversion\": xxxxx, (numeric) the protocol version\n"
352-
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
353-
" \"balance\": xxxxxxx, (numeric) the total bitcoin balance of the wallet\n"
354-
" \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
355-
" \"timeoffset\": xxxxx, (numeric) the time offset\n"
356-
" \"connections\": xxxxx, (numeric) the number of connections\n"
357-
" \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
358-
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
359-
" \"testnet\": true|false, (boolean) if the server is using testnet or not\n"
360-
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n"
361-
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
362-
" \"paytxfee\": x.xxxx, (numeric) the transaction fee set in btc\n"
363-
" \"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"
364-
" \"errors\": \"...\" (string) any error messages\n"
365-
"}\n"
366-
"\nExamples:\n"
367-
+ HelpExampleCli("getinfo", "")
368-
+ HelpExampleRpc("getinfo", "")
369-
);
370-
371-
proxyType proxy;
372-
GetProxy(NET_IPV4, proxy);
373-
374-
Object obj;
375-
obj.push_back(Pair("version", (int)CLIENT_VERSION));
376-
obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION));
377-
#ifdef ENABLE_WALLET
378-
if (pwalletMain) {
379-
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
380-
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
381-
}
382-
#endif
383-
obj.push_back(Pair("blocks", (int)chainActive.Height()));
384-
obj.push_back(Pair("timeoffset", (boost::int64_t)GetTimeOffset()));
385-
obj.push_back(Pair("connections", (int)vNodes.size()));
386-
obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string())));
387-
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
388-
obj.push_back(Pair("testnet", TestNet()));
389-
#ifdef ENABLE_WALLET
390-
if (pwalletMain) {
391-
obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime()));
392-
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize()));
393-
}
394-
#endif
395-
obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee)));
396-
#ifdef ENABLE_WALLET
397-
if (pwalletMain && pwalletMain->IsCrypted())
398-
obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime));
399-
#endif
400-
obj.push_back(Pair("errors", GetWarnings("statusbar")));
401-
return obj;
402-
}

0 commit comments

Comments
 (0)