mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
rpc: Add listwalletdir RPC
This commit is contained in:
parent
d1b03b8e5f
commit
cc3377360c
1 changed files with 33 additions and 0 deletions
|
@ -2450,6 +2450,38 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
|
||||||
return obj;
|
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)
|
static UniValue listwallets(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
if (request.fHelp || request.params.size() != 0)
|
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", "listsinceblock", &listsinceblock, {"blockhash","target_confirmations","include_watchonly","include_removed"} },
|
||||||
{ "wallet", "listtransactions", &listtransactions, {"dummy","count","skip","include_watchonly"} },
|
{ "wallet", "listtransactions", &listtransactions, {"dummy","count","skip","include_watchonly"} },
|
||||||
{ "wallet", "listunspent", &listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} },
|
{ "wallet", "listunspent", &listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} },
|
||||||
|
{ "wallet", "listwalletdir", &listwalletdir, {} },
|
||||||
{ "wallet", "listwallets", &listwallets, {} },
|
{ "wallet", "listwallets", &listwallets, {} },
|
||||||
{ "wallet", "loadwallet", &loadwallet, {"filename"} },
|
{ "wallet", "loadwallet", &loadwallet, {"filename"} },
|
||||||
{ "wallet", "lockunspent", &lockunspent, {"unlock","transactions"} },
|
{ "wallet", "lockunspent", &lockunspent, {"unlock","transactions"} },
|
||||||
|
|
Loading…
Add table
Reference in a new issue