diff options
author | stoffu <stoffu@protonmail.ch> | 2017-12-13 17:24:59 +0900 |
---|---|---|
committer | stoffu <stoffu@protonmail.ch> | 2017-12-18 10:22:34 +0900 |
commit | a9217641621e397a5cb811e6d1ab1a765f53b93e (patch) | |
tree | fb1daa5bd83984fac10f4d90990c56d5193d6ca4 /src/wallet/wallet_rpc_server.cpp | |
parent | Merge pull request #2134 (diff) | |
download | monero-a9217641621e397a5cb811e6d1ab1a765f53b93e.tar.xz |
wallet-rpc: added receiving address to res of get(_bulk)_payments; selective addresses for getaddress
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 0482b9dd6..304d80756 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -356,13 +356,24 @@ namespace tools if (!m_wallet) return not_open(er); try { - res.addresses.resize(m_wallet->get_num_subaddresses(req.account_index)); + res.addresses.clear(); + std::vector<uint32_t> req_address_index; + if (req.address_index.empty()) + { + for (uint32_t i = 0; i < m_wallet->get_num_subaddresses(req.account_index); ++i) + req_address_index.push_back(i); + } + else + { + req_address_index = req.address_index; + } tools::wallet2::transfer_container transfers; m_wallet->get_transfers(transfers); - cryptonote::subaddress_index index = {req.account_index, 0}; - for (; index.minor < m_wallet->get_num_subaddresses(req.account_index); ++index.minor) + for (uint32_t i : req_address_index) { - auto& info = res.addresses[index.minor]; + res.addresses.resize(res.addresses.size() + 1); + auto& info = res.addresses.back(); + const cryptonote::subaddress_index index = {req.account_index, i}; info.address = m_wallet->get_subaddress_as_str(index); info.label = m_wallet->get_subaddress_label(index); info.address_index = index.minor; @@ -1254,6 +1265,7 @@ namespace tools rpc_payment.block_height = payment.m_block_height; rpc_payment.unlock_time = payment.m_unlock_time; rpc_payment.subaddr_index = payment.m_subaddr_index; + rpc_payment.address = m_wallet->get_subaddress_as_str(payment.m_subaddr_index); res.payments.push_back(rpc_payment); } @@ -1280,6 +1292,7 @@ namespace tools rpc_payment.block_height = payment.second.m_block_height; rpc_payment.unlock_time = payment.second.m_unlock_time; rpc_payment.subaddr_index = payment.second.m_subaddr_index; + rpc_payment.address = m_wallet->get_subaddress_as_str(payment.second.m_subaddr_index); res.payments.push_back(std::move(rpc_payment)); } @@ -1330,6 +1343,7 @@ namespace tools rpc_payment.block_height = payment.m_block_height; rpc_payment.unlock_time = payment.m_unlock_time; rpc_payment.subaddr_index = payment.m_subaddr_index; + rpc_payment.address = m_wallet->get_subaddress_as_str(payment.m_subaddr_index); res.payments.push_back(std::move(rpc_payment)); } } |