mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
rpc: Add listwalletdir RPC
This commit is contained in:
parent
d1b03b8e5f
commit
cc3377360c
@ -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)
|
||||
@ -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"} },
|
||||
|
Loading…
Reference in New Issue
Block a user