wallet: add unconfirmed incoming txes from the txpool

Shown in show_transfers simplewallet command, and get_transfers
RPC command, if req.pool is true.
This commit is contained in:
moneromooo-monero 2016-05-23 21:40:12 +01:00
parent 8e143fcf1d
commit b89b96394a
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
5 changed files with 242 additions and 53 deletions

View file

@ -918,8 +918,8 @@ namespace tools
std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> payments;
m_wallet.get_payments_out(payments, min_height, max_height);
for (std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>>::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<std::pair<crypto::hash, tools::wallet2::payment_details>> payments;
m_wallet.get_unconfirmed_payments(payments);
for (std::list<std::pair<crypto::hash, tools::wallet2::payment_details>>::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;
}
//------------------------------------------------------------------------------------------------------------------------------