diff options
author | Jeff Garzik <jgarzik@bitpay.com> | 2014-03-10 13:37:03 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@bitpay.com> | 2014-03-10 13:37:03 -0400 |
commit | a63f8b7b36e39722024a0ba061ca214f00a8f1bd (patch) | |
tree | a3f9c676ca26c1b6271740fa2422d303f96d9893 /src | |
parent | 0ffd87f1c13662c39366e8b2a9b37e08cf8aa185 (diff) | |
parent | a00ebb51176d229683d36cd02a8a26fd63a471a8 (diff) |
Merge pull request #3717 from djpnewton/wallet-txcount
add getwalletinfo RPC call with wallet transaction count
Diffstat (limited to 'src')
-rw-r--r-- | src/rpcserver.cpp | 1 | ||||
-rw-r--r-- | src/rpcserver.h | 1 | ||||
-rw-r--r-- | src/rpcwallet.cpp | 32 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 0c29e1d5f3..2c0cdd345f 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -295,6 +295,7 @@ static const CRPCCommand vRPCCommands[] = { "lockunspent", &lockunspent, false, false, true }, { "listlockunspent", &listlockunspent, false, false, true }, { "settxfee", &settxfee, false, false, true }, + { "getwalletinfo", &getwalletinfo, true, false, true }, /* Wallet-enabled mining */ { "getgenerate", &getgenerate, true, false, false }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 0dd583c8eb..ea03c09bf6 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -163,6 +163,7 @@ extern json_spirit::Value walletlock(const json_spirit::Array& params, bool fHel extern json_spirit::Value encryptwallet(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value validateaddress(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getinfo(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getwalletinfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getrawtransaction(const json_spirit::Array& params, bool fHelp); // in rcprawtransaction.cpp extern json_spirit::Value listunspent(const json_spirit::Array& params, bool fHelp); diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index d3b6c349a7..c8b2127264 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -1888,4 +1888,36 @@ Value settxfee(const Array& params, bool fHelp) return true; } +Value getwalletinfo(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getwalletinfo\n" + "Returns an object containing various wallet state info.\n" + "\nResult:\n" + "{\n" + " \"walletversion\": xxxxx, (numeric) the wallet version\n" + " \"balance\": xxxxxxx, (numeric) the total bitcoin balance of the wallet\n" + " \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n" + " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT 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" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getwalletinfo", "") + + HelpExampleRpc("getwalletinfo", "") + ); + + Object obj; + obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); + obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); + obj.push_back(Pair("txcount", (int)pwalletMain->mapWallet.size())); + obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime())); + obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); + if (pwalletMain->IsCrypted()) + obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime)); + return obj; +} + + |