diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-06-17 23:21:27 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-08-28 21:28:49 +0100 |
commit | acbe06d8e931c2a35bd37e0a5d41159ce3ab5da9 (patch) | |
tree | 126fd9e6e4b266332ad71d790c2204927f103286 | |
parent | wallet: reset output spent status on blockchain reorg (diff) | |
download | monero-acbe06d8e931c2a35bd37e0a5d41159ce3ab5da9.tar.xz |
wallet: update spent status when an accepted tx disappears
-rw-r--r-- | src/wallet/wallet2.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 55106fa98..59472e648 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -884,6 +884,25 @@ void wallet2::update_pool_state() { LOG_PRINT_L1("Pending txid " << txid << " not in pool, marking as failed"); pit->second.m_state = wallet2::unconfirmed_transfer_details::failed; + + // the inputs aren't spent anymore, since the tx failed + for (size_t vini = 0; vini < pit->second.m_tx.vin.size(); ++vini) + { + if (pit->second.m_tx.vin[vini].type() == typeid(txin_to_key)) + { + txin_to_key &tx_in_to_key = boost::get<txin_to_key>(pit->second.m_tx.vin[vini]); + for (auto &td: m_transfers) + { + if (td.m_key_image == tx_in_to_key.k_image) + { + LOG_PRINT_L1("Resetting spent status for output " << vini << ": " << td.m_key_image); + td.m_spent = 0; + td.m_spent_height = 0; + break; + } + } + } + } } } } |