From 892fc5fd54a41db0469ced446463671ea76753c7 Mon Sep 17 00:00:00 2001 From: jeffro256 Date: Sat, 13 Sep 2025 12:14:35 -0500 Subject: [PATCH] wallet: re-add detatched confirmed transactions on reorg --- src/wallet/wallet2.cpp | 32 +++++++++++++++++++++++++++----- src/wallet/wallet2.h | 2 +- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index aabb06521d..055d3c76ae 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -790,6 +790,24 @@ void drop_from_short_history(std::list &short_chain_history, size_ } } +static tools::wallet2::unconfirmed_transfer_details disconfirm_transfer(const tools::wallet2::confirmed_transfer_details &ctd) +{ + tools::wallet2::unconfirmed_transfer_details utd{}; + utd.m_tx = ctd.m_tx; + utd.m_amount_in = ctd.m_amount_in; + utd.m_amount_out = ctd.m_amount_out; + utd.m_change = ctd.m_change; + utd.m_sent_time = ctd.m_timestamp; + utd.m_dests = ctd.m_dests; + utd.m_payment_id = ctd.m_payment_id; + utd.m_state = tools::wallet2::unconfirmed_transfer_details::pending; + utd.m_timestamp = ctd.m_timestamp; + utd.m_subaddr_account = ctd.m_subaddr_account; + utd.m_subaddr_indices = ctd.m_subaddr_indices; + utd.m_rings = ctd.m_rings; + return utd; +} + size_t estimate_rct_tx_size(int n_inputs, int mixin, int n_outputs, size_t extra_size, bool bulletproof, bool clsag, bool bulletproof_plus, bool use_view_tags) { size_t size = 0; @@ -1834,9 +1852,9 @@ void wallet2::process_scan_txs(const tx_entry_data &txs_to_scan, const tx_entry_ // Re-set destination addresses if they were previously set if (m_confirmed_txs.find(tx_info.tx_hash) != m_confirmed_txs.end() && - dbd.detached_confirmed_txs_dests.find(tx_info.tx_hash) != dbd.detached_confirmed_txs_dests.end()) + dbd.detached_confirmed_txs.count(tx_info.tx_hash)) { - m_confirmed_txs[tx_info.tx_hash].m_dests = std::move(dbd.detached_confirmed_txs_dests[tx_info.tx_hash]); + m_confirmed_txs[tx_info.tx_hash].m_dests = std::move(dbd.detached_confirmed_txs[tx_info.tx_hash].m_dests); } } @@ -4400,7 +4418,7 @@ wallet2::detached_blockchain_data wallet2::detach_blockchain(uint64_t height, st if(height <= it->second.m_block_height) { dbd.detached_tx_hashes.insert(it->first); - dbd.detached_confirmed_txs_dests[it->first] = std::move(it->second.m_dests); + dbd.detached_confirmed_txs[it->first] = std::move(it->second); it = m_confirmed_txs.erase(it); } else @@ -4421,6 +4439,10 @@ void wallet2::handle_reorg(uint64_t height, std::map detached_tx_hashes; - std::unordered_map> detached_confirmed_txs_dests; + std::unordered_map detached_confirmed_txs; }; struct process_tx_entry_t