wallet.get_txs(...) does not return missing txs

This commit is contained in:
woodser
2023-07-24 17:46:42 -04:00
parent 67f66b1ab9
commit 53da0cef03
3 changed files with 4 additions and 27 deletions
-12
View File
@@ -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<std::shared_ptr<monero_tx_wallet>> get_txs(const monero_tx_query& query, std::vector<std::string>& 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
+4 -14
View File
@@ -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<std::string> 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<std::shared_ptr<monero_tx_wallet>>& 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<std::string> 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<std::shared_ptr<monero_tx_wallet>> monero_wallet_full::get_txs(const monero_tx_query& query) const {
std::vector<std::string> missing_tx_hashes;
std::vector<std::shared_ptr<monero_tx_wallet>> 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<std::shared_ptr<monero_tx_wallet>> monero_wallet_full::get_txs(const monero_tx_query& query, std::vector<std::string>& missing_tx_hashes) const {
MTRACE("get_txs(query)");
// copy query
@@ -1784,17 +1775,16 @@ namespace monero {
for (const std::shared_ptr<monero_tx_wallet>& 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<std::string, std::shared_ptr<monero_tx_wallet>>::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);
}
}
-1
View File
@@ -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<std::shared_ptr<monero_tx_wallet>> get_txs() const override;
std::vector<std::shared_ptr<monero_tx_wallet>> get_txs(const monero_tx_query& query) const override;
std::vector<std::shared_ptr<monero_tx_wallet>> get_txs(const monero_tx_query& query, std::vector<std::string>& missing_tx_hashes) const override;
std::vector<std::shared_ptr<monero_transfer>> get_transfers(const monero_transfer_query& query) const override;
std::vector<std::shared_ptr<monero_output_wallet>> get_outputs(const monero_output_query& query) const override;
std::string export_outputs(bool all = false) const override;