| 2412 | } |
| 2413 | |
| 2414 | UniValue getwalletinfo(const UniValue& params, bool fHelp) |
| 2415 | { |
| 2416 | if (fHelp || params.size() != 0) |
| 2417 | throw runtime_error( |
| 2418 | "getwalletinfo\n" |
| 2419 | "Returns an object containing various wallet state info.\n" |
| 2420 | "\nResult:\n" |
| 2421 | "{\n" |
| 2422 | " \"walletversion\": xxxxx, (numeric) the wallet version\n" |
| 2423 | " \"balance\": xxxxxxx, (numeric) the total " + CURRENCY_UNIT + " balance of the wallet\n" |
| 2424 | " \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed balance of the wallet in " + CURRENCY_UNIT + "\n" |
| 2425 | " \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet in " + CURRENCY_UNIT + "\n" |
| 2426 | " \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n" |
| 2427 | " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n" |
| 2428 | " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated (only counts external keys)\n" |
| 2429 | " \"keypoolsize_hd_internal\": xxxx, (numeric) how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used)\n" |
| 2430 | " \"keys_left\": xxxx, (numeric) how many new keys are left since last automatic backup\n" |
| 2431 | " \"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" |
| 2432 | " \"paytxfee\": x.xxxx, (numeric) the transaction fee configuration, set in " + CURRENCY_UNIT + "/kB\n" |
| 2433 | " \"hdchainid\": \"<hash>\", (string) the ID of the HD chain\n" |
| 2434 | " \"hdaccountcount\": xxx, (numeric) how many accounts of the HD chain are in this wallet\n" |
| 2435 | " [\n" |
| 2436 | " {\n" |
| 2437 | " \"hdaccountindex\": xxx, (numeric) the index of the account\n" |
| 2438 | " \"hdexternalkeyindex\": xxxx, (numeric) current external childkey index\n" |
| 2439 | " \"hdinternalkeyindex\": xxxx, (numeric) current internal childkey index\n" |
| 2440 | " }\n" |
| 2441 | " ,...\n" |
| 2442 | " ]\n" |
| 2443 | "}\n" |
| 2444 | "\nExamples:\n" + |
| 2445 | HelpExampleCli("getwalletinfo", "") + HelpExampleRpc("getwalletinfo", "")); |
| 2446 | |
| 2447 | LOCK2(cs_main, pwalletMain->cs_wallet); |
| 2448 | |
| 2449 | CHDChain hdChainCurrent; |
| 2450 | bool fHDEnabled = pwalletMain->GetHDChain(hdChainCurrent); |
| 2451 | UniValue obj(UniValue::VOBJ); |
| 2452 | obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); |
| 2453 | obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); |
| 2454 | obj.push_back(Pair("unconfirmed_balance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance()))); |
| 2455 | obj.push_back(Pair("immature_balance", ValueFromAmount(pwalletMain->GetImmatureBalance()))); |
| 2456 | obj.push_back(Pair("txcount", (int)pwalletMain->mapWallet.size())); |
| 2457 | obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); |
| 2458 | obj.push_back(Pair("keypoolsize", (int64_t)pwalletMain->KeypoolCountExternalKeys())); |
| 2459 | if (fHDEnabled) { |
| 2460 | obj.push_back(Pair("keypoolsize_hd_internal", (int64_t)(pwalletMain->KeypoolCountInternalKeys()))); |
| 2461 | } |
| 2462 | if (pwalletMain->IsCrypted()) |
| 2463 | #if 1 |
| 2464 | obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); |
| 2465 | #else |
| 2466 | obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime)); |
| 2467 | #endif |
| 2468 | if (fHDEnabled) { |
| 2469 | obj.push_back(Pair("hdchainid", hdChainCurrent.GetID().GetHex())); |
| 2470 | obj.push_back(Pair("hdaccountcount", (int64_t)hdChainCurrent.CountAccounts())); |
| 2471 | UniValue accounts(UniValue::VARR); |
nothing calls this directly
no test coverage detected