From 9989cb087e4a31017adbee33131f4bde7ab8cc3f Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 21 Jan 2020 19:56:23 +0000 Subject: [PATCH] simplewallet: warn about correlations if print-ring-members is not set The warning about spending more than one output with similar creation time was skipped if print-ring-members was not set, and it defaults to false, which means most people probably aren't getting this warning if they spend correlated outputs. Reported by SeventhAlpaca. --- src/simplewallet/simplewallet.cpp | 30 +++++++++++++++++------------- src/simplewallet/simplewallet.h | 2 +- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index d981a48b8..9569863b3 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -6064,11 +6064,14 @@ std::pair simple_wallet::show_outputs_line(const std:: return std::make_pair(ostr.str(), ring_str); } //---------------------------------------------------------------------------------------------------- -bool simple_wallet::print_ring_members(const std::vector& ptx_vector, std::ostream& ostr) +bool simple_wallet::process_ring_members(const std::vector& ptx_vector, std::ostream& ostr, bool verbose) { uint32_t version; if (!try_connect_to_daemon(false, &version)) + { + fail_msg_writer() << tr("failed to connect to daemon"); return false; + } // available for RPC version 1.4 or higher if (version < MAKE_CORE_RPC_VERSION(1, 4)) return true; @@ -6084,7 +6087,8 @@ bool simple_wallet::print_ring_members(const std::vector spent_key_height(tx.vin.size()); std::vector spent_key_txid (tx.vin.size()); @@ -6105,7 +6109,8 @@ bool simple_wallet::print_ring_members(const std::vector absolute_offsets = cryptonote::relative_output_offsets_to_absolute(in_key.key_offsets); // get block heights from which those ring member keys originated @@ -6135,7 +6140,8 @@ bool simple_wallet::print_ring_members(const std::vector heights(absolute_offsets.size(), 0); @@ -6144,7 +6150,8 @@ bool simple_wallet::print_ring_members(const std::vector ring_str = show_outputs_line(heights, blockchain_height, source.real_output); - ostr << ring_str.first << tr("\n|") << ring_str.second << tr("|\n"); + if (verbose) + ostr << ring_str.first << tr("\n|") << ring_str.second << tr("|\n"); } // warn if rings contain keys originating from the same tx or temporally very close block heights bool are_keys_from_same_tx = false; @@ -6163,7 +6170,7 @@ bool simple_wallet::print_ring_members(const std::vectorprint_ring_members()) - { - if (!print_ring_members(ptx_vector, prompt)) - return false; - } + if (!process_ring_members(ptx_vector, prompt, m_wallet->print_ring_members())) + return false; bool default_ring_size = true; for (const auto &ptx: ptx_vector) { @@ -7064,7 +7068,7 @@ bool simple_wallet::sweep_main(uint64_t below, bool locked, const std::vector 1) prompt << tr("WARNING: Outputs of multiple addresses are being used together, which might potentially compromise your privacy.\n"); } - if (m_wallet->print_ring_members() && !print_ring_members(ptx_vector, prompt)) + if (!process_ring_members(ptx_vector, prompt, m_wallet->print_ring_members())) return true; if (ptx_vector.size() > 1) { prompt << boost::format(tr("Sweeping %s in %llu transactions for a total fee of %s. Is this okay?")) % @@ -7308,7 +7312,7 @@ bool simple_wallet::sweep_single(const std::vector &args_) uint64_t total_fee = ptx_vector[0].fee; uint64_t total_sent = m_wallet->get_transfer_details(ptx_vector[0].selected_transfers.front()).amount(); std::ostringstream prompt; - if (!print_ring_members(ptx_vector, prompt)) + if (!process_ring_members(ptx_vector, prompt, m_wallet->print_ring_members())) return true; prompt << boost::format(tr("Sweeping %s for a total fee of %s. Is this okay?")) % print_money(total_sent) % diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index c0416ecbb..4ba2793e0 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -270,7 +270,7 @@ namespace cryptonote bool accept_loaded_tx(const std::function get_num_txes, const std::function &get_tx, const std::string &extra_message = std::string()); bool accept_loaded_tx(const tools::wallet2::unsigned_tx_set &txs); bool accept_loaded_tx(const tools::wallet2::signed_tx_set &txs); - bool print_ring_members(const std::vector& ptx_vector, std::ostream& ostr); + bool process_ring_members(const std::vector& ptx_vector, std::ostream& ostr, bool verbose); std::string get_prompt() const; bool print_seed(bool encrypted); void key_images_sync_intern();