From b89b96394a33c96fb8135fc771f47bd1f65e0a06 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 23 May 2016 21:40:12 +0100 Subject: wallet: add unconfirmed incoming txes from the txpool Shown in show_transfers simplewallet command, and get_transfers RPC command, if req.pool is true. --- src/wallet/wallet_rpc_server.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/wallet/wallet_rpc_server.cpp') diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 5c42e1c53..dbfb880a1 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -918,8 +918,8 @@ namespace tools std::list> payments; m_wallet.get_payments_out(payments, min_height, max_height); for (std::list>::const_iterator i = payments.begin(); i != payments.end(); ++i) { - res.in.push_back(wallet_rpc::COMMAND_RPC_GET_TRANSFERS::entry()); - wallet_rpc::COMMAND_RPC_GET_TRANSFERS::entry &entry = res.in.back(); + res.out.push_back(wallet_rpc::COMMAND_RPC_GET_TRANSFERS::entry()); + wallet_rpc::COMMAND_RPC_GET_TRANSFERS::entry &entry = res.out.back(); const tools::wallet2::confirmed_transfer_details &pd = i->second; entry.txid = string_tools::pod_to_hex(i->first); @@ -969,6 +969,29 @@ namespace tools } } + if (req.pool) + { + m_wallet.update_pool_state(); + + std::list> payments; + m_wallet.get_unconfirmed_payments(payments); + for (std::list>::const_iterator i = payments.begin(); i != payments.end(); ++i) { + res.pool.push_back(wallet_rpc::COMMAND_RPC_GET_TRANSFERS::entry()); + wallet_rpc::COMMAND_RPC_GET_TRANSFERS::entry &entry = res.pool.back(); + const tools::wallet2::payment_details &pd = i->second; + + entry.txid = string_tools::pod_to_hex(pd.m_tx_hash); + entry.payment_id = string_tools::pod_to_hex(i->first); + if (entry.payment_id.substr(16).find_first_not_of('0') == std::string::npos) + entry.payment_id = entry.payment_id.substr(0,16); + entry.height = 0; + entry.timestamp = pd.m_timestamp; + entry.amount = pd.m_amount; + entry.fee = 0; // TODO + entry.note = m_wallet.get_tx_note(pd.m_tx_hash); + } + } + return true; } //------------------------------------------------------------------------------------------------------------------------------ -- cgit v1.2.3