Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 2,915 Lines • ▼ Show 20 Lines | static UniValue getwalletinfo(const Config &config, | ||||
} | } | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getwalletinfo\n" | "getwalletinfo\n" | ||||
"Returns an object containing various wallet state info.\n" | "Returns an object containing various wallet state info.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"walletname\": xxxxx, (string) the wallet 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 + "\n" | CURRENCY_UNIT + "\n" | ||||
" \"unconfirmed_balance\": xxx, (numeric) " | " \"unconfirmed_balance\": xxx, (numeric) " | ||||
"the total unconfirmed balance of the wallet in " + | "the total unconfirmed balance of the wallet in " + | ||||
CURRENCY_UNIT + "\n" | CURRENCY_UNIT + "\n" | ||||
Show All 26 Lines | if (request.fHelp || request.params.size() != 0) { | ||||
HelpExampleRpc("getwalletinfo", "")); | HelpExampleRpc("getwalletinfo", "")); | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
size_t kpExternalSize = pwallet->KeypoolCountExternalKeys(); | size_t kpExternalSize = pwallet->KeypoolCountExternalKeys(); | ||||
obj.push_back(Pair("walletname", pwallet->GetName())); | |||||
obj.push_back(Pair("walletversion", pwallet->GetVersion())); | obj.push_back(Pair("walletversion", pwallet->GetVersion())); | ||||
obj.push_back(Pair("balance", ValueFromAmount(pwallet->GetBalance()))); | obj.push_back(Pair("balance", ValueFromAmount(pwallet->GetBalance()))); | ||||
obj.push_back(Pair("unconfirmed_balance", | obj.push_back(Pair("unconfirmed_balance", | ||||
ValueFromAmount(pwallet->GetUnconfirmedBalance()))); | ValueFromAmount(pwallet->GetUnconfirmedBalance()))); | ||||
obj.push_back(Pair("immature_balance", | obj.push_back(Pair("immature_balance", | ||||
ValueFromAmount(pwallet->GetImmatureBalance()))); | ValueFromAmount(pwallet->GetImmatureBalance()))); | ||||
obj.push_back(Pair("txcount", (int)pwallet->mapWallet.size())); | obj.push_back(Pair("txcount", (int)pwallet->mapWallet.size())); | ||||
obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime())); | obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime())); | ||||
Show All 9 Lines | static UniValue getwalletinfo(const Config &config, | ||||
} | } | ||||
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); | obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); | ||||
if (!masterKeyID.IsNull()) { | if (!masterKeyID.IsNull()) { | ||||
obj.push_back(Pair("hdmasterkeyid", masterKeyID.GetHex())); | obj.push_back(Pair("hdmasterkeyid", masterKeyID.GetHex())); | ||||
} | } | ||||
return obj; | return obj; | ||||
} | } | ||||
static UniValue listwallets(const Config &config, | |||||
const JSONRPCRequest &request) { | |||||
if (request.fHelp || request.params.size() != 0) { | |||||
throw std::runtime_error( | |||||
"listwallets\n" | |||||
"Returns a list of currently loaded wallets.\n" | |||||
"For full information on the wallet, use \"getwalletinfo\"\n" | |||||
"\nResult:\n" | |||||
"[ (json array of strings)\n" | |||||
" \"walletname\" (string) the wallet name\n" | |||||
" ...\n" | |||||
"]\n" | |||||
"\nExamples:\n" + | |||||
HelpExampleCli("listwallets", "") + | |||||
HelpExampleRpc("listwallets", "")); | |||||
} | |||||
UniValue obj(UniValue::VARR); | |||||
for (CWalletRef pwallet : vpwallets) { | |||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | |||||
return NullUniValue; | |||||
} | |||||
LOCK(pwallet->cs_wallet); | |||||
obj.push_back(pwallet->GetName()); | |||||
} | |||||
return obj; | |||||
} | |||||
static UniValue resendwallettransactions(const Config &config, | static UniValue resendwallettransactions(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
CWallet *const pwallet = GetWalletForJSONRPCRequest(request); | CWallet *const pwallet = GetWalletForJSONRPCRequest(request); | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
▲ Show 20 Lines • Show All 481 Lines • ▼ Show 20 Lines | static const CRPCCommand commands[] = { | ||||
{ "wallet", "listaccounts", listaccounts, false, {"minconf","include_watchonly"} }, | { "wallet", "listaccounts", listaccounts, false, {"minconf","include_watchonly"} }, | ||||
{ "wallet", "listaddressgroupings", listaddressgroupings, false, {} }, | { "wallet", "listaddressgroupings", listaddressgroupings, false, {} }, | ||||
{ "wallet", "listlockunspent", listlockunspent, false, {} }, | { "wallet", "listlockunspent", listlockunspent, false, {} }, | ||||
{ "wallet", "listreceivedbyaccount", listreceivedbyaccount, false, {"minconf","include_empty","include_watchonly"} }, | { "wallet", "listreceivedbyaccount", listreceivedbyaccount, false, {"minconf","include_empty","include_watchonly"} }, | ||||
{ "wallet", "listreceivedbyaddress", listreceivedbyaddress, false, {"minconf","include_empty","include_watchonly"} }, | { "wallet", "listreceivedbyaddress", listreceivedbyaddress, false, {"minconf","include_empty","include_watchonly"} }, | ||||
{ "wallet", "listsinceblock", listsinceblock, false, {"blockhash","target_confirmations","include_watchonly"} }, | { "wallet", "listsinceblock", listsinceblock, false, {"blockhash","target_confirmations","include_watchonly"} }, | ||||
{ "wallet", "listtransactions", listtransactions, false, {"account","count","skip","include_watchonly"} }, | { "wallet", "listtransactions", listtransactions, false, {"account","count","skip","include_watchonly"} }, | ||||
{ "wallet", "listunspent", listunspent, false, {"minconf","maxconf","addresses","include_unsafe"} }, | { "wallet", "listunspent", listunspent, false, {"minconf","maxconf","addresses","include_unsafe"} }, | ||||
{ "wallet", "listwallets", listwallets, true, {} }, | |||||
{ "wallet", "lockunspent", lockunspent, true, {"unlock","transactions"} }, | { "wallet", "lockunspent", lockunspent, true, {"unlock","transactions"} }, | ||||
{ "wallet", "move", movecmd, false, {"fromaccount","toaccount","amount","minconf","comment"} }, | { "wallet", "move", movecmd, false, {"fromaccount","toaccount","amount","minconf","comment"} }, | ||||
{ "wallet", "sendfrom", sendfrom, false, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, | { "wallet", "sendfrom", sendfrom, false, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, | ||||
{ "wallet", "sendmany", sendmany, false, {"fromaccount","amounts","minconf","comment","subtractfeefrom"} }, | { "wallet", "sendmany", sendmany, false, {"fromaccount","amounts","minconf","comment","subtractfeefrom"} }, | ||||
{ "wallet", "sendtoaddress", sendtoaddress, false, {"address","amount","comment","comment_to","subtractfeefromamount"} }, | { "wallet", "sendtoaddress", sendtoaddress, false, {"address","amount","comment","comment_to","subtractfeefromamount"} }, | ||||
{ "wallet", "setaccount", setaccount, true, {"address","account"} }, | { "wallet", "setaccount", setaccount, true, {"address","account"} }, | ||||
{ "wallet", "settxfee", settxfee, true, {"amount"} }, | { "wallet", "settxfee", settxfee, true, {"amount"} }, | ||||
{ "wallet", "signmessage", signmessage, true, {"address","message"} }, | { "wallet", "signmessage", signmessage, true, {"address","message"} }, | ||||
{ "wallet", "walletlock", walletlock, true, {} }, | { "wallet", "walletlock", walletlock, true, {} }, | ||||
{ "wallet", "walletpassphrasechange", walletpassphrasechange, true, {"oldpassphrase","newpassphrase"} }, | { "wallet", "walletpassphrasechange", walletpassphrasechange, true, {"oldpassphrase","newpassphrase"} }, | ||||
{ "wallet", "walletpassphrase", walletpassphrase, true, {"passphrase","timeout"} }, | { "wallet", "walletpassphrase", walletpassphrase, true, {"passphrase","timeout"} }, | ||||
{ "generating", "generate", &generate, true, {"nblocks","maxtries"} }, | { "generating", "generate", generate, true, {"nblocks","maxtries"} }, | ||||
}; | }; | ||||
// clang-format on | // clang-format on | ||||
void RegisterWalletRPCCommands(CRPCTable &t) { | void RegisterWalletRPCCommands(CRPCTable &t) { | ||||
if (GetBoolArg("-disablewallet", false)) { | if (GetBoolArg("-disablewallet", false)) { | ||||
return; | return; | ||||
} | } | ||||
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | ||||
t.appendCommand(commands[vcidx].name, &commands[vcidx]); | t.appendCommand(commands[vcidx].name, &commands[vcidx]); | ||||
} | } | ||||
} | } |