Skip to content

Commit

Permalink
rpc: Add listwalletdir RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
promag committed Oct 18, 2018
1 parent d1b03b8 commit cc33773
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,38 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
return obj;
}

static UniValue listwalletdir(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 0) {
throw std::runtime_error(
"listwalletdir\n"
"Returns a list of wallets in the wallet directory.\n"
"{\n"
" \"wallets\" : [ (json array of objects)\n"
" {\n"
" \"name\" : \"name\" (string) The wallet name\n"
" }\n"
" ,...\n"
" ]\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("listwalletdir", "")
+ HelpExampleRpc("listwalletdir", "")
);
}

UniValue wallets(UniValue::VARR);
for (const auto& path : ListWalletDir()) {
UniValue wallet(UniValue::VOBJ);
wallet.pushKV("name", path.string());
wallets.push_back(wallet);
}

UniValue result(UniValue::VOBJ);
result.pushKV("wallets", wallets);
return result;
}

static UniValue listwallets(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 0)
Expand Down Expand Up @@ -4102,6 +4134,7 @@ static const CRPCCommand commands[] =
{ "wallet", "listsinceblock", &listsinceblock, {"blockhash","target_confirmations","include_watchonly","include_removed"} },
{ "wallet", "listtransactions", &listtransactions, {"dummy","count","skip","include_watchonly"} },
{ "wallet", "listunspent", &listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} },
{ "wallet", "listwalletdir", &listwalletdir, {} },
{ "wallet", "listwallets", &listwallets, {} },
{ "wallet", "loadwallet", &loadwallet, {"filename"} },
{ "wallet", "lockunspent", &lockunspent, {"unlock","transactions"} },
Expand Down

0 comments on commit cc33773

Please sign in to comment.