Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 2,886 Lines • ▼ Show 20 Lines | static UniValue getwalletinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
CWallet *const pwallet = wallet.get(); | CWallet *const pwallet = wallet.get(); | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
if (request.fHelp || request.params.size() != 0) { | const RPCHelpMan help{ | ||||
throw std::runtime_error(RPCHelpMan{ | |||||
"getwalletinfo", | "getwalletinfo", | ||||
"Returns an object containing various wallet state info.\n", | "Returns an object containing various wallet state info.\n", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | "{\n" | ||||
" \"walletname\": xxxxx, (string) the wallet " | " \"walletname\": xxxxx, (string) the wallet name\n" | ||||
"name\n" | |||||
" \"walletversion\": xxxxx, (numeric) the wallet " | " \"walletversion\": xxxxx, (numeric) the wallet " | ||||
"version\n" | "version\n" | ||||
" \"balance\": xxxxxxx, (numeric) the total " | " \"balance\": xxxxxxx, (numeric) the total " | ||||
"confirmed balance of the wallet in " + | "confirmed balance of the wallet in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
"\n" | "\n" | ||||
" \"unconfirmed_balance\": xxx, (numeric) the total " | " \"unconfirmed_balance\": xxx, (numeric) the total " | ||||
"unconfirmed balance of the wallet in " + | "unconfirmed balance of the wallet in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
"\n" | "\n" | ||||
" \"immature_balance\": xxxxxx, (numeric) the total " | " \"immature_balance\": xxxxxx, (numeric) the total immature " | ||||
"immature balance of the wallet in " + | "balance of the wallet in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
"\n" | "\n" | ||||
" \"txcount\": xxxxxxx, (numeric) the total " | " \"txcount\": xxxxxxx, (numeric) the total number " | ||||
"number of transactions in the wallet\n" | "of transactions in the wallet\n" | ||||
" \"keypoololdest\": xxxxxx, (numeric) the timestamp " | " \"keypoololdest\": xxxxxx, (numeric) the timestamp " | ||||
"(seconds since Unix epoch) of the oldest pre-generated key in " | "(seconds since Unix epoch) of the oldest pre-generated key in the " | ||||
"the key pool\n" | "key pool\n" | ||||
" \"keypoolsize\": xxxx, (numeric) how many new " | " \"keypoolsize\": xxxx, (numeric) how many new keys " | ||||
"keys are pre-generated (only counts external keys)\n" | "are pre-generated (only counts external keys)\n" | ||||
" \"keypoolsize_hd_internal\": xxxx, (numeric) how many new " | " \"keypoolsize_hd_internal\": xxxx, (numeric) how many new keys " | ||||
"keys are pre-generated for internal use (used for change " | "are pre-generated for internal use (used for change outputs, only " | ||||
"outputs, only appears if the wallet is using this feature, " | "appears if the wallet is using this feature, otherwise external " | ||||
"otherwise external keys are used)\n" | "keys are used)\n" | ||||
" \"unlocked_until\": ttt, (numeric) the timestamp " | " \"unlocked_until\": ttt, (numeric) the timestamp in " | ||||
"in seconds since epoch (midnight Jan 1 1970 GMT) that the " | "seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is " | ||||
"wallet is unlocked for transfers, or 0 if the wallet is " | "unlocked for transfers, or 0 if the wallet is locked\n" | ||||
"locked\n" | " \"paytxfee\": x.xxxx, (numeric) the transaction " | ||||
" \"paytxfee\": x.xxxx, (numeric) the " | "fee configuration, set in " + | ||||
"transaction fee configuration, set in " + | |||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
"/kB\n" | "/kB\n" | ||||
" \"hdseedid\": \"<hash160>\" (string, optional) the " | " \"hdseedid\": \"<hash160>\" (string, optional) the " | ||||
"Hash160 of the HD seed (only present when HD is enabled)\n" | "Hash160 of the HD seed (only present when HD is enabled)\n" | ||||
" \"private_keys_enabled\": true|false (boolean) false if " | " \"private_keys_enabled\": true|false (boolean) false if " | ||||
"privatekeys are disabled for this wallet (enforced watch-only " | "privatekeys are disabled for this wallet (enforced watch-only " | ||||
"wallet)\n" | "wallet)\n" | ||||
"}\n"}, | "}\n"}, | ||||
RPCExamples{HelpExampleCli("getwalletinfo", "") + | RPCExamples{HelpExampleCli("getwalletinfo", "") + | ||||
HelpExampleRpc("getwalletinfo", "")}, | HelpExampleRpc("getwalletinfo", "")}, | ||||
} | }; | ||||
.ToString()); | |||||
if (request.fHelp || !help.IsValidNumArgs(request.params.size())) { | |||||
throw std::runtime_error(help.ToString()); | |||||
} | } | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
// the user could have gotten from another RPC command prior to now | // the user could have gotten from another RPC command prior to now | ||||
pwallet->BlockUntilSyncedToCurrentChain(); | pwallet->BlockUntilSyncedToCurrentChain(); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
▲ Show 20 Lines • Show All 1,850 Lines • Show Last 20 Lines |