aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobtoht <tob@featherwallet.org>2025-08-01 11:52:22 +0000
committertobtoht <tob@featherwallet.org>2025-08-01 11:52:22 +0000
commit35efc7e340cf3d672c66e48112e275b03ff69cd6 (patch)
tree8700c9d7d9eb3bcf3f365f6d5963c30c4b222e4d
parentec870e50706a29768a65f597155ed5c7ad7e6326 (diff)
parent8f98dac4f02e1c7f431c3917f95cb9a235e668b9 (diff)
downloadmonzero-core-35efc7e340cf3d672c66e48112e275b03ff69cd6.tar.gz
monzero-core-35efc7e340cf3d672c66e48112e275b03ff69cd6.tar.xz
monzero-core-35efc7e340cf3d672c66e48112e275b03ff69cd6.zip
Merge pull request #10015
8f98dac wallet: deprecate wallet2::find_and_save_rings() (jeffro256)
-rw-r--r--src/simplewallet/simplewallet.cpp10
-rw-r--r--src/wallet/api/wallet.cpp1
-rw-r--r--src/wallet/wallet2.cpp73
-rw-r--r--src/wallet/wallet2.h2
4 files changed, 6 insertions, 80 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index fd8a82b52..33f5f64d7 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -2231,15 +2231,7 @@ bool simple_wallet::blackballed(const std::vector<std::string> &args)
bool simple_wallet::save_known_rings(const std::vector<std::string> &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 8fda0bab7..165b21c9f 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 e9f59cd8c..3cb583afe 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),
@@ -6522,15 +6522,6 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass
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)
m_message_store.read_from_file(get_multisig_wallet_state(), m_mms_file, m_load_deprecated_formats);
}
@@ -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)
- 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<crypto::hash> txs_hashes;
- std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> payments;
- get_payments_out(payments, 0, std::numeric_limits<uint64_t>::max(), boost::none, std::set<uint32_t>());
- for (const std::pair<crypto::hash,wallet2::confirmed_transfer_details> &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)
+ if (force)
{
- 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<boost::recursive_mutex> 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");
- }
+ MWARNING("wallet2::find_and_save_rings() is deprecated");
+ return false;
}
-
- 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 187f6ccc3..66c244bd1 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -1767,7 +1767,7 @@ private:
bool set_rings(const std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> &rings, bool relative);
bool unset_ring(const std::vector<crypto::key_image> &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<uint64_t, uint64_t> &output);
bool set_blackballed_outputs(const std::vector<std::pair<uint64_t, uint64_t>> &outputs, bool add = false);