From 0744587cf000c42811341c71c916d579f0920f64 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Tue, 17 Jan 2017 17:07:14 +0800 Subject: [PATCH 01/18] searching for mixins with outputs started --- src/page.h | 68 +++++++++++++++++++++++------------ src/templates/my_outputs.html | 45 ++++++++++++----------- 2 files changed, 70 insertions(+), 43 deletions(-) diff --git a/src/page.h b/src/page.h index 66ec4ca..58aa8c2 100644 --- a/src/page.h +++ b/src/page.h @@ -1322,8 +1322,10 @@ public: // we can also test ouputs used in mixins for key images // this can show possible spending. Only possible, because // without a spend key, we cant know for sure. It might be - // that our output was used by someelse for their mixin. - // for this we can look in our custom db, for efficiencly + // that our output was used by someone else for their mixins. + // For this we can look in our custom db, for efficiencly + + bool show_key_images {false}; unique_ptr mylmdb; @@ -1341,6 +1343,7 @@ public: if (!mylmdb) { + show_key_images = false; break; } @@ -1378,13 +1381,13 @@ public: // to store our mixins found for the given key image vector> our_mixins_found; - // for each found output public key find check if its ours or not + // for each found output public key check if its ours or not for (const cryptonote::output_data_t& output_data: mixin_outputs) { string out_pub_key_str = pod_to_hex(output_data.pubkey); - //cout << "out_pub_key_str: " << out_pub_key_str << endl; + cout << "out_pub_key_str: " << out_pub_key_str << endl; // this will be txs where the outputs come from vector found_tx_hashes; @@ -1396,19 +1399,26 @@ public: mixins.push_back(mstch::map{ - {"mixin_pub_key", out_pub_key_str}, - make_pair(string("mixin_outputs"), mstch::array{}) + {"mixin_pub_key" , out_pub_key_str}, + {"mixin_outputs" , mstch::array{}}, + {"has_mixin_outputs", false} }); mstch::array& mixin_outputs = boost::get( boost::get(mixins.back())["mixin_outputs"] ); - // for each output transaction, check if its ours + mstch::node& has_mixin_outputs + = boost::get(mixins.back())["has_mixin_outputs"]; + + + bool found_something {false}; + + + // for each mixin output transaction, check if its ours // as before for (string tx_hash_str: found_tx_hashes) { - crypto::hash tx_hash; hex_to_pod(tx_hash_str, tx_hash); @@ -1422,17 +1432,17 @@ public: } - public_key tx_pub_key + public_key mixin_tx_pub_key = xmreg::get_tx_pub_key_from_received_outs(mixin_tx); - // public transaction key is combined with our viewkey + // public transaction key is combined with our viewkey // to create, so called, derived key. key_derivation derivation; - if (!generate_key_derivation(tx_pub_key, prv_view_key, derivation)) + if (!generate_key_derivation(mixin_tx_pub_key, prv_view_key, derivation)) { cerr << "Cant get derived key for: " << "\n" - << "pub_tx_key: " << tx_pub_key << " and " + << "pub_tx_key: " << mixin_tx_pub_key << " and " << "prv_view_key" << prv_view_key << endl; continue; @@ -1444,14 +1454,17 @@ public: output_pub_keys = xmreg::get_ouputs_tuple(mixin_tx); mixin_outputs.push_back(mstch::map{ - {"mix_tx_hash" , tx_hash_str}, - make_pair(string("found_outputs"), mstch::array{}) + {"mix_tx_hash" , tx_hash_str}, + {"found_outputs" , mstch::array{}}, + {"has_found_outputs", false} }); mstch::array& found_outputs = boost::get( boost::get(mixin_outputs.back())["found_outputs"] ); + mstch::node& has_found_outputs + = boost::get(mixin_outputs.back())["has_found_outputs"]; // for each output in mixin tx, find the one from key_image // and check if its ours. @@ -1462,10 +1475,14 @@ public: uint64_t amount = std::get<1>(mix_out); uint64_t output_idx_in_tx = std::get<2>(mix_out); - //@todo fix this for loop - continue; + cout << " - " << pod_to_hex(txout_k.key) << endl; -// if (mix_out.first.key != output_data.pubkey) +// //@todo fix this for loop +// continue; + +// // analyze only those output keys +// // that were used in mixins +// if (txout_k.key != output_data.pubkey) // { // continue; // } @@ -1492,10 +1509,10 @@ public: bool r; r = decode_ringct(mixin_tx.rct_signatures, - txout_k.key, + mixin_tx_pub_key, prv_view_key, output_idx_in_tx, - mixin_tx.rct_signatures.ecdhInfo[output_idx].mask, + mixin_tx.rct_signatures.ecdhInfo[output_idx_in_tx].mask, rct_amount); if (!r) @@ -1524,20 +1541,27 @@ public: if (mine_output) { - - // cout << " - " << pod_to_hex(txout_k.key) // <<": " << mine_output << " amount: " // << xmreg::xmr_amount_to_str(amount) // << endl; + + found_something = true; + } } // for (const pair& mix_out: txd.output_pub_keys) + has_found_outputs = !found_outputs.empty(); + } // for (string tx_hash_str: found_tx_hashes) + has_mixin_outputs = found_something; + } // for (const cryptonote::output_data_t& output_data: mixin_outputs) + show_key_images = true; + } // for (const txin_to_key& in_key: input_key_imgs) @@ -1545,7 +1569,7 @@ public: context["sum_xmr"] = xmreg::xmr_amount_to_str(sum_xmr); context.emplace("inputs", inputs); - context["show_inputs"] = false; + context["show_inputs"] = show_key_images; // 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 185599c..3325329 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -75,29 +75,32 @@ {{#inputs}}

Key image: {{key_image}}, amount {{key_image_amount}}

