From 71f754c2f6e6e380d472ea81a7f3b51f91560452 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 5 Oct 2016 15:29:57 +0800 Subject: [PATCH] show real mixing in signed tx details --- src/page.h | 58 ++++++++++++++++++++++++++ src/templates/partials/tx_details.html | 14 +++++++ 2 files changed, 72 insertions(+) diff --git a/src/page.h b/src/page.h index 70bfffa..2602c0e 100644 --- a/src/page.h +++ b/src/page.h @@ -1475,8 +1475,65 @@ namespace xmreg { for (tools::wallet2::pending_tx& ptx: ptxs) { + // get public keys of real outputs + + vector real_output_pub_keys; + + for (const tx_source_entry& tx_source: ptx.construction_data.sources) + { + transaction real_source_tx; + + uint64_t index_of_real_output = tx_source.outputs[tx_source.real_output].first; + + // get tx of the real output + tx_out_index real_toi = core_storage->get_db() + .get_output_tx_and_index(0, index_of_real_output); + + if (!mcore->get_tx(real_toi.first, real_source_tx)) + { + cerr << "Cant get tx in blockchain: " << real_toi.first << endl; + return string("Cant get tx: " + pod_to_hex(real_toi.first)); + } + + tx_details real_txd = get_tx_details(real_source_tx); + + public_key real_out_pub_key = real_txd.output_pub_keys[tx_source.real_output_in_tx_index].first.key; + + real_output_pub_keys.push_back( + REMOVE_HASH_BRAKETS(fmt::format("{:s}",real_out_pub_key)) + ); + } + mstch::map tx_context = construct_tx_context(ptx.tx); + // get reference to inputs array created of the tx + mstch::array& inputs = boost::get(tx_context["inputs"]); + + for (mstch::node& input_node: inputs) + { + mstch::array& mixins = boost::get( + boost::get(input_node)["mixins"] + ); + + for (mstch::node& mixin_node: mixins) + { + mstch::map& mixin = boost::get(mixin_node); + + string mix_pub_key_str = boost::get(mixin["mix_pub_key"]); + + //cout << mix_pub_key_str << endl; + + if (std::find( + real_output_pub_keys.begin(), + real_output_pub_keys.end(), + mix_pub_key_str) != real_output_pub_keys.end()) + { + mixin["mix_is_it_real"] = true; + } + } + + } + boost::get(context["txs"]).push_back(tx_context); } @@ -2296,6 +2353,7 @@ namespace xmreg { {"mix_outputs_no" , mixin_txd.output_pub_keys.size()}, {"mix_age_format" , mixin_age.second}, {"mix_idx" , fmt::format("{:02d}", count)}, + {"mix_is_it_real" , false}, // a placeholder for future }); if (blk.timestamp < min_mix_timestamp) diff --git a/src/templates/partials/tx_details.html b/src/templates/partials/tx_details.html index 423255e..ad17bd0 100644 --- a/src/templates/partials/tx_details.html +++ b/src/templates/partials/tx_details.html @@ -133,20 +133,34 @@ + {{#have_raw_tx}} + + {{/have_raw_tx}} + + {{#mixins}} + {{#have_raw_tx}} + {{#mix_is_it_real}} + + {{/mix_is_it_real}} + {{^mix_is_it_real}} + + {{/mix_is_it_real}} + {{/have_raw_tx}} + {{/mixins}}
Mixin stealth addressIs it real?blk mixinin/out timestamp age [y:d:h:m:s]
- {{mix_idx}}: {{mix_pub_key}}{{mix_is_it_real}}{{mix_is_it_real}}{{mix_blk}} {{mix_mixin_no}} {{mix_inputs_no}}/{{mix_outputs_no}} {{mix_timestamp}} {{mix_age}}