From 53da0cef03d873ee64796d615e8121691a94ae23 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 20 Jul 2023 12:09:10 -0400 Subject: [PATCH] wallet.get_txs(...) does not return missing txs --- src/wallet/monero_wallet.h | 12 ------------ src/wallet/monero_wallet_full.cpp | 18 ++++-------------- src/wallet/monero_wallet_full.h | 1 - 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/wallet/monero_wallet.h b/src/wallet/monero_wallet.h index 9b0c12f..4d07165 100644 --- a/src/wallet/monero_wallet.h +++ b/src/wallet/monero_wallet.h @@ -726,18 +726,6 @@ namespace monero { throw std::runtime_error("get_txs(query) not supported"); } - /** - * Same as get_txs(query) but collects missing tx hashes instead of throwing an error. - * This method is separated because WebAssembly does not support exception handling. - * - * @param query filters results (optional) - * @param missing_tx_hashes are populated with requested tx hashes that are not part of the wallet - * @return wallet transactions per the request - */ - virtual std::vector> get_txs(const monero_tx_query& query, std::vector& missing_tx_hashes) const { - throw std::runtime_error("get_txs(query, missing_tx_hashes) not supported"); - } - /** * Get incoming and outgoing transfers to and from this wallet. An outgoing * transfer represents a total amount sent from one or more subaddresses diff --git a/src/wallet/monero_wallet_full.cpp b/src/wallet/monero_wallet_full.cpp index 8e1b1e0..f7876d4 100644 --- a/src/wallet/monero_wallet_full.cpp +++ b/src/wallet/monero_wallet_full.cpp @@ -919,8 +919,7 @@ namespace monero { tx_query.m_hashes = tx_hashes; tx_query.m_include_outputs = true; tx_query.m_is_locked = true; - std::vector missing_tx_hashes; - on_spend_txs(m_wallet.get_txs(tx_query, missing_tx_hashes)); + on_spend_txs(m_wallet.get_txs(tx_query)); } void on_spend_txs(const std::vector>& txs) { @@ -986,8 +985,7 @@ namespace monero { query.m_hashes = tx_hashes_no_longer_locked; query.m_is_locked = false; query.m_include_outputs = true; - std::vector missing_tx_hashes; - txs_no_longer_locked = m_wallet.get_txs(query, missing_tx_hashes); + txs_no_longer_locked = m_wallet.get_txs(query); } // notify listeners of newly unlocked inputs and outputs @@ -1693,13 +1691,6 @@ namespace monero { } std::vector> monero_wallet_full::get_txs(const monero_tx_query& query) const { - std::vector missing_tx_hashes; - std::vector> txs = get_txs(query, missing_tx_hashes); - if (!missing_tx_hashes.empty()) throw std::runtime_error("Tx not found in wallet: " + missing_tx_hashes[0]); - return txs; - } - - std::vector> monero_wallet_full::get_txs(const monero_tx_query& query, std::vector& missing_tx_hashes) const { MTRACE("get_txs(query)"); // copy query @@ -1784,17 +1775,16 @@ namespace monero { for (const std::shared_ptr& tx : txs) { if (*tx->m_is_confirmed && tx->m_block == boost::none) { std::cout << "WARNING: Inconsistency detected building txs from multiple wallet2 calls, re-fetching" << std::endl; - return get_txs(*_query, missing_tx_hashes); + return get_txs(*_query); } } - // if tx hashes requested, order txs and collect missing hashes + // if tx hashes requested, order txs if (!_query->m_hashes.empty()) { txs.clear(); for (const std::string& tx_hash : _query->m_hashes) { std::map>::const_iterator tx_iter = tx_map.find(tx_hash); if (tx_iter != tx_map.end()) txs.push_back(tx_iter->second); - else missing_tx_hashes.push_back(tx_hash); } } diff --git a/src/wallet/monero_wallet_full.h b/src/wallet/monero_wallet_full.h index fdad1ad..af50312 100644 --- a/src/wallet/monero_wallet_full.h +++ b/src/wallet/monero_wallet_full.h @@ -189,7 +189,6 @@ namespace monero { void set_subaddress_label(uint32_t account_idx, uint32_t subaddress_idx, const std::string& label = "") override; std::vector> get_txs() const override; std::vector> get_txs(const monero_tx_query& query) const override; - std::vector> get_txs(const monero_tx_query& query, std::vector& missing_tx_hashes) const override; std::vector> get_transfers(const monero_transfer_query& query) const override; std::vector> get_outputs(const monero_output_query& query) const override; std::string export_outputs(bool all = false) const override;