mirror of
https://github.com/monero-project/monero.git
synced 2025-08-06 01:44:24 -04:00
track double spending in the txpool
Transactions in the txpool are marked when another transaction is seen double spending one or more of its inputs. This is then exposed wherever appropriate. Note that being marked with this "double spend seen" flag does NOT mean this transaction IS a double spend and will never be mined: it just means that the network has seen at least another transaction spending at least one of the same inputs, so care should be taken to wait for a few confirmations before acting upon that transaction (ie, mostly of use for merchants wanting to accept unconfirmed transactions).
This commit is contained in:
parent
3dd31d33fa
commit
ccf53a566c
16 changed files with 216 additions and 62 deletions
|
@ -299,8 +299,9 @@ namespace tools
|
|||
entry.subaddr_index = { pd.m_subaddr_account, 0 };
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd)
|
||||
void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &payment_id, const tools::wallet2::pool_payment_details &ppd)
|
||||
{
|
||||
const tools::wallet2::payment_details &pd = ppd.m_pd;
|
||||
entry.txid = string_tools::pod_to_hex(pd.m_tx_hash);
|
||||
entry.payment_id = string_tools::pod_to_hex(payment_id);
|
||||
if (entry.payment_id.substr(16).find_first_not_of('0') == std::string::npos)
|
||||
|
@ -311,6 +312,7 @@ namespace tools
|
|||
entry.unlock_time = pd.m_unlock_time;
|
||||
entry.fee = 0; // TODO
|
||||
entry.note = m_wallet->get_tx_note(pd.m_tx_hash);
|
||||
entry.double_spend_seen = ppd.m_double_spend_seen;
|
||||
entry.type = "pool";
|
||||
entry.subaddr_index = pd.m_subaddr_index;
|
||||
}
|
||||
|
@ -1357,9 +1359,9 @@ namespace tools
|
|||
{
|
||||
m_wallet->update_pool_state();
|
||||
|
||||
std::list<std::pair<crypto::hash, tools::wallet2::payment_details>> payments;
|
||||
std::list<std::pair<crypto::hash, tools::wallet2::pool_payment_details>> payments;
|
||||
m_wallet->get_unconfirmed_payments(payments, req.account_index, req.subaddr_indices);
|
||||
for (std::list<std::pair<crypto::hash, tools::wallet2::payment_details>>::const_iterator i = payments.begin(); i != payments.end(); ++i) {
|
||||
for (std::list<std::pair<crypto::hash, tools::wallet2::pool_payment_details>>::const_iterator i = payments.begin(); i != payments.end(); ++i) {
|
||||
res.pool.push_back(wallet_rpc::transfer_entry());
|
||||
fill_transfer_entry(res.pool.back(), i->first, i->second);
|
||||
}
|
||||
|
@ -1430,10 +1432,10 @@ namespace tools
|
|||
|
||||
m_wallet->update_pool_state();
|
||||
|
||||
std::list<std::pair<crypto::hash, tools::wallet2::payment_details>> pool_payments;
|
||||
std::list<std::pair<crypto::hash, tools::wallet2::pool_payment_details>> pool_payments;
|
||||
m_wallet->get_unconfirmed_payments(pool_payments);
|
||||
for (std::list<std::pair<crypto::hash, tools::wallet2::payment_details>>::const_iterator i = pool_payments.begin(); i != pool_payments.end(); ++i) {
|
||||
if (i->second.m_tx_hash == txid)
|
||||
for (std::list<std::pair<crypto::hash, tools::wallet2::pool_payment_details>>::const_iterator i = pool_payments.begin(); i != pool_payments.end(); ++i) {
|
||||
if (i->second.m_pd.m_tx_hash == txid)
|
||||
{
|
||||
fill_transfer_entry(res.transfer, i->first, i->second);
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue