* 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. */
| 901 | * @param result Reference to UniValue object the wallet names and balances are pushed to. |
| 902 | */ |
| 903 | static void GetWalletBalances(UniValue& result) |
| 904 | { |
| 905 | DefaultRequestHandler rh; |
| 906 | const UniValue listwallets = ConnectAndCallRPC(&rh, "listwallets", /* args=*/{}); |
| 907 | if (!find_value(listwallets, "error").isNull()) return; |
| 908 | const UniValue& wallets = find_value(listwallets, "result"); |
| 909 | if (wallets.size() <= 1) return; |
| 910 | |
| 911 | UniValue balances(UniValue::VOBJ); |
| 912 | for (const UniValue& wallet : wallets.getValues()) { |
| 913 | const std::string wallet_name = wallet.get_str(); |
| 914 | const UniValue getbalances = ConnectAndCallRPC(&rh, "getbalances", /* args=*/{}, wallet_name); |
| 915 | const UniValue& balance = find_value(getbalances, "result")["mine"]["trusted"]; |
| 916 | balances.pushKV(wallet_name, balance); |
| 917 | } |
| 918 | result.pushKV("balances", balances); |
| 919 | } |
| 920 | |
| 921 | /** |
| 922 | * GetProgressBar constructs a progress bar with 5% intervals. |
no test coverage detected