MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / getwalletinfo

Function getwalletinfo

src/wallet/rpcwallet.cpp:3003–3069  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3001}
3002
3003static UniValue getwalletinfo(const JSONRPCRequest& request)
3004{
3005 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
3006 CWallet* const pwallet = wallet.get();
3007
3008 if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
3009 return NullUniValue;
3010 }
3011
3012 if (request.fHelp || request.params.size() != 0)
3013 throw std::runtime_error(
3014 "getwalletinfo\n"
3015 "Returns an object containing various wallet state info.\n"
3016 "\nResult:\n"
3017 "{\n"
3018 " \"walletname\": xxxxx, (string) the wallet name\n"
3019 " \"walletversion\": xxxxx, (numeric) the wallet version\n"
3020 " \"balance\": xxxxxxx, (numeric) the total confirmed balance of the wallet in " + CURRENCY_UNIT + "\n"
3021 " \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed balance of the wallet in " + CURRENCY_UNIT + "\n"
3022 " \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet in " + CURRENCY_UNIT + "\n"
3023 " \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n"
3024 " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\n"
3025 " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated (only counts external keys)\n"
3026 " \"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"
3027 " \"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"
3028 " \"paytxfee\": x.xxxx, (numeric) the transaction fee configuration, set in " + CURRENCY_UNIT + "/kB\n"
3029 " \"hdseedid\": \"<hash160>\" (string, optional) the Hash160 of the HD seed (only present when HD is enabled)\n"
3030 " \"hdmasterkeyid\": \"<hash160>\" (string, optional) alias for hdseedid retained for backwards-compatibility. Will be removed in V0.18.\n"
3031 " \"private_keys_enabled\": true|false (boolean) false if privatekeys are disabled for this wallet (enforced watch-only wallet)\n"
3032 "}\n"
3033 "\nExamples:\n"
3034 + HelpExampleCli("getwalletinfo", "")
3035 + HelpExampleRpc("getwalletinfo", "")
3036 );
3037
3038 // Make sure the results are valid at least up to the most recent block
3039 // the user could have gotten from another RPC command prior to now
3040 pwallet->BlockUntilSyncedToCurrentChain();
3041
3042 LOCK2(cs_main, pwallet->cs_wallet);
3043
3044 UniValue obj(UniValue::VOBJ);
3045
3046 size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
3047 obj.pushKV("walletname", pwallet->GetName());
3048 obj.pushKV("walletversion", pwallet->GetVersion());
3049 obj.pushKV("balance", ValueFromAmount(pwallet->GetBalance()));
3050 obj.pushKV("unconfirmed_balance", ValueFromAmount(pwallet->GetUnconfirmedBalance()));
3051 obj.pushKV("immature_balance", ValueFromAmount(pwallet->GetImmatureBalance()));
3052 obj.pushKV("txcount", (int)pwallet->mapWallet.size());
3053 obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime());
3054 obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
3055 CKeyID seed_id = pwallet->GetHDChain().seed_id;
3056 if (!seed_id.IsNull() && pwallet->CanSupportFeature(FEATURE_HD_SPLIT)) {
3057 obj.pushKV("keypoolsize_hd_internal", (int64_t)(pwallet->GetKeyPoolSize() - kpExternalSize));
3058 }
3059 if (pwallet->IsCrypted()) {
3060 obj.pushKV("unlocked_until", pwallet->nRelockTime);

Callers

nothing calls this directly

Calls 15

EnsureWalletIsAvailableFunction · 0.85
HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
ValueFromAmountFunction · 0.85
getMethod · 0.80
GetBalanceMethod · 0.80
GetUnconfirmedBalanceMethod · 0.80
GetImmatureBalanceMethod · 0.80
GetOldestKeyPoolTimeMethod · 0.80
IsCryptedMethod · 0.80

Tested by

no test coverage detected