* GetWalletBalances calls listwallets; if more than one wallet is loaded, it then * fetches mine.trusted balances for each loaded wallet and pushes them to `result`. * * @param result Reference to UniValue object the wallet names and balances are pushed to. */
| 1358 | * @param result Reference to UniValue object the wallet names and balances are pushed to. |
| 1359 | */ |
| 1360 | static void GetWalletBalances(UniValue& result) |
| 1361 | { |
| 1362 | DefaultRequestHandler rh; |
| 1363 | const UniValue listwallets = ConnectAndCallRPC(&rh, "listwallets", /* args=*/{}); |
| 1364 | if (!listwallets.find_value("error").isNull()) return; |
| 1365 | const UniValue& wallets = listwallets.find_value("result"); |
| 1366 | if (wallets.size() <= 1) return; |
| 1367 | |
| 1368 | UniValue balances(UniValue::VOBJ); |
| 1369 | for (const UniValue& wallet : wallets.getValues()) { |
| 1370 | const std::string& wallet_name = wallet.get_str(); |
| 1371 | const UniValue getbalances = ConnectAndCallRPC(&rh, "getbalances", /* args=*/{}, wallet_name); |
| 1372 | const UniValue& balance = getbalances.find_value("result")["mine"]["trusted"]; |
| 1373 | balances.pushKV(wallet_name, balance); |
| 1374 | } |
| 1375 | result.pushKV("balances", std::move(balances)); |
| 1376 | } |
| 1377 | |
| 1378 | /** |
| 1379 | * GetProgressBar constructs a progress bar with 5% intervals. |
no test coverage detected