@@ -2447,6 +2447,7 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
2447
2447
" Returns an object containing various wallet state info.\n "
2448
2448
" \n Result:\n "
2449
2449
" {\n "
2450
+ " \" walletname\" : xxxxx, (string) the wallet name\n "
2450
2451
" \" walletversion\" : xxxxx, (numeric) the wallet version\n "
2451
2452
" \" balance\" : xxxxxxx, (numeric) the total confirmed balance of the wallet in " + CURRENCY_UNIT + " \n "
2452
2453
" \" unconfirmed_balance\" : xxx, (numeric) the total unconfirmed balance of the wallet in " + CURRENCY_UNIT + " \n "
@@ -2469,6 +2470,7 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
2469
2470
UniValue obj (UniValue::VOBJ);
2470
2471
2471
2472
size_t kpExternalSize = pwallet->KeypoolCountExternalKeys ();
2473
+ obj.push_back (Pair (" walletname" , pwallet->GetName ()));
2472
2474
obj.push_back (Pair (" walletversion" , pwallet->GetVersion ()));
2473
2475
obj.push_back (Pair (" balance" , ValueFromAmount (pwallet->GetBalance ())));
2474
2476
obj.push_back (Pair (" unconfirmed_balance" , ValueFromAmount (pwallet->GetUnconfirmedBalance ())));
@@ -2489,6 +2491,39 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
2489
2491
return obj;
2490
2492
}
2491
2493
2494
+ UniValue listwallets (const JSONRPCRequest& request)
2495
+ {
2496
+ if (request.fHelp || request.params .size () != 0 )
2497
+ throw std::runtime_error (
2498
+ " listwallets\n "
2499
+ " Returns a list of currently loaded wallets.\n "
2500
+ " For full information on the wallet, use \" getwalletinfo\"\n "
2501
+ " \n Result:\n "
2502
+ " [ (json array of strings)\n "
2503
+ " \" walletname\" (string) the wallet name\n "
2504
+ " ...\n "
2505
+ " ]\n "
2506
+ " \n Examples:\n "
2507
+ + HelpExampleCli (" listwallets" , " " )
2508
+ + HelpExampleRpc (" listwallets" , " " )
2509
+ );
2510
+
2511
+ UniValue obj (UniValue::VARR);
2512
+
2513
+ for (CWalletRef pwallet : vpwallets) {
2514
+
2515
+ if (!EnsureWalletIsAvailable (pwallet, request.fHelp )) {
2516
+ return NullUniValue;
2517
+ }
2518
+
2519
+ LOCK (pwallet->cs_wallet );
2520
+
2521
+ obj.push_back (pwallet->GetName ());
2522
+ }
2523
+
2524
+ return obj;
2525
+ }
2526
+
2492
2527
UniValue resendwallettransactions (const JSONRPCRequest& request)
2493
2528
{
2494
2529
CWallet * const pwallet = GetWalletForJSONRPCRequest (request);
@@ -3085,6 +3120,7 @@ static const CRPCCommand commands[] =
3085
3120
{ " wallet" , " listsinceblock" , &listsinceblock, false , {" blockhash" ," target_confirmations" ," include_watchonly" } },
3086
3121
{ " wallet" , " listtransactions" , &listtransactions, false , {" account" ," count" ," skip" ," include_watchonly" } },
3087
3122
{ " wallet" , " listunspent" , &listunspent, false , {" minconf" ," maxconf" ," addresses" ," include_unsafe" ," query_options" } },
3123
+ { " wallet" , " listwallets" , &listwallets, true , {} },
3088
3124
{ " wallet" , " lockunspent" , &lockunspent, true , {" unlock" ," transactions" } },
3089
3125
{ " wallet" , " move" , &movecmd, false , {" fromaccount" ," toaccount" ," amount" ," minconf" ," comment" } },
3090
3126
{ " wallet" , " sendfrom" , &sendfrom, false , {" fromaccount" ," toaddress" ," amount" ," minconf" ," comment" ," comment_to" } },
0 commit comments