diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index fd8a82b521..33f5f64d7c 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -2231,15 +2231,7 @@ bool simple_wallet::blackballed(const std::vector &args) bool simple_wallet::save_known_rings(const std::vector &args) { - try - { - LOCK_IDLE_SCOPE(); - m_wallet->find_and_save_rings(); - } - catch (const std::exception &e) - { - fail_msg_writer() << tr("Failed to save known rings: ") << e.what(); - } + fail_msg_writer() << tr("save_known_rings is deprecated"); return true; } diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 8fda0bab72..165b21c9f3 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -2479,7 +2479,6 @@ void WalletImpl::doRefresh() if (m_history->count() == 0) { m_history->refresh(); } - m_wallet->find_and_save_rings(false); } else { LOG_PRINT_L3(__FUNCTION__ << ": skipping refresh - daemon is not synced"); } diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index e9f59cd8c1..3cb583afe5 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1250,7 +1250,7 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended, std m_original_keys_available(false), m_message_store(http_client_factory->create()), m_key_device_type(hw::device::device_type::SOFTWARE), - m_ring_history_saved(false), + m_ring_history_saved(true), m_ringdb(), m_last_block_reward(0), m_unattended(unattended), @@ -6520,15 +6520,6 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass if (get_num_subaddress_accounts() == 0) add_subaddress_account(tr("Primary account")); - try - { - find_and_save_rings(false); - } - catch (const std::exception &e) - { - MERROR("Failed to save rings, will try again next time"); - } - try { if (use_fs) @@ -8918,67 +8909,11 @@ bool wallet2::unset_ring(const crypto::hash &txid) bool wallet2::find_and_save_rings(bool force) { - if (!force && m_ring_history_saved) - return true; - if (!m_ringdb) + if (force) + { + MWARNING("wallet2::find_and_save_rings() is deprecated"); return false; - - COMMAND_RPC_GET_TRANSACTIONS::request req = AUTO_VAL_INIT(req); - COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res); - - MDEBUG("Finding and saving rings..."); - - // get payments we made - std::vector txs_hashes; - std::list> payments; - get_payments_out(payments, 0, std::numeric_limits::max(), boost::none, std::set()); - for (const std::pair &entry: payments) - { - const crypto::hash &txid = entry.first; - txs_hashes.push_back(txid); } - - MDEBUG("Found " << std::to_string(txs_hashes.size()) << " transactions"); - - // get those transactions from the daemon - auto it = txs_hashes.begin(); - static const size_t SLICE_SIZE = 200; - for (size_t slice = 0; slice < txs_hashes.size(); slice += SLICE_SIZE) - { - req.decode_as_json = false; - req.prune = true; - req.txs_hashes.clear(); - size_t ntxes = slice + SLICE_SIZE > txs_hashes.size() ? txs_hashes.size() - slice : SLICE_SIZE; - for (size_t s = slice; s < slice + ntxes; ++s) - req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txs_hashes[s])); - - { - const boost::lock_guard lock{m_daemon_rpc_mutex}; - uint64_t pre_call_credits = m_rpc_payment_state.credits; - req.client = get_client_signature(); - bool r = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client, rpc_timeout); - THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, {}, res, "/gettransactions"); - THROW_WALLET_EXCEPTION_IF(res.txs.size() != req.txs_hashes.size(), error::wallet_internal_error, - "daemon returned wrong response for gettransactions, wrong txs count = " + - std::to_string(res.txs.size()) + ", expected " + std::to_string(req.txs_hashes.size())); - check_rpc_cost("/gettransactions", res.credits, pre_call_credits, res.txs.size() * COST_PER_TX); - } - - MDEBUG("Scanning " << res.txs.size() << " transactions"); - THROW_WALLET_EXCEPTION_IF(slice + res.txs.size() > txs_hashes.size(), error::wallet_internal_error, "Unexpected tx array size"); - for (size_t i = 0; i < res.txs.size(); ++i, ++it) - { - const auto &tx_info = res.txs[i]; - cryptonote::transaction tx; - crypto::hash tx_hash; - THROW_WALLET_EXCEPTION_IF(!get_pruned_tx(tx_info, tx, tx_hash), error::wallet_internal_error, - "Failed to get transaction from daemon"); - THROW_WALLET_EXCEPTION_IF(!(tx_hash == *it), error::wallet_internal_error, "Wrong txid received"); - THROW_WALLET_EXCEPTION_IF(!add_rings(get_ringdb_key(), tx), error::wallet_internal_error, "Failed to save ring"); - } - } - - MINFO("Found and saved rings for " << txs_hashes.size() << " transactions"); m_ring_history_saved = true; return true; } diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 187f6ccc3c..66c244bd18 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1767,7 +1767,7 @@ private: bool set_rings(const std::vector>> &rings, bool relative); bool unset_ring(const std::vector &key_images); bool unset_ring(const crypto::hash &txid); - bool find_and_save_rings(bool force = true); + [[deprecated]] bool find_and_save_rings(bool force = true); bool blackball_output(const std::pair &output); bool set_blackballed_outputs(const std::vector> &outputs, bool add = false);