Skip to content

Commit a00ebb5

Browse files
committed
move wallet info stuff to "getwalletinfo" rpc (left original wallet
stuff in getinfo call for backwards compatibility) add wallet transaction count to getwalletinfo rpc call
1 parent 76a7705 commit a00ebb5

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/rpcserver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ static const CRPCCommand vRPCCommands[] =
296296
{ "lockunspent", &lockunspent, false, false, true },
297297
{ "listlockunspent", &listlockunspent, false, false, true },
298298
{ "settxfee", &settxfee, false, false, true },
299+
{ "getwalletinfo", &getwalletinfo, true, false, true },
299300

300301
/* Wallet-enabled mining */
301302
{ "getgenerate", &getgenerate, true, false, false },

src/rpcserver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ extern json_spirit::Value walletlock(const json_spirit::Array& params, bool fHel
163163
extern json_spirit::Value encryptwallet(const json_spirit::Array& params, bool fHelp);
164164
extern json_spirit::Value validateaddress(const json_spirit::Array& params, bool fHelp);
165165
extern json_spirit::Value getinfo(const json_spirit::Array& params, bool fHelp);
166+
extern json_spirit::Value getwalletinfo(const json_spirit::Array& params, bool fHelp);
166167

167168
extern json_spirit::Value getrawtransaction(const json_spirit::Array& params, bool fHelp); // in rcprawtransaction.cpp
168169
extern json_spirit::Value listunspent(const json_spirit::Array& params, bool fHelp);

src/rpcwallet.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,4 +1893,36 @@ Value settxfee(const Array& params, bool fHelp)
18931893
return true;
18941894
}
18951895

1896+
Value getwalletinfo(const Array& params, bool fHelp)
1897+
{
1898+
if (fHelp || params.size() != 0)
1899+
throw runtime_error(
1900+
"getwalletinfo\n"
1901+
"Returns an object containing various wallet state info.\n"
1902+
"\nResult:\n"
1903+
"{\n"
1904+
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
1905+
" \"balance\": xxxxxxx, (numeric) the total bitcoin balance of the wallet\n"
1906+
" \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n"
1907+
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n"
1908+
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
1909+
" \"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"
1910+
"}\n"
1911+
"\nExamples:\n"
1912+
+ HelpExampleCli("getwalletinfo", "")
1913+
+ HelpExampleRpc("getwalletinfo", "")
1914+
);
1915+
1916+
Object obj;
1917+
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
1918+
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
1919+
obj.push_back(Pair("txcount", (int)pwalletMain->mapWallet.size()));
1920+
obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime()));
1921+
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize()));
1922+
if (pwalletMain->IsCrypted())
1923+
obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime));
1924+
return obj;
1925+
}
1926+
1927+
18961928

0 commit comments

Comments
 (0)