From f1d379d27d02e5da46b3d23e1335019b178c13c6 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 2 Dec 2019 23:21:45 +0000 Subject: [PATCH 1/2] simplewallet: fix "outputs in same tx" detector It was comparing source txids, but txids were empty, so all checks triggered --- src/simplewallet/simplewallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index ea8f6f2f5..b753fa1ed 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -6072,6 +6072,7 @@ bool simple_wallet::print_ring_members(const std::vectorget_rpc_client_secret_key()); bool r = m_wallet->invoke_http_bin("/get_outs.bin", req, res); err = interpret_rpc_response(r, res.status); From 94266eeb89cad13b8f76a0ca16c143baf27820ee Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 2 Dec 2019 23:21:57 +0000 Subject: [PATCH 2/2] simplewallet: fix output age display with duplicate heights The highlight check was based on height, so would highlight any output at that height, resulting in several matches if a fake out was picked at the same height as the real spend --- src/simplewallet/simplewallet.cpp | 23 +++++++++++++---------- src/simplewallet/simplewallet.h | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index b753fa1ed..e6391470e 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -5822,8 +5822,14 @@ bool simple_wallet::show_incoming_transfers(const std::vector& args if (uses) { std::vector heights; - for (const auto &e: td.m_uses) heights.push_back(e.first); - const std::pair line = show_outputs_line(heights, blockchain_height, td.m_spent_height); + uint64_t idx = 0; + for (const auto &e: td.m_uses) + { + heights.push_back(e.first); + if (e.first < td.m_spent_height) + ++idx; + } + const std::pair line = show_outputs_line(heights, blockchain_height, idx); extra_string += std::string("\n ") + tr("Used at heights: ") + line.first + "\n " + line.second; } message_writer(td.m_spent ? console_color_magenta : console_color_green, false) << @@ -5992,7 +5998,7 @@ bool simple_wallet::rescan_spent(const std::vector &args) return true; } //---------------------------------------------------------------------------------------------------- -std::pair simple_wallet::show_outputs_line(const std::vector &heights, uint64_t blockchain_height, uint64_t highlight_height) const +std::pair simple_wallet::show_outputs_line(const std::vector &heights, uint64_t blockchain_height, uint64_t highlight_idx) const { std::stringstream ostr; @@ -6000,7 +6006,7 @@ std::pair simple_wallet::show_outputs_line(const std:: blockchain_height = std::max(blockchain_height, h); for (size_t j = 0; j < heights.size(); ++j) - ostr << (heights[j] == highlight_height ? " *" : " ") << heights[j]; + ostr << (j == highlight_idx ? " *" : " ") << heights[j]; // visualize the distribution, using the code by moneroexamples onion-monero-viewer const uint64_t resolution = 79; @@ -6010,9 +6016,9 @@ std::pair simple_wallet::show_outputs_line(const std:: uint64_t pos = (heights[j] * resolution) / blockchain_height; ring_str[pos] = 'o'; } - if (highlight_height < blockchain_height) + if (highlight_idx < heights.size() && heights[highlight_idx] < blockchain_height) { - uint64_t pos = (highlight_height * resolution) / blockchain_height; + uint64_t pos = (heights[highlight_idx] * resolution) / blockchain_height; ring_str[pos] = '*'; } @@ -6094,14 +6100,11 @@ bool simple_wallet::print_ring_members(const std::vector heights(absolute_offsets.size(), 0); - uint64_t highlight_height = std::numeric_limits::max(); for (size_t j = 0; j < absolute_offsets.size(); ++j) { heights[j] = res.outs[j].height; - if (j == source.real_output) - highlight_height = heights[j]; } - std::pair ring_str = show_outputs_line(heights, blockchain_height, highlight_height); + std::pair ring_str = show_outputs_line(heights, blockchain_height, source.real_output); 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 diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 75bd893d5..2ee14eb8a 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -274,7 +274,7 @@ namespace cryptonote bool print_seed(bool encrypted); void key_images_sync_intern(); void on_refresh_finished(uint64_t start_height, uint64_t fetched_blocks, bool is_init, bool received_money); - std::pair show_outputs_line(const std::vector &heights, uint64_t blockchain_height, uint64_t highlight_height = std::numeric_limits::max()) const; + std::pair show_outputs_line(const std::vector &heights, uint64_t blockchain_height, uint64_t highlight_idx = std::numeric_limits::max()) const; bool freeze_thaw(const std::vector& args, bool freeze); bool prompt_if_old(const std::vector &ptx_vector); bool on_command(bool (simple_wallet::*cmd)(const std::vector&), const std::vector &args);