From 3143506724d65d6519da14fa1284d76140121359 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 20 Jan 2017 05:31:14 +0000 Subject: [PATCH 1/3] mempool link added to front page --- src/page.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/page.h b/src/page.h index ba5a8a7..87ed58c 100644 --- a/src/page.h +++ b/src/page.h @@ -1595,7 +1595,13 @@ public: found_something = true; show_key_images = true; - + // increase sum_mixin_xmr only when + // public key of an outputs used in ring signature, + // matches a public key in a mixin_tx + if (txout_k.key != output_data.pubkey) + { + continue; + } // for regular txs, just concentrated on outputs // which have same amount as the key image. From e4cf9c05d90047ec837b9510634a53079ce4094a Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 20 Jan 2017 06:20:07 +0000 Subject: [PATCH 2/3] fix: iterating over mixins is correct now. --- src/page.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/page.h b/src/page.h index 87ed58c..9fbdb42 100644 --- a/src/page.h +++ b/src/page.h @@ -1415,7 +1415,6 @@ public: size_t count = 0; // for each found output public key check if its ours or not - //for (const cryptonote::output_data_t& output_data: mixin_outputs) for (const uint64_t& abs_offset: absolute_offsets) { @@ -1581,10 +1580,13 @@ public: {"mine_output" , mine_output}, {"out_idx" , to_string(output_idx_in_tx)}, {"formed_output_pk", out_pub_key_str}, - {"out_in_match" , (amount == in_key.amount)}, + {"out_in_match" , (txout_k.key == output_data.pubkey)}, {"amount" , xmreg::xmr_amount_to_str(amount)} }); + //cout << "txout_k.key == output_data.pubkey" << endl; + //cout << pod_to_hex(txout_k.key) << " == " << pod_to_hex(output_data.pubkey) << endl; + if (mine_output) { // cout << " - " << pod_to_hex(txout_k.key) @@ -1624,6 +1626,8 @@ public: has_mixin_outputs = found_something; + ++count; + } // for (const cryptonote::output_data_t& output_data: mixin_outputs) From 8d018ecfdf2dc8b3b847d944ad3830e5ee11d730 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Sun, 22 Jan 2017 07:54:19 +0800 Subject: [PATCH 3/3] few amendments to spending estimation --- src/page.h | 28 +++++++++++++++++++++------- src/templates/my_outputs.html | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/page.h b/src/page.h index 03a9a4c..0e1728a 100644 --- a/src/page.h +++ b/src/page.h @@ -1372,8 +1372,14 @@ public: vector input_key_imgs = xmreg::get_key_images(tx); + // to hold sum of xmr in matched mixins, those that + // perfectly match mixin public key with outputs in mixn_tx. uint64_t sum_mixin_xmr {0}; + // this is used for the final check. we assument that number of + // parefct matches must be equal to number of inputs in a tx. + uint64_t no_of_matched_mixins {0}; + for (const txin_to_key& in_key: input_key_imgs) { @@ -1589,10 +1595,6 @@ public: if (mine_output) { -// cout << " - " << pod_to_hex(txout_k.key) -// <<": " << mine_output << " amount: " -// << xmreg::xmr_amount_to_str(amount) -// << endl; found_something = true; show_key_images = true; @@ -1605,10 +1607,14 @@ public: continue; } + no_of_matched_mixins++; + // for regular txs, just concentrated on outputs // which have same amount as the key image. // for ringct its not possible to know for sure amount // in key image without spend key, so we just use all + // for regular/old txs there must be also a match + // in amounts, not only in output public keys if (mixin_tx.version < 2 && amount == in_key.amount) { sum_mixin_xmr += amount; @@ -1644,21 +1650,29 @@ public: context["show_inputs"] = show_key_images; context["inputs_no"] = static_cast(inputs.size()); - context["sum_mixin_xmr"] = xmreg::xmr_amount_to_str(sum_mixin_xmr); - + context["sum_mixin_xmr"] = xmreg::xmr_amount_to_str( + sum_mixin_xmr, "{:0.12f}", false); uint64_t possible_spending {0}; - if (sum_mixin_xmr > (sum_xmr + txd.fee)) + // show spending only if sum of mixins is more than + // what we get + fee, and number of perferctly matched + // mixis is equal to number of inputs + if (sum_mixin_xmr > (sum_xmr + txd.fee) + && no_of_matched_mixins == inputs.size()) { // (outcoming - incoming) - fee possible_spending = (sum_mixin_xmr - sum_xmr) - txd.fee; } + context["possible_spending"] = xmreg::xmr_amount_to_str( possible_spending, "{:0.12f}", false); + //cout << "no_of_matched_mixins: " << no_of_matched_mixins << endl; + + // read my_outputs.html string my_outputs_html = xmreg::read(TMPL_MY_OUTPUTS); diff --git a/src/templates/my_outputs.html b/src/templates/my_outputs.html index 94ed464..b9f1163 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -132,7 +132,7 @@

- Sum XMR from matched mixin's outputs: {{sum_mixin_xmr}} + Sum XMR from matched and marked by * mixin's outputs: {{sum_mixin_xmr}}
Possible spending is: {{possible_spending}} (tx fee included)