searching for mixins with outputs started

add_selenium_testing
moneroexamples 8 years ago
parent 52a3de72ab
commit 0744587cf0

@ -1322,8 +1322,10 @@ public:
// we can also test ouputs used in mixins for key images // we can also test ouputs used in mixins for key images
// this can show possible spending. Only possible, because // this can show possible spending. Only possible, because
// without a spend key, we cant know for sure. It might be // without a spend key, we cant know for sure. It might be
// that our output was used by someelse for their mixin. // that our output was used by someone else for their mixins.
// for this we can look in our custom db, for efficiencly // For this we can look in our custom db, for efficiencly
bool show_key_images {false};
unique_ptr<xmreg::MyLMDB> mylmdb; unique_ptr<xmreg::MyLMDB> mylmdb;
@ -1341,6 +1343,7 @@ public:
if (!mylmdb) if (!mylmdb)
{ {
show_key_images = false;
break; break;
} }
@ -1378,13 +1381,13 @@ public:
// to store our mixins found for the given key image // to store our mixins found for the given key image
vector<map<string, string>> our_mixins_found; vector<map<string, string>> 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) for (const cryptonote::output_data_t& output_data: mixin_outputs)
{ {
string out_pub_key_str = pod_to_hex(output_data.pubkey); 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 // this will be txs where the outputs come from
vector<string> found_tx_hashes; vector<string> found_tx_hashes;
@ -1396,19 +1399,26 @@ public:
mixins.push_back(mstch::map{ mixins.push_back(mstch::map{
{"mixin_pub_key", out_pub_key_str}, {"mixin_pub_key" , out_pub_key_str},
make_pair(string("mixin_outputs"), mstch::array{}) {"mixin_outputs" , mstch::array{}},
{"has_mixin_outputs", false}
}); });
mstch::array& mixin_outputs = boost::get<mstch::array>( mstch::array& mixin_outputs = boost::get<mstch::array>(
boost::get<mstch::map>(mixins.back())["mixin_outputs"] boost::get<mstch::map>(mixins.back())["mixin_outputs"]
); );
// for each output transaction, check if its ours mstch::node& has_mixin_outputs
= boost::get<mstch::map>(mixins.back())["has_mixin_outputs"];
bool found_something {false};
// for each mixin output transaction, check if its ours
// as before // as before
for (string tx_hash_str: found_tx_hashes) for (string tx_hash_str: found_tx_hashes)
{ {
crypto::hash tx_hash; crypto::hash tx_hash;
hex_to_pod(tx_hash_str, 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); = 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. // to create, so called, derived key.
key_derivation derivation; 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" 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; << "prv_view_key" << prv_view_key << endl;
continue; continue;
@ -1444,14 +1454,17 @@ public:
output_pub_keys = xmreg::get_ouputs_tuple(mixin_tx); output_pub_keys = xmreg::get_ouputs_tuple(mixin_tx);
mixin_outputs.push_back(mstch::map{ mixin_outputs.push_back(mstch::map{
{"mix_tx_hash" , tx_hash_str}, {"mix_tx_hash" , tx_hash_str},
make_pair(string("found_outputs"), mstch::array{}) {"found_outputs" , mstch::array{}},
{"has_found_outputs", false}
}); });
mstch::array& found_outputs = boost::get<mstch::array>( mstch::array& found_outputs = boost::get<mstch::array>(
boost::get<mstch::map>(mixin_outputs.back())["found_outputs"] boost::get<mstch::map>(mixin_outputs.back())["found_outputs"]
); );
mstch::node& has_found_outputs
= boost::get<mstch::map>(mixin_outputs.back())["has_found_outputs"];
// for each output in mixin tx, find the one from key_image // for each output in mixin tx, find the one from key_image
// and check if its ours. // and check if its ours.
@ -1462,10 +1475,14 @@ public:
uint64_t amount = std::get<1>(mix_out); uint64_t amount = std::get<1>(mix_out);
uint64_t output_idx_in_tx = std::get<2>(mix_out); uint64_t output_idx_in_tx = std::get<2>(mix_out);
//@todo fix this for loop cout << " - " << pod_to_hex(txout_k.key) << endl;
continue;
// //@todo fix this for loop
// continue;
// if (mix_out.first.key != output_data.pubkey) // // analyze only those output keys
// // that were used in mixins
// if (txout_k.key != output_data.pubkey)
// { // {
// continue; // continue;
// } // }
@ -1492,10 +1509,10 @@ public:
bool r; bool r;
r = decode_ringct(mixin_tx.rct_signatures, r = decode_ringct(mixin_tx.rct_signatures,
txout_k.key, mixin_tx_pub_key,
prv_view_key, prv_view_key,
output_idx_in_tx, output_idx_in_tx,
mixin_tx.rct_signatures.ecdhInfo[output_idx].mask, mixin_tx.rct_signatures.ecdhInfo[output_idx_in_tx].mask,
rct_amount); rct_amount);
if (!r) if (!r)
@ -1524,20 +1541,27 @@ public:
if (mine_output) if (mine_output)
{ {
// cout << " - " << pod_to_hex(txout_k.key) // cout << " - " << pod_to_hex(txout_k.key)
// <<": " << mine_output << " amount: " // <<": " << mine_output << " amount: "
// << xmreg::xmr_amount_to_str(amount) // << xmreg::xmr_amount_to_str(amount)
// << endl; // << endl;
found_something = true;
} }
} // for (const pair<txout_to_key, uint64_t>& mix_out: txd.output_pub_keys) } // for (const pair<txout_to_key, uint64_t>& mix_out: txd.output_pub_keys)
has_found_outputs = !found_outputs.empty();
} // for (string tx_hash_str: found_tx_hashes) } // for (string tx_hash_str: found_tx_hashes)
has_mixin_outputs = found_something;
} // for (const cryptonote::output_data_t& output_data: mixin_outputs) } // for (const cryptonote::output_data_t& output_data: mixin_outputs)
show_key_images = true;
} // for (const txin_to_key& in_key: input_key_imgs) } // 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["sum_xmr"] = xmreg::xmr_amount_to_str(sum_xmr);
context.emplace("inputs", inputs); context.emplace("inputs", inputs);
context["show_inputs"] = false; context["show_inputs"] = show_key_images;
// read my_outputs.html // read my_outputs.html
string my_outputs_html = xmreg::read(TMPL_MY_OUTPUTS); string my_outputs_html = xmreg::read(TMPL_MY_OUTPUTS);

@ -75,29 +75,32 @@
{{#inputs}} {{#inputs}}
<h4>Key image: {{key_image}}, amount {{key_image_amount}}</h4> <h4>Key image: {{key_image}}, amount {{key_image_amount}}</h4>
{{#mixins}} {{#mixins}}
<h5>Mixin of pub key: {{mixin_pub_key}}</h5> {{#has_mixin_outputs}}
{{#mixin_outputs}} <h5>Mixin of pub key: {{mixin_pub_key}}</h5>
<h5> {{#mixin_outputs}}
uses outputs from tx: <h5>
<a href="/tx/{{mix_tx_hash}}">{{mix_tx_hash}}</a> uses outputs from tx:
</h5> <a href="/tx/{{mix_tx_hash}}">{{mix_tx_hash}}</a>
{{#found_outputs}} </h5>
{{#has_found_outputs}}
<h6 style="font-family: 'Lucida Console', Monaco, monospace; font-size: 12px; font-weight: normal;"> {{#found_outputs}}
Output public key: {{my_public_key}},
amount: {{amount}}, <h6 style="font-family: 'Lucida Console', Monaco, monospace; font-size: 12px; font-weight: normal;">
is ours: Output public key: {{my_public_key}},
{{#mine_output}} amount: {{amount}},
<span style="color: #008009;font-weight: bold">{{mine_output}}</span> is ours:
{{/mine_output}} {{#mine_output}}
{{^mine_output}} <span style="color: #008009;font-weight: bold">{{mine_output}}</span>
{{mine_output}} {{/mine_output}}
{{/mine_output}} {{^mine_output}}
</h6> {{mine_output}}
{{/mine_output}}
{{/found_outputs}} </h6>
{{/mixin_outputs}}
{{/found_outputs}}
{{/has_found_outputs}}
{{/mixin_outputs}}
{{/has_mixin_outputs}}
{{/mixins}} {{/mixins}}
{{/inputs}} {{/inputs}}

Loading…
Cancel
Save