Skip to content

Commit

Permalink
Merge pull request monero-project#2916
Browse files Browse the repository at this point in the history
a921764 wallet-rpc: added receiving address to res of get(_bulk)_payments; selective addresses for getaddress (stoffu)
  • Loading branch information
fluffypony committed Dec 25, 2017
2 parents f04d4a7 + a921764 commit 8b40bc2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/wallet/wallet_rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -1281,6 +1293,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));
}

Expand Down Expand Up @@ -1331,6 +1344,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));
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/wallet/wallet_rpc_server_commands_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ namespace wallet_rpc
struct request
{
uint32_t account_index;
std::vector<uint32_t> address_index;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(account_index)
KV_SERIALIZE(address_index)
END_KV_SERIALIZE_MAP()
};

Expand Down Expand Up @@ -601,6 +603,7 @@ namespace wallet_rpc
uint64_t block_height;
uint64_t unlock_time;
cryptonote::subaddress_index subaddr_index;
std::string address;

BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(payment_id)
Expand All @@ -609,6 +612,7 @@ namespace wallet_rpc
KV_SERIALIZE(block_height)
KV_SERIALIZE(unlock_time)
KV_SERIALIZE(subaddr_index)
KV_SERIALIZE(address)
END_KV_SERIALIZE_MAP()
};

Expand Down

0 comments on commit 8b40bc2

Please sign in to comment.