{{#mixins}} -
Mixin of pub key: {{mixin_pub_key}}
- {{#mixin_outputs}} -
- uses outputs from tx: - {{mix_tx_hash}} -
- {{#found_outputs}} + {{#has_mixin_outputs}} +
Mixin of pub key: {{mixin_pub_key}}
+ {{#mixin_outputs}} +
+ uses outputs from tx: + {{mix_tx_hash}} +
+ {{#has_found_outputs}} + {{#found_outputs}} -
- Output public key: {{my_public_key}}, - amount: {{amount}}, - is ours: - {{#mine_output}} - {{mine_output}} - {{/mine_output}} - {{^mine_output}} - {{mine_output}} - {{/mine_output}} -
- - {{/found_outputs}} - {{/mixin_outputs}} +
+ Output public key: {{my_public_key}}, + amount: {{amount}}, + is ours: + {{#mine_output}} + {{mine_output}} + {{/mine_output}} + {{^mine_output}} + {{mine_output}} + {{/mine_output}} +
+ {{/found_outputs}} + {{/has_found_outputs}} + {{/mixin_outputs}} + {{/has_mixin_outputs}} {{/mixins}} {{/inputs}} From 88e753bce816395d4621e24380e2988a8d78100a Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 18 Jan 2017 05:19:13 +0000 Subject: [PATCH 02/18] my_outputs.html modified --- src/templates/my_outputs.html | 54 ++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/templates/my_outputs.html b/src/templates/my_outputs.html index 3325329..fe70e86 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -76,29 +76,43 @@

Key image: {{key_image}}, amount {{key_image_amount}}

{{#mixins}} {{#has_mixin_outputs}} -
Mixin of pub key: {{mixin_pub_key}}
{{#mixin_outputs}} -
- uses outputs from tx: - {{mix_tx_hash}} -
+
+ + + + {{#has_found_outputs}} - {{#found_outputs}} - -
- Output public key: {{my_public_key}}, - amount: {{amount}}, - is ours: - {{#mine_output}} - {{mine_output}} - {{/mine_output}} - {{^mine_output}} - {{mine_output}} - {{/mine_output}} -
- - {{/found_outputs}} + {{/has_found_outputs}} +
+ Mixin {{mixin_pub_key}}
might use our outputs from tx: {{mix_tx_hash}} +
+
+ + + + + + + {{#found_outputs}} + + + + + + {{/found_outputs}} +
output public keyamountis ours?
{{my_public_key}}{{amount}} + {{#mine_output}} + {{mine_output}} + {{/mine_output}} + {{^mine_output}} + {{mine_output}} + {{/mine_output}} +
+
+
+
{{/mixin_outputs}} {{/has_mixin_outputs}} {{/mixins}} From 7a3046c200a5b0ca6eaedc0c7fcd179ed1d197f2 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 18 Jan 2017 06:35:12 +0000 Subject: [PATCH 03/18] my_outputs.html modified --- src/page.h | 17 ++++++++--------- src/templates/my_outputs.html | 6 +++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/page.h b/src/page.h index 58aa8c2..02f704f 100644 --- a/src/page.h +++ b/src/page.h @@ -1387,7 +1387,7 @@ public: string out_pub_key_str = pod_to_hex(output_data.pubkey); - cout << "out_pub_key_str: " << out_pub_key_str << endl; + //cout << "out_pub_key_str: " << out_pub_key_str << endl; // this will be txs where the outputs come from vector found_tx_hashes; @@ -1401,7 +1401,7 @@ public: mixins.push_back(mstch::map{ {"mixin_pub_key" , out_pub_key_str}, {"mixin_outputs" , mstch::array{}}, - {"has_mixin_outputs", false} + {"has_mixin_outputs" , false} }); mstch::array& mixin_outputs = boost::get( @@ -1431,10 +1431,11 @@ public: continue; } - public_key mixin_tx_pub_key = xmreg::get_tx_pub_key_from_received_outs(mixin_tx); + string mixin_tx_pub_key_str = pod_to_hex(mixin_tx_pub_key); + // public transaction key is combined with our viewkey // to create, so called, derived key. key_derivation derivation; @@ -1455,6 +1456,7 @@ public: mixin_outputs.push_back(mstch::map{ {"mix_tx_hash" , tx_hash_str}, + {"mix_tx_pub_key" , mixin_tx_pub_key_str}, {"found_outputs" , mstch::array{}}, {"has_found_outputs", false} }); @@ -1475,10 +1477,7 @@ public: uint64_t amount = std::get<1>(mix_out); uint64_t output_idx_in_tx = std::get<2>(mix_out); - cout << " - " << pod_to_hex(txout_k.key) << endl; - -// //@todo fix this for loop -// continue; + //cout << " - " << pod_to_hex(txout_k.key) << endl; // // analyze only those output keys // // that were used in mixins @@ -1547,7 +1546,7 @@ public: // << endl; found_something = true; - + show_key_images = true; } } // for (const pair& mix_out: txd.output_pub_keys) @@ -1560,7 +1559,7 @@ public: } // for (const cryptonote::output_data_t& output_data: mixin_outputs) - show_key_images = true; + } // for (const txin_to_key& in_key: input_key_imgs) diff --git a/src/templates/my_outputs.html b/src/templates/my_outputs.html index fe70e86..0b8189a 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -68,8 +68,6 @@ {{#show_inputs}} -
-

Inputs

{{#inputs}} @@ -81,7 +79,9 @@ {{#has_found_outputs}} From 67f361f47c0d96f589b55da97c68a89d3c7d4b75 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 18 Jan 2017 06:46:50 +0000 Subject: [PATCH 04/18] refactoring started --- src/page.h | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/page.h b/src/page.h index 02f704f..5dd7324 100644 --- a/src/page.h +++ b/src/page.h @@ -1381,22 +1381,53 @@ public: // to store our mixins found for the given key image vector> our_mixins_found; + // mixin counter + 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 cryptonote::output_data_t& output_data: mixin_outputs) + for (const uint64_t& abs_offset: absolute_offsets) { + // get basic information about mixn's output + cryptonote::output_data_t output_data = mixin_outputs.at(count); + + tx_out_index tx_out_idx; + + try + { + // get pair pair where first is tx hash + // and second is local index of the output i in that tx + tx_out_idx = core_storage->get_db() + .get_output_tx_and_index(in_key.amount, abs_offset); + } + catch (const OUTPUT_DNE& e) + { + + string out_msg = fmt::format( + "Output with amount {:d} and index {:d} does not exist!", + in_key.amount, abs_offset + ); + + cerr << out_msg << endl; + + break; + } + string out_pub_key_str = pod_to_hex(output_data.pubkey); //cout << "out_pub_key_str: " << out_pub_key_str << endl; - // this will be txs where the outputs come from - vector found_tx_hashes; + // get mixin transaction + transaction mixin_tx; - mylmdb->search(out_pub_key_str, - found_tx_hashes, - "output_public_keys"); + if (!mcore->get_tx(tx_out_idx.first, mixin_tx)) + { + cerr << "Cant get tx: " << tx_out_idx.first << endl; + break; + } mixins.push_back(mstch::map{ {"mixin_pub_key" , out_pub_key_str}, From 17cd272f1c00b731cbe7b772ab4615a5f6370e7f Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Tue, 17 Jan 2017 17:07:14 +0800 Subject: [PATCH 05/18] searching for mixins with outputs started --- src/page.h | 68 +++++++++++++++++++++++------------ src/templates/my_outputs.html | 45 ++++++++++++----------- 2 files changed, 70 insertions(+), 43 deletions(-) diff --git a/src/page.h b/src/page.h index aa2f399..d972b88 100644 --- a/src/page.h +++ b/src/page.h @@ -1330,8 +1330,10 @@ public: // we can also test ouputs used in mixins for key images // this can show possible spending. Only possible, because // without a spend key, we cant know for sure. It might be - // that our output was used by someelse for their mixin. - // for this we can look in our custom db, for efficiencly + // that our output was used by someone else for their mixins. + // For this we can look in our custom db, for efficiencly + + bool show_key_images {false}; unique_ptr mylmdb; @@ -1349,6 +1351,7 @@ public: if (!mylmdb) { + show_key_images = false; break; } @@ -1386,13 +1389,13 @@ public: // to store our mixins found for the given key image vector> our_mixins_found; - // for each found output public key find check if its ours or not + // for each found output public key check if its ours or not for (const cryptonote::output_data_t& output_data: mixin_outputs) { string out_pub_key_str = pod_to_hex(output_data.pubkey); - //cout << "out_pub_key_str: " << out_pub_key_str << endl; + cout << "out_pub_key_str: " << out_pub_key_str << endl; // this will be txs where the outputs come from vector found_tx_hashes; @@ -1404,19 +1407,26 @@ public: mixins.push_back(mstch::map{ - {"mixin_pub_key", out_pub_key_str}, - make_pair(string("mixin_outputs"), mstch::array{}) + {"mixin_pub_key" , out_pub_key_str}, + {"mixin_outputs" , mstch::array{}}, + {"has_mixin_outputs", false} }); mstch::array& mixin_outputs = boost::get( boost::get(mixins.back())["mixin_outputs"] ); - // for each output transaction, check if its ours + mstch::node& has_mixin_outputs + = boost::get(mixins.back())["has_mixin_outputs"]; + + + bool found_something {false}; + + + // for each mixin output transaction, check if its ours // as before for (string tx_hash_str: found_tx_hashes) { - crypto::hash tx_hash; hex_to_pod(tx_hash_str, tx_hash); @@ -1430,17 +1440,17 @@ public: } - public_key tx_pub_key + public_key mixin_tx_pub_key = xmreg::get_tx_pub_key_from_received_outs(mixin_tx); - // public transaction key is combined with our viewkey + // public transaction key is combined with our viewkey // to create, so called, derived key. key_derivation derivation; - if (!generate_key_derivation(tx_pub_key, prv_view_key, derivation)) + if (!generate_key_derivation(mixin_tx_pub_key, prv_view_key, derivation)) { cerr << "Cant get derived key for: " << "\n" - << "pub_tx_key: " << tx_pub_key << " and " + << "pub_tx_key: " << mixin_tx_pub_key << " and " << "prv_view_key" << prv_view_key << endl; continue; @@ -1452,14 +1462,17 @@ public: output_pub_keys = xmreg::get_ouputs_tuple(mixin_tx); mixin_outputs.push_back(mstch::map{ - {"mix_tx_hash" , tx_hash_str}, - make_pair(string("found_outputs"), mstch::array{}) + {"mix_tx_hash" , tx_hash_str}, + {"found_outputs" , mstch::array{}}, + {"has_found_outputs", false} }); mstch::array& found_outputs = boost::get( boost::get(mixin_outputs.back())["found_outputs"] ); + mstch::node& has_found_outputs + = boost::get(mixin_outputs.back())["has_found_outputs"]; // for each output in mixin tx, find the one from key_image // and check if its ours. @@ -1470,10 +1483,14 @@ public: uint64_t amount = std::get<1>(mix_out); uint64_t output_idx_in_tx = std::get<2>(mix_out); - //@todo fix this for loop - continue; + cout << " - " << pod_to_hex(txout_k.key) << endl; -// if (mix_out.first.key != output_data.pubkey) +// //@todo fix this for loop +// continue; + +// // analyze only those output keys +// // that were used in mixins +// if (txout_k.key != output_data.pubkey) // { // continue; // } @@ -1500,10 +1517,10 @@ public: bool r; r = decode_ringct(mixin_tx.rct_signatures, - txout_k.key, + mixin_tx_pub_key, prv_view_key, output_idx_in_tx, - mixin_tx.rct_signatures.ecdhInfo[output_idx].mask, + mixin_tx.rct_signatures.ecdhInfo[output_idx_in_tx].mask, rct_amount); if (!r) @@ -1532,20 +1549,27 @@ public: if (mine_output) { - - // cout << " - " << pod_to_hex(txout_k.key) // <<": " << mine_output << " amount: " // << xmreg::xmr_amount_to_str(amount) // << endl; + + found_something = true; + } } // for (const pair& mix_out: txd.output_pub_keys) + has_found_outputs = !found_outputs.empty(); + } // for (string tx_hash_str: found_tx_hashes) + has_mixin_outputs = found_something; + } // for (const cryptonote::output_data_t& output_data: mixin_outputs) + show_key_images = true; + } // for (const txin_to_key& in_key: input_key_imgs) @@ -1554,7 +1578,7 @@ public: context["sum_xmr"] = xmreg::xmr_amount_to_str(sum_xmr); context.emplace("inputs", inputs); - context["show_inputs"] = false; + context["show_inputs"] = show_key_images; // 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 7dd8f4e..323fabf 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -83,29 +83,32 @@ {{#inputs}}

Key image: {{key_image}}, amount {{key_image_amount}}

{{#mixins}} -
Mixin of pub key: {{mixin_pub_key}}
- {{#mixin_outputs}} -
- uses outputs from tx: - {{mix_tx_hash}} -
- {{#found_outputs}} + {{#has_mixin_outputs}} +
Mixin of pub key: {{mixin_pub_key}}
+ {{#mixin_outputs}} +
+ uses outputs from tx: + {{mix_tx_hash}} +
+ {{#has_found_outputs}} + {{#found_outputs}} -
- Output public key: {{my_public_key}}, - amount: {{amount}}, - is ours: - {{#mine_output}} - {{mine_output}} - {{/mine_output}} - {{^mine_output}} - {{mine_output}} - {{/mine_output}} -
- - {{/found_outputs}} - {{/mixin_outputs}} +
+ Output public key: {{my_public_key}}, + amount: {{amount}}, + is ours: + {{#mine_output}} + {{mine_output}} + {{/mine_output}} + {{^mine_output}} + {{mine_output}} + {{/mine_output}} +
+ {{/found_outputs}} + {{/has_found_outputs}} + {{/mixin_outputs}} + {{/has_mixin_outputs}} {{/mixins}} {{/inputs}} From aabba1b8b1cd75d34cf680b4e0ca29c94845132a Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 18 Jan 2017 05:19:13 +0000 Subject: [PATCH 06/18] my_outputs.html modified --- src/templates/my_outputs.html | 54 ++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/templates/my_outputs.html b/src/templates/my_outputs.html index 323fabf..f20b2dd 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -84,29 +84,43 @@

Key image: {{key_image}}, amount {{key_image_amount}}

{{#mixins}} {{#has_mixin_outputs}} -
Mixin of pub key: {{mixin_pub_key}}
{{#mixin_outputs}} -
- uses outputs from tx: - {{mix_tx_hash}} -
+
+
- Mixin {{mixin_pub_key}}
might use our outputs from tx: {{mix_tx_hash}} + Mixin {{mixin_pub_key}} might use our outputs +
+ from tx of public key: {{mix_tx_pub_key}}
+ + + {{#has_found_outputs}} - {{#found_outputs}} - -
- Output public key: {{my_public_key}}, - amount: {{amount}}, - is ours: - {{#mine_output}} - {{mine_output}} - {{/mine_output}} - {{^mine_output}} - {{mine_output}} - {{/mine_output}} -
- - {{/found_outputs}} + {{/has_found_outputs}} +
+ Mixin {{mixin_pub_key}}
might use our outputs from tx: {{mix_tx_hash}} +
+
+ + + + + + + {{#found_outputs}} + + + + + + {{/found_outputs}} +
output public keyamountis ours?
{{my_public_key}}{{amount}} + {{#mine_output}} + {{mine_output}} + {{/mine_output}} + {{^mine_output}} + {{mine_output}} + {{/mine_output}} +
+
+
+
{{/mixin_outputs}} {{/has_mixin_outputs}} {{/mixins}} From fe8ed78bfa04d543a2ef510b630884ef0f9165c6 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 18 Jan 2017 06:35:12 +0000 Subject: [PATCH 07/18] my_outputs.html modified --- src/page.h | 17 ++++++++--------- src/templates/my_outputs.html | 6 +++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/page.h b/src/page.h index d972b88..89c3655 100644 --- a/src/page.h +++ b/src/page.h @@ -1395,7 +1395,7 @@ public: string out_pub_key_str = pod_to_hex(output_data.pubkey); - cout << "out_pub_key_str: " << out_pub_key_str << endl; + //cout << "out_pub_key_str: " << out_pub_key_str << endl; // this will be txs where the outputs come from vector found_tx_hashes; @@ -1409,7 +1409,7 @@ public: mixins.push_back(mstch::map{ {"mixin_pub_key" , out_pub_key_str}, {"mixin_outputs" , mstch::array{}}, - {"has_mixin_outputs", false} + {"has_mixin_outputs" , false} }); mstch::array& mixin_outputs = boost::get( @@ -1439,10 +1439,11 @@ public: continue; } - public_key mixin_tx_pub_key = xmreg::get_tx_pub_key_from_received_outs(mixin_tx); + string mixin_tx_pub_key_str = pod_to_hex(mixin_tx_pub_key); + // public transaction key is combined with our viewkey // to create, so called, derived key. key_derivation derivation; @@ -1463,6 +1464,7 @@ public: mixin_outputs.push_back(mstch::map{ {"mix_tx_hash" , tx_hash_str}, + {"mix_tx_pub_key" , mixin_tx_pub_key_str}, {"found_outputs" , mstch::array{}}, {"has_found_outputs", false} }); @@ -1483,10 +1485,7 @@ public: uint64_t amount = std::get<1>(mix_out); uint64_t output_idx_in_tx = std::get<2>(mix_out); - cout << " - " << pod_to_hex(txout_k.key) << endl; - -// //@todo fix this for loop -// continue; + //cout << " - " << pod_to_hex(txout_k.key) << endl; // // analyze only those output keys // // that were used in mixins @@ -1555,7 +1554,7 @@ public: // << endl; found_something = true; - + show_key_images = true; } } // for (const pair& mix_out: txd.output_pub_keys) @@ -1568,7 +1567,7 @@ public: } // for (const cryptonote::output_data_t& output_data: mixin_outputs) - show_key_images = true; + } // for (const txin_to_key& in_key: input_key_imgs) diff --git a/src/templates/my_outputs.html b/src/templates/my_outputs.html index f20b2dd..d6ed37d 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -76,8 +76,6 @@ {{#show_inputs}} -
-

Inputs

{{#inputs}} @@ -89,7 +87,9 @@ {{#has_found_outputs}} From 8f62a7c7d9337b0f0a882b7a6047c9fe19e2f2b9 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 18 Jan 2017 06:46:50 +0000 Subject: [PATCH 08/18] refactoring started --- src/page.h | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/page.h b/src/page.h index 89c3655..2fc16a3 100644 --- a/src/page.h +++ b/src/page.h @@ -1389,22 +1389,53 @@ public: // to store our mixins found for the given key image vector> our_mixins_found; + // mixin counter + 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 cryptonote::output_data_t& output_data: mixin_outputs) + for (const uint64_t& abs_offset: absolute_offsets) { + // get basic information about mixn's output + cryptonote::output_data_t output_data = mixin_outputs.at(count); + + tx_out_index tx_out_idx; + + try + { + // get pair pair where first is tx hash + // and second is local index of the output i in that tx + tx_out_idx = core_storage->get_db() + .get_output_tx_and_index(in_key.amount, abs_offset); + } + catch (const OUTPUT_DNE& e) + { + + string out_msg = fmt::format( + "Output with amount {:d} and index {:d} does not exist!", + in_key.amount, abs_offset + ); + + cerr << out_msg << endl; + + break; + } + string out_pub_key_str = pod_to_hex(output_data.pubkey); //cout << "out_pub_key_str: " << out_pub_key_str << endl; - // this will be txs where the outputs come from - vector found_tx_hashes; + // get mixin transaction + transaction mixin_tx; - mylmdb->search(out_pub_key_str, - found_tx_hashes, - "output_public_keys"); + if (!mcore->get_tx(tx_out_idx.first, mixin_tx)) + { + cerr << "Cant get tx: " << tx_out_idx.first << endl; + break; + } mixins.push_back(mstch::map{ {"mixin_pub_key" , out_pub_key_str}, From bfd620a78bfdc6c68f793588c9b8e7b075f2802b Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Tue, 17 Jan 2017 17:07:14 +0800 Subject: [PATCH 09/18] searching for mixins with outputs started --- src/page.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/page.h b/src/page.h index 2fc16a3..787e7b4 100644 --- a/src/page.h +++ b/src/page.h @@ -1424,7 +1424,7 @@ public: string out_pub_key_str = pod_to_hex(output_data.pubkey); - //cout << "out_pub_key_str: " << out_pub_key_str << endl; + cout << "out_pub_key_str: " << out_pub_key_str << endl; // get mixin transaction From 255c9b50e4a728f444fa7c42eb4efa47133ee9ed Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 18 Jan 2017 06:35:12 +0000 Subject: [PATCH 10/18] my_outputs.html modified --- src/page.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/page.h b/src/page.h index 787e7b4..2fc16a3 100644 --- a/src/page.h +++ b/src/page.h @@ -1424,7 +1424,7 @@ public: string out_pub_key_str = pod_to_hex(output_data.pubkey); - cout << "out_pub_key_str: " << out_pub_key_str << endl; + //cout << "out_pub_key_str: " << out_pub_key_str << endl; // get mixin transaction From 91c7dc7b51c366a7bba9dc173394912601e2dcb0 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 18 Jan 2017 23:36:34 +0000 Subject: [PATCH 11/18] searching for our mixins dont use custom lmdb now --- src/page.h | 196 ++++++++++++++++++++++++----------------------------- 1 file changed, 90 insertions(+), 106 deletions(-) diff --git a/src/page.h b/src/page.h index 2fc16a3..177b925 100644 --- a/src/page.h +++ b/src/page.h @@ -1454,69 +1454,53 @@ public: bool found_something {false}; - // for each mixin output transaction, check if its ours - // as before - for (string tx_hash_str: found_tx_hashes) + public_key mixin_tx_pub_key + = xmreg::get_tx_pub_key_from_received_outs(mixin_tx); + + string mixin_tx_pub_key_str = pod_to_hex(mixin_tx_pub_key); + + // public transaction key is combined with our viewkey + // to create, so called, derived key. + key_derivation derivation; + + if (!generate_key_derivation(mixin_tx_pub_key, prv_view_key, derivation)) { - crypto::hash tx_hash; + cerr << "Cant get derived key for: " << "\n" + << "pub_tx_key: " << mixin_tx_pub_key << " and " + << "prv_view_key" << prv_view_key << endl; - hex_to_pod(tx_hash_str, tx_hash); + continue; + } - transaction mixin_tx; + // + vector> output_pub_keys; - if (!mcore->get_tx(tx_hash, mixin_tx)) - { - cerr << "Cant get tx in blockchain: " << tx_hash << endl; - continue; - } + output_pub_keys = xmreg::get_ouputs_tuple(mixin_tx); - public_key mixin_tx_pub_key - = xmreg::get_tx_pub_key_from_received_outs(mixin_tx); + mixin_outputs.push_back(mstch::map{ + {"mix_tx_hash" , tx_hash_str}, + {"mix_tx_pub_key" , mixin_tx_pub_key_str}, + {"found_outputs" , mstch::array{}}, + {"has_found_outputs", false} + }); - string mixin_tx_pub_key_str = pod_to_hex(mixin_tx_pub_key); + mstch::array& found_outputs = boost::get( + boost::get(mixin_outputs.back())["found_outputs"] + ); - // public transaction key is combined with our viewkey - // to create, so called, derived key. - key_derivation derivation; + mstch::node& has_found_outputs + = boost::get(mixin_outputs.back())["has_found_outputs"]; - if (!generate_key_derivation(mixin_tx_pub_key, prv_view_key, derivation)) - { - cerr << "Cant get derived key for: " << "\n" - << "pub_tx_key: " << mixin_tx_pub_key << " and " - << "prv_view_key" << prv_view_key << endl; + // for each output in mixin tx, find the one from key_image + // and check if its ours. + for (const auto& mix_out: output_pub_keys) + { - continue; - } + txout_to_key txout_k = std::get<0>(mix_out); + uint64_t amount = std::get<1>(mix_out); + uint64_t output_idx_in_tx = std::get<2>(mix_out); - // - vector> output_pub_keys; - - output_pub_keys = xmreg::get_ouputs_tuple(mixin_tx); - - mixin_outputs.push_back(mstch::map{ - {"mix_tx_hash" , tx_hash_str}, - {"mix_tx_pub_key" , mixin_tx_pub_key_str}, - {"found_outputs" , mstch::array{}}, - {"has_found_outputs", false} - }); - - mstch::array& found_outputs = boost::get( - boost::get(mixin_outputs.back())["found_outputs"] - ); - - mstch::node& has_found_outputs - = boost::get(mixin_outputs.back())["has_found_outputs"]; - - // for each output in mixin tx, find the one from key_image - // and check if its ours. - for (const auto& mix_out: output_pub_keys) - { - - txout_to_key txout_k = std::get<0>(mix_out); - uint64_t amount = std::get<1>(mix_out); - uint64_t output_idx_in_tx = std::get<2>(mix_out); - - //cout << " - " << pod_to_hex(txout_k.key) << endl; + //cout << " - " << pod_to_hex(txout_k.key) << endl; // // analyze only those output keys // // that were used in mixins @@ -1525,74 +1509,74 @@ public: // continue; // } - // get the tx output public key - // that normally would be generated for us, - // if someone had sent us some xmr. - public_key tx_pubkey_generated; + // get the tx output public key + // that normally would be generated for us, + // if someone had sent us some xmr. + public_key tx_pubkey_generated; - derive_public_key(derivation, + derive_public_key(derivation, + output_idx_in_tx, + address.m_spend_public_key, + tx_pubkey_generated); + + // check if generated public key matches the current output's key + bool mine_output = (txout_k.key == tx_pubkey_generated); + + + if (mine_output && mixin_tx.version == 2) + { + // initialize with regular amount + uint64_t rct_amount = amount; + + bool r; + + r = decode_ringct(mixin_tx.rct_signatures, + mixin_tx_pub_key, + prv_view_key, output_idx_in_tx, - address.m_spend_public_key, - tx_pubkey_generated); + mixin_tx.rct_signatures.ecdhInfo[output_idx_in_tx].mask, + rct_amount); - // check if generated public key matches the current output's key - bool mine_output = (txout_k.key == tx_pubkey_generated); - - - if (mine_output && mixin_tx.version == 2) + if (!r) { - // initialize with regular amount - uint64_t rct_amount = amount; - - bool r; - - r = decode_ringct(mixin_tx.rct_signatures, - mixin_tx_pub_key, - prv_view_key, - output_idx_in_tx, - mixin_tx.rct_signatures.ecdhInfo[output_idx_in_tx].mask, - rct_amount); - - if (!r) - { - cerr << "show_my_outputs: key images: Cant decode ringCT!" << endl; - } - - // cointbase txs have amounts in plain sight. - // so use amount from ringct, only for non-coinbase txs - if (!is_coinbase(mixin_tx)) - { - amount = rct_amount; - } + cerr << "show_my_outputs: key images: Cant decode ringCT!" << endl; } - - // save our mixnin's public keys - found_outputs.push_back(mstch::map { - {"my_public_key" , pod_to_hex(txout_k.key)}, - {"tx_hash" , tx_hash_str}, - {"mine_output" , mine_output}, - {"out_idx" , to_string(output_idx_in_tx)}, - {"formed_output_pk", out_pub_key_str}, - {"amount" , xmreg::xmr_amount_to_str(amount)}, - }); - - if (mine_output) + // cointbase txs have amounts in plain sight. + // so use amount from ringct, only for non-coinbase txs + if (!is_coinbase(mixin_tx)) { + amount = rct_amount; + } + } + + + // save our mixnin's public keys + found_outputs.push_back(mstch::map { + {"my_public_key" , pod_to_hex(txout_k.key)}, + {"tx_hash" , tx_hash_str}, + {"mine_output" , mine_output}, + {"out_idx" , to_string(output_idx_in_tx)}, + {"formed_output_pk", out_pub_key_str}, + {"amount" , xmreg::xmr_amount_to_str(amount)}, + }); + + 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; - } + found_something = true; + show_key_images = true; + } - } // for (const pair& mix_out: txd.output_pub_keys) + } // for (const pair& mix_out: txd.output_pub_keys) + + has_found_outputs = !found_outputs.empty(); - has_found_outputs = !found_outputs.empty(); - } // for (string tx_hash_str: found_tx_hashes) has_mixin_outputs = found_something; From 591b481ec878ec5c1d50827abd60a87fd61fbdee Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 19 Jan 2017 01:22:33 +0000 Subject: [PATCH 12/18] get_block_by_height refactored --- src/MicroCore.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/MicroCore.cpp b/src/MicroCore.cpp index 996f1d6..66e4124 100644 --- a/src/MicroCore.cpp +++ b/src/MicroCore.cpp @@ -109,33 +109,32 @@ namespace xmreg bool MicroCore::get_block_by_height(const uint64_t& height, block& blk) { - - crypto::hash block_id; - try { - block_id = m_blockchain_storage.get_block_id_by_height(height); + blk = m_blockchain_storage.get_db().get_block_from_height(height); } - catch (const exception& e) + catch (const BLOCK_DNE& e) { - cerr << e.what() << endl; - return false; - } - - if (!m_blockchain_storage.have_block(block_id)) - { - cerr << "Block with hash " << block_id + cerr << "Block of height " << height << " not found in the blockchain!" + << e.what() << endl; return false; } - - if (!m_blockchain_storage.get_block_by_hash(block_id, blk)) + catch (const DB_ERROR& e) { - cerr << "Block with hash " << block_id - << "and height " << height << " not found!" + cerr << "Blockchain access error when getting block " << height + << e.what() << endl; + + return false; + } + catch (...) + { + cerr << "Something went terribly wrong when getting block " << height + << endl; + return false; } From 1463563ba274821b329ade2942bda77cf1e4ced8 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 19 Jan 2017 02:57:39 +0000 Subject: [PATCH 13/18] possible spending added --- src/page.h | 12 +++++++++++- src/templates/my_outputs.html | 11 +++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/page.h b/src/page.h index 45c6a0c..c510728 100644 --- a/src/page.h +++ b/src/page.h @@ -1346,6 +1346,8 @@ public: vector input_key_imgs = xmreg::get_key_images(tx); + uint64_t sum_mixin_xmr {0}; + for (const txin_to_key& in_key: input_key_imgs) { @@ -1570,6 +1572,8 @@ public: found_something = true; show_key_images = true; + + sum_mixin_xmr += amount; } } // for (const pair& mix_out: txd.output_pub_keys) @@ -1594,7 +1598,13 @@ public: context["sum_xmr"] = xmreg::xmr_amount_to_str(sum_xmr); context.emplace("inputs", inputs); - context["show_inputs"] = show_key_images; + context["show_inputs"] = show_key_images; + context["sum_mixin_xmr"] = xmreg::xmr_amount_to_str(sum_mixin_xmr); + + // (outcoming - incoming) - fee + uint64_t possible_spending = (sum_mixin_xmr - sum_xmr) - txd.fee; + context["possible_spending"] = xmreg::xmr_amount_to_str(possible_spending); + // 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 d6ed37d..5cfc5d8 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -63,7 +63,7 @@
- Mixin {{mixin_pub_key}}
might use our outputs from tx: {{mix_tx_hash}} + Mixin {{mixin_pub_key}} might use our outputs +
+ from tx of public key: {{mix_tx_pub_key}}

- Sum XMR from matched outputs: + Sum XMR from matched outputs (i.e., incoming XMR): {{#found_our_outputs}} {{sum_xmr}} {{/found_our_outputs}} @@ -127,7 +127,14 @@ {{/inputs}}

- +

+ Sum XMR from matched mixin's outputs: {{sum_mixin_xmr}} +
+ Possible spending is: {{possible_spending}} +
+ Note: without private spendkey, it is impossible to know whether this is your real spending. + So do not take this number seriously. It is just a guess. +

{{/show_inputs}} From 7da52875a86f5b65057d0c749df3bca3535aefd3 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 19 Jan 2017 04:22:01 +0000 Subject: [PATCH 14/18] possible spending calculation amended --- src/page.h | 40 +++++++++++++++++++++++++++-------- src/templates/my_outputs.html | 20 +++++++++++------- src/tools.h | 13 ++++++++++-- 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/page.h b/src/page.h index c510728..9008600 100644 --- a/src/page.h +++ b/src/page.h @@ -1560,7 +1560,8 @@ public: {"mine_output" , mine_output}, {"out_idx" , to_string(output_idx_in_tx)}, {"formed_output_pk", out_pub_key_str}, - {"amount" , xmreg::xmr_amount_to_str(amount)}, + {"out_in_match" , (amount == in_key.amount)}, + {"amount" , xmreg::xmr_amount_to_str(amount)} }); if (mine_output) @@ -1573,17 +1574,27 @@ public: found_something = true; show_key_images = true; - sum_mixin_xmr += amount; + + + // 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 + if (mixin_tx.version < 2 && amount == in_key.amount) + { + sum_mixin_xmr += amount; + } + else if (mixin_tx.version == 2) // ringct + { + sum_mixin_xmr += amount; + } + } } // for (const pair& mix_out: txd.output_pub_keys) has_found_outputs = !found_outputs.empty(); - - - has_mixin_outputs = found_something; - has_mixin_outputs = found_something; } // for (const cryptonote::output_data_t& output_data: mixin_outputs) @@ -1594,16 +1605,27 @@ public: context.emplace("outputs", outputs); + context["found_our_outputs"] = (sum_xmr > 0); context["sum_xmr"] = xmreg::xmr_amount_to_str(sum_xmr); context.emplace("inputs", inputs); + context["show_inputs"] = show_key_images; + context["inputs_no"] = inputs.size(); context["sum_mixin_xmr"] = xmreg::xmr_amount_to_str(sum_mixin_xmr); - // (outcoming - incoming) - fee - uint64_t possible_spending = (sum_mixin_xmr - sum_xmr) - txd.fee; - context["possible_spending"] = xmreg::xmr_amount_to_str(possible_spending); + + + uint64_t possible_spending {0}; + + if (sum_mixin_xmr > (sum_xmr + txd.fee)) + { + // (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); // read my_outputs.html diff --git a/src/templates/my_outputs.html b/src/templates/my_outputs.html index 5cfc5d8..48ec321 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -40,7 +40,7 @@
- + @@ -76,7 +76,7 @@ {{#show_inputs}} -

Inputs

+

Inputs ({{inputs_no}})

{{#inputs}}

Key image: {{key_image}}, amount {{key_image_amount}}

@@ -87,7 +87,7 @@
Stealth addressoutput public key amount output match?
@@ -99,7 +99,7 @@ - + {{#found_outputs}} @@ -107,7 +107,7 @@
- Mixin {{mixin_pub_key}} might use our outputs + Mixin {{mixin_pub_key}} might use your outputs
from tx of public key: {{mix_tx_pub_key}}
output public key amountis ours?output match?
{{amount}} {{#mine_output}} - {{mine_output}} + {{mine_output}}{{#out_in_match}}*{{/out_in_match}} {{/mine_output}} {{^mine_output}} {{mine_output}} @@ -130,10 +130,14 @@

Sum XMR from matched mixin's outputs: {{sum_mixin_xmr}}
- Possible spending is: {{possible_spending}} + Possible spending is: + {{possible_spending}} (tx fee included) +
- Note: without private spendkey, it is impossible to know whether this is your real spending. - So do not take this number seriously. It is just a guess. + Note: without private spendkey, + it is impossible to know whether this is your real spending.
+ So do not take this number seriously. + It is probably totally wrong anyway.

{{/show_inputs}} diff --git a/src/tools.h b/src/tools.h index a8d499b..e207313 100644 --- a/src/tools.h +++ b/src/tools.h @@ -245,14 +245,23 @@ parse(const std::string& str, string format="%Y-%m-%d %H:%M:%S"); static string -xmr_amount_to_str(const uint64_t& xmr_amount, string _format="{:0.12f}") +xmr_amount_to_str(const uint64_t& xmr_amount, + string _format="{:0.12f}", + bool zero_to_question_mark=true) { string amount_str = "?"; - if (xmr_amount > 0) + if (!zero_to_question_mark) { amount_str = fmt::format(_format, XMR_AMOUNT(xmr_amount)); } + else + { + if (xmr_amount > 0 && zero_to_question_mark == true) + { + amount_str = fmt::format(_format, XMR_AMOUNT(xmr_amount)); + } + } return amount_str; } From 2f5b0fe6b669b4b0200defd9cafff83fe08e1eb0 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 19 Jan 2017 05:38:35 +0000 Subject: [PATCH 15/18] fix: decoding key image file data --- src/page.h | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/page.h b/src/page.h index 9008600..b28dfdf 100644 --- a/src/page.h +++ b/src/page.h @@ -2750,30 +2750,35 @@ public: // seems we found our output. so now lets decode its amount // using ringct - bool r; - - r = decode_ringct(output_source_tx.rct_signatures, - tx_pub_key, - prv_view_key, - output_idx_in_tx, - output_source_tx.rct_signatures.ecdhInfo[output_idx_in_tx].mask, - rct_amount); - - if (!r) + if (output_source_tx.version == 2 + && !is_coinbase(output_source_tx)) { - string error_msg = fmt::format( - "Cant decode ringCT for " - "pub_tx_key: {:s} " - "using prv_view_key: {:s}", - tx_pub_key, prv_view_key); + bool r; - context["has_error"] = true; - context["error_msg"] = error_msg; + r = decode_ringct(output_source_tx.rct_signatures, + tx_pub_key, + prv_view_key, + output_idx_in_tx, + output_source_tx.rct_signatures.ecdhInfo[output_idx_in_tx].mask, + rct_amount); - return mstch::render(full_page, context); - } + if (!r) + { + string error_msg = fmt::format( + "Cant decode ringCT for " + "pub_tx_key: {:s} " + "using prv_view_key: {:s}", + tx_pub_key, prv_view_key); - xmr_amount = rct_amount; + context["has_error"] = true; + context["error_msg"] = error_msg; + + return mstch::render(full_page, context); + } + + xmr_amount = rct_amount; + + } // if (output_source_tx.version == 2 && !is_coinbase(output_source_tx)) break; From 7b3c840231bec43bb0c77f15b97229b94db0e282 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 19 Jan 2017 23:38:28 +0000 Subject: [PATCH 16/18] fix: show_my_outputs does not depend on custom lmdb now --- src/page.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/page.h b/src/page.h index b28dfdf..2f8238e 100644 --- a/src/page.h +++ b/src/page.h @@ -1335,13 +1335,6 @@ public: bool show_key_images {false}; - unique_ptr mylmdb; - - if (bf::is_directory(lmdb2_path)) - { - mylmdb = make_unique(lmdb2_path); - } - mstch::array inputs; vector input_key_imgs = xmreg::get_key_images(tx); @@ -1351,12 +1344,6 @@ public: for (const txin_to_key& in_key: input_key_imgs) { - if (!mylmdb) - { - show_key_images = false; - break; - } - // get absolute offsets of mixins std::vector absolute_offsets = cryptonote::relative_output_offsets_to_absolute( From d8c719dc07d682fdf9a1b0a4f1d35a41374b3700 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 20 Jan 2017 00:07:42 +0000 Subject: [PATCH 17/18] dont decode ringct amounts for ringct coinbase txs --- src/page.h | 72 ++++++++++++++++++----------------- src/templates/my_outputs.html | 2 +- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/page.h b/src/page.h index 2f8238e..8f1050d 100644 --- a/src/page.h +++ b/src/page.h @@ -1283,27 +1283,28 @@ public: // if mine output has RingCT, i.e., tx version is 2 if (mine_output && tx.version == 2) { - // initialize with regular amount - uint64_t rct_amount = money_transfered[output_idx]; - - bool r; - - r = decode_ringct(tx.rct_signatures, - pub_key, - prv_view_key, - output_idx, - tx.rct_signatures.ecdhInfo[output_idx].mask, - rct_amount); - - if (!r) - { - cerr << "\nshow_my_outputs: Cant decode ringCT! " << endl; - } - // cointbase txs have amounts in plain sight. // so use amount from ringct, only for non-coinbase txs if (!is_coinbase(tx)) { + + // initialize with regular amount + uint64_t rct_amount = money_transfered[output_idx]; + + bool r; + + r = decode_ringct(tx.rct_signatures, + pub_key, + prv_view_key, + output_idx, + tx.rct_signatures.ecdhInfo[output_idx].mask, + rct_amount); + + if (!r) + { + cerr << "\nshow_my_outputs: Cant decode ringCT! " << endl; + } + outp.second = rct_amount; money_transfered[output_idx] = rct_amount; } @@ -1514,29 +1515,30 @@ public: if (mine_output && mixin_tx.version == 2) { - // initialize with regular amount - uint64_t rct_amount = amount; - - bool r; - - r = decode_ringct(mixin_tx.rct_signatures, - mixin_tx_pub_key, - prv_view_key, - output_idx_in_tx, - mixin_tx.rct_signatures.ecdhInfo[output_idx_in_tx].mask, - rct_amount); - - if (!r) - { - cerr << "show_my_outputs: key images: Cant decode ringCT!" << endl; - } - // cointbase txs have amounts in plain sight. // so use amount from ringct, only for non-coinbase txs if (!is_coinbase(mixin_tx)) { + // initialize with regular amount + uint64_t rct_amount = amount; + + bool r; + + r = decode_ringct(mixin_tx.rct_signatures, + mixin_tx_pub_key, + prv_view_key, + output_idx_in_tx, + mixin_tx.rct_signatures.ecdhInfo[output_idx_in_tx].mask, + rct_amount); + + if (!r) + { + cerr << "show_my_outputs: key images: Cant decode ringCT!" << endl; + } + amount = rct_amount; - } + + } // if (mine_output && mixin_tx.version == 2) } diff --git a/src/templates/my_outputs.html b/src/templates/my_outputs.html index 48ec321..f5ec218 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -75,7 +75,7 @@ {{#show_inputs}} - +

Inputs ({{inputs_no}})

{{#inputs}} From 1bbc608080217006a45d268880f975617c1cc79d Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 20 Jan 2017 00:37:21 +0000 Subject: [PATCH 18/18] div of decoded inputs is hidden now --- src/templates/css/style.css | 27 +++++++++++++++++++++++++++ src/templates/my_outputs.html | 7 +++++++ 2 files changed, 34 insertions(+) diff --git a/src/templates/css/style.css b/src/templates/css/style.css index 48b2938..8f90f7a 100644 --- a/src/templates/css/style.css +++ b/src/templates/css/style.css @@ -111,4 +111,31 @@ form { [type=radio]:checked ~ label ~ .content { z-index: 1; +} + +input#toggle-1[type=checkbox] { + position: absolute; + top: -9999px; + left: -9999px; + +} +label#show-decoded-inputs { + /*-webkit-appearance: push-button;*/ + /*-moz-appearance: button;*/ + display: inline-block; + /*margin: 60px 0 10px 0;*/ + cursor: pointer; + background-color: black;; + color: white; + width: 100%; + text-align: center; +} + +div#decoded-inputs{ + display: none; +} + +/* Toggled State */ +input#toggle-1[type=checkbox]:checked ~ div#decoded-inputs { + display: block; } \ No newline at end of file diff --git a/src/templates/my_outputs.html b/src/templates/my_outputs.html index f5ec218..94ed464 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -76,6 +76,10 @@ {{#show_inputs}}
+ + + +

Inputs ({{inputs_no}})

{{#inputs}} @@ -139,7 +143,10 @@ So do not take this number seriously. It is probably totally wrong anyway. +
+ {{/show_inputs}}
+
\ No newline at end of file