@@ -2450,6 +2450,38 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
24502450 return obj;
24512451}
24522452
2453+ static UniValue listwalletdir (const JSONRPCRequest& request)
2454+ {
2455+ if (request.fHelp || request.params .size () != 0 ) {
2456+ throw std::runtime_error (
2457+ " listwalletdir\n "
2458+ " Returns a list of wallets in the wallet directory.\n "
2459+ " {\n "
2460+ " \" wallets\" : [ (json array of objects)\n "
2461+ " {\n "
2462+ " \" name\" : \" name\" (string) The wallet name\n "
2463+ " }\n "
2464+ " ,...\n "
2465+ " ]\n "
2466+ " }\n "
2467+ " \n Examples:\n "
2468+ + HelpExampleCli (" listwalletdir" , " " )
2469+ + HelpExampleRpc (" listwalletdir" , " " )
2470+ );
2471+ }
2472+
2473+ UniValue wallets (UniValue::VARR);
2474+ for (const auto & path : ListWalletDir ()) {
2475+ UniValue wallet (UniValue::VOBJ);
2476+ wallet.pushKV (" name" , path.string ());
2477+ wallets.push_back (wallet);
2478+ }
2479+
2480+ UniValue result (UniValue::VOBJ);
2481+ result.pushKV (" wallets" , wallets);
2482+ return result;
2483+ }
2484+
24532485static UniValue listwallets (const JSONRPCRequest& request)
24542486{
24552487 if (request.fHelp || request.params .size () != 0 )
@@ -4102,6 +4134,7 @@ static const CRPCCommand commands[] =
41024134 { " wallet" , " listsinceblock" , &listsinceblock, {" blockhash" ," target_confirmations" ," include_watchonly" ," include_removed" } },
41034135 { " wallet" , " listtransactions" , &listtransactions, {" dummy" ," count" ," skip" ," include_watchonly" } },
41044136 { " wallet" , " listunspent" , &listunspent, {" minconf" ," maxconf" ," addresses" ," include_unsafe" ," query_options" } },
4137+ { " wallet" , " listwalletdir" , &listwalletdir, {} },
41054138 { " wallet" , " listwallets" , &listwallets, {} },
41064139 { " wallet" , " loadwallet" , &loadwallet, {" filename" } },
41074140 { " wallet" , " lockunspent" , &lockunspent, {" unlock" ," transactions" } },
0 commit comments