diff options
author | luigi1111 <luigi1111w@gmail.com> | 2018-08-15 17:37:23 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2018-08-15 17:37:23 -0500 |
commit | a68143bc52653a02c9a1a476993374c6be7eb1c2 (patch) | |
tree | b3f0ddac4f1d66189f665d63178d01148a84f8c7 /src/wallet | |
parent | Merge pull request #4170 (diff) | |
parent | wallet-rpc: filter getbalance response by address index (diff) | |
download | monero-a68143bc52653a02c9a1a476993374c6be7eb1c2.tar.xz |
Merge pull request #4171
9127a8b wallet-rpc: filter getbalance response by address index (stoffu)
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 14 | ||||
-rw-r--r-- | src/wallet/wallet_rpc_server_commands_defs.h | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index b744a79ac..c6a81d886 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -355,14 +355,20 @@ namespace tools std::map<uint32_t, uint64_t> unlocked_balance_per_subaddress = m_wallet->unlocked_balance_per_subaddress(req.account_index); std::vector<tools::wallet2::transfer_details> transfers; m_wallet->get_transfers(transfers); - for (const auto& i : balance_per_subaddress) + std::set<uint32_t> address_indices = req.address_indices; + if (address_indices.empty()) + { + for (const auto& i : balance_per_subaddress) + address_indices.insert(i.first); + } + for (uint32_t i : address_indices) { wallet_rpc::COMMAND_RPC_GET_BALANCE::per_subaddress_info info; - info.address_index = i.first; + info.address_index = i; cryptonote::subaddress_index index = {req.account_index, info.address_index}; info.address = m_wallet->get_subaddress_as_str(index); - info.balance = i.second; - info.unlocked_balance = unlocked_balance_per_subaddress[i.first]; + info.balance = balance_per_subaddress[i]; + info.unlocked_balance = unlocked_balance_per_subaddress[i]; info.label = m_wallet->get_subaddress_label(index); info.num_unspent_outputs = std::count_if(transfers.begin(), transfers.end(), [&](const tools::wallet2::transfer_details& td) { return !td.m_spent && td.m_subaddr_index == index; }); res.per_subaddress.push_back(info); diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h index 37c96ec89..48d881c4c 100644 --- a/src/wallet/wallet_rpc_server_commands_defs.h +++ b/src/wallet/wallet_rpc_server_commands_defs.h @@ -62,8 +62,10 @@ namespace wallet_rpc struct request { uint32_t account_index; + std::set<uint32_t> address_indices; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(account_index) + KV_SERIALIZE(address_indices) END_KV_SERIALIZE_MAP() }; |