From 290ee4a2609999ab6cc4b33f770391024f7a1f45 Mon Sep 17 00:00:00 2001 From: j-berman Date: Thu, 21 Apr 2022 01:54:38 -0700 Subject: [PATCH] Update for view tags --- src/MempoolStatus.cpp | 2 +- src/MicroCore.cpp | 7 ++-- src/page.h | 81 +++++++++++++++++++++---------------------- src/tools.cpp | 47 ++++++++++--------------- src/tools.h | 6 ++-- 5 files changed, 67 insertions(+), 76 deletions(-) diff --git a/src/MempoolStatus.cpp b/src/MempoolStatus.cpp index b55b312..4309def 100644 --- a/src/MempoolStatus.cpp +++ b/src/MempoolStatus.cpp @@ -170,7 +170,7 @@ MempoolStatus::read_mempool() vector input_key_imgs; // public keys and xmr amount of outputs - vector> output_pub_keys; + vector> output_pub_keys; // sum xmr in inputs and ouputs in the given tx const array& sum_data = summary_of_in_out_rct( diff --git a/src/MicroCore.cpp b/src/MicroCore.cpp index 2c38204..1825941 100644 --- a/src/MicroCore.cpp +++ b/src/MicroCore.cpp @@ -211,12 +211,13 @@ MicroCore::find_output_in_tx(const transaction& tx, auto it = std::find_if(tx.vout.begin(), tx.vout.end(), [&](const tx_out& o) { - const txout_to_key& tx_in_to_key - = boost::get(o.target); + public_key found_output_pubkey; + cryptonote::get_output_public_key( + o, found_output_pubkey); ++idx; - return tx_in_to_key.key == output_pubkey; + return found_output_pubkey == output_pubkey; }); if (it != tx.vout.end()) diff --git a/src/page.h b/src/page.h index d204f95..aa10312 100644 --- a/src/page.h +++ b/src/page.h @@ -336,7 +336,7 @@ struct tx_details vector input_key_imgs; // public keys and xmr amount of outputs - vector> output_pub_keys; + vector> output_pub_keys; mstch::map get_mstch_map() const @@ -2196,7 +2196,7 @@ show_my_outputs(string tx_hash_str, uint64_t output_idx {0}; - for (pair& outp: txd.output_pub_keys) + for (pair& outp: txd.output_pub_keys) { // get the tx output public key @@ -2211,12 +2211,12 @@ show_my_outputs(string tx_hash_str, // cout << pod_to_hex(derivation) << ", " << output_idx << ", " // << pod_to_hex(address_info.address.m_spend_public_key) << ", " -// << pod_to_hex(outp.first.key) << " == " +// << pod_to_hex(outp.first) << " == " // << pod_to_hex(tx_pubkey) << '\n' << '\n'; // check if generated public key matches the current output's key - bool mine_output = (outp.first.key == tx_pubkey); + bool mine_output = (outp.first == tx_pubkey); bool with_additional = false; @@ -2229,7 +2229,7 @@ show_my_outputs(string tx_hash_str, tx_pubkey); - mine_output = (outp.first.key == tx_pubkey); + mine_output = (outp.first == tx_pubkey); with_additional = true; } @@ -2272,7 +2272,7 @@ show_my_outputs(string tx_hash_str, } outputs.push_back(mstch::map { - {"out_pub_key" , pod_to_hex(outp.first.key)}, + {"out_pub_key" , pod_to_hex(outp.first)}, {"amount" , xmreg::xmr_amount_to_str(outp.second)}, {"mine_output" , mine_output}, {"output_idx" , fmt::format("{:02d}", output_idx)} @@ -2477,7 +2477,7 @@ show_my_outputs(string tx_hash_str, } // - vector> output_pub_keys; + vector> output_pub_keys; output_pub_keys = xmreg::get_ouputs_tuple(mixin_tx); @@ -2505,15 +2505,15 @@ show_my_outputs(string tx_hash_str, for (const auto& mix_out: output_pub_keys) { - txout_to_key const& txout_k = std::get<0>(mix_out); + public_key const& output_pub_key = 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(output_pub_key) << endl; // // analyze only those output keys // // that were used in mixins - // if (txout_k.key != output_data.pubkey) + // if (output_pub_key != output_data.pubkey) // { // continue; // } @@ -2529,7 +2529,7 @@ show_my_outputs(string tx_hash_str, tx_pubkey_generated); // check if generated public key matches the current output's key - bool mine_output = (txout_k.key == tx_pubkey_generated); + bool mine_output = (output_pub_key == tx_pubkey_generated); bool with_additional = false; @@ -2541,7 +2541,7 @@ show_my_outputs(string tx_hash_str, address_info.address.m_spend_public_key, tx_pubkey_generated); - mine_output = (txout_k.key == tx_pubkey_generated); + mine_output = (output_pub_key == tx_pubkey_generated); with_additional = true; } @@ -2576,7 +2576,7 @@ show_my_outputs(string tx_hash_str, } // makre only - bool output_match = (txout_k.key == output_data.pubkey); + bool output_match = (output_pub_key == output_data.pubkey); // mark only first output_match as the "real" one // due to luck of better method of gussing which output @@ -2585,7 +2585,7 @@ show_my_outputs(string tx_hash_str, // save our mixnin's public keys found_outputs.push_back(mstch::map { - {"my_public_key" , pod_to_hex(txout_k.key)}, + {"my_public_key" , pod_to_hex(output_pub_key)}, {"tx_hash" , tx_hash_str}, {"mine_output" , mine_output}, {"out_idx" , output_idx_in_tx}, @@ -2594,7 +2594,7 @@ show_my_outputs(string tx_hash_str, {"amount" , xmreg::xmr_amount_to_str(amount)} }); - //cout << "txout_k.key == output_data.pubkey" << endl; + //cout << "output_pub_key == output_data.pubkey" << endl; if (mine_output) { @@ -2604,7 +2604,7 @@ show_my_outputs(string tx_hash_str, // 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) + if (output_pub_key != output_data.pubkey) continue; // sum up only first output matched found in each input @@ -2653,7 +2653,7 @@ show_my_outputs(string tx_hash_str, } // if (mine_output) - } // for (const pair& mix_out: txd.output_pub_keys) + } // for (const pair& mix_out: txd.output_pub_keys) has_found_outputs = !found_outputs.empty(); @@ -2924,7 +2924,7 @@ show_checkrawtx(string raw_tx_data, string action) real_output_indices.push_back(tx_source.real_output); - public_key real_out_pub_key = real_txd.output_pub_keys[tx_source.real_output_in_tx_index].first.key; + public_key real_out_pub_key = real_txd.output_pub_keys[tx_source.real_output_in_tx_index].first; //cout << "real_txd.hash: " << pod_to_hex(real_txd.hash) << endl; //cout << "real_txd.pk: " << pod_to_hex(real_txd.pk) << endl; @@ -2973,7 +2973,7 @@ show_checkrawtx(string raw_tx_data, string action) tx_details txd = get_tx_details(tx); - public_key out_pub_key = txd.output_pub_keys[toi.second].first.key; + public_key out_pub_key = txd.output_pub_keys[toi.second].first; // get block cointaining this tx @@ -3301,7 +3301,7 @@ show_checkrawtx(string raw_tx_data, string action) 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_txd.output_pub_keys[tx_source.real_output_in_tx_index].first; real_output_pub_keys.push_back( REMOVE_HASH_BRAKETS(fmt::format("{:s}",real_out_pub_key)) @@ -3910,8 +3910,7 @@ show_checkcheckrawoutput(string raw_data, string viewkey_str) const transaction_prefix& txp = td.m_tx; - txout_to_key txout_key = boost::get( - txp.vout[td.m_internal_output_index].target); + public_key output_pub_key = td.get_public_key(); uint64_t xmr_amount = td.amount(); @@ -3957,7 +3956,7 @@ show_checkcheckrawoutput(string raw_data, string viewkey_str) { string error_msg = fmt::format( "Cant decode RingCT for output: {:s}", - txout_key.key); + output_pub_key); context["has_error"] = true; context["error_msg"] = error_msg; @@ -3989,7 +3988,7 @@ show_checkcheckrawoutput(string raw_data, string viewkey_str) mstch::map output_info { {"output_no" , fmt::format("{:03d}", output_no)}, - {"output_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", txout_key.key))}, + {"output_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", output_pub_key))}, {"amount" , xmreg::xmr_amount_to_str(xmr_amount)}, {"tx_hash" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", td.m_txid))}, {"timestamp" , xmreg::timestamp_to_str_gm(blk_timestamp)}, @@ -4239,11 +4238,11 @@ search_txs(vector txs, const string& search_text) // check if output_public_keys matche the search_text - vector>::iterator it2 = + vector>::iterator it2 = find_if(begin(txd.output_pub_keys), end(txd.output_pub_keys), - [&](const pair& tx_out_pk) + [&](const pair& tx_out_pk) { - return pod_to_hex(tx_out_pk.first.key) == search_text; + return pod_to_hex(tx_out_pk.first) == search_text; }); if (it2 != txd.output_pub_keys.end()) @@ -4473,7 +4472,7 @@ json_transaction(string tx_hash_str) for (const auto& output: txd.output_pub_keys) { outputs.push_back(json { - {"public_key", pod_to_hex(output.first.key)}, + {"public_key", pod_to_hex(output.first)}, {"amount" , output.second} }); } @@ -5390,7 +5389,7 @@ json_outputs(string tx_hash_str, j_data["outputs"] = json::array(); json& j_outptus = j_data["outputs"]; - for (pair& outp: txd.output_pub_keys) + for (pair& outp: txd.output_pub_keys) { // get the tx output public key @@ -5404,7 +5403,7 @@ json_outputs(string tx_hash_str, tx_pubkey); // check if generated public key matches the current output's key - bool mine_output = (outp.first.key == tx_pubkey); + bool mine_output = (outp.first == tx_pubkey); bool with_additional = false; if (!mine_output && txd.additional_pks.size() == txd.output_pub_keys.size()) { @@ -5412,7 +5411,7 @@ json_outputs(string tx_hash_str, output_idx, address_info.address.m_spend_public_key, tx_pubkey); - mine_output = (outp.first.key == tx_pubkey); + mine_output = (outp.first == tx_pubkey); with_additional = true; } @@ -5448,7 +5447,7 @@ json_outputs(string tx_hash_str, } // if (mine_output && tx.version == 2) j_outptus.push_back(json { - {"output_pubkey", pod_to_hex(outp.first.key)}, + {"output_pubkey", pod_to_hex(outp.first)}, {"amount" , outp.second}, {"match" , mine_output}, {"output_idx" , output_idx}, @@ -5456,7 +5455,7 @@ json_outputs(string tx_hash_str, ++output_idx; - } // for (pair& outp: txd.output_pub_keys) + } // for (pair& outp: txd.output_pub_keys) // if we don't already have the tx_timestamp from the mempool // then read it from the block that the transaction is in @@ -5861,7 +5860,7 @@ find_our_outputs( //j_data["outputs"] = json::array(); //json& j_outptus = j_data["outputs"]; - for (pair &outp: txd.output_pub_keys) + for (pair &outp: txd.output_pub_keys) { // get the tx output public key @@ -5875,7 +5874,7 @@ find_our_outputs( tx_pubkey); // check if generated public key matches the current output's key - bool mine_output = (outp.first.key == tx_pubkey); + bool mine_output = (outp.first == tx_pubkey); bool with_additional = false; if (!mine_output && txd.additional_pks.size() == txd.output_pub_keys.size()) { @@ -5883,7 +5882,7 @@ find_our_outputs( output_idx, address.m_spend_public_key, tx_pubkey); - mine_output = (outp.first.key == tx_pubkey); + mine_output = (outp.first == tx_pubkey); with_additional = true; } @@ -5927,7 +5926,7 @@ find_our_outputs( string payment_id_str = get_payment_id_as_string(txd, prv_view_key); j_outptus.push_back(json { - {"output_pubkey" , pod_to_hex(outp.first.key)}, + {"output_pubkey" , pod_to_hex(outp.first)}, {"amount" , outp.second}, {"block_no" , block_no}, {"in_mempool" , is_mempool}, @@ -5939,7 +5938,7 @@ find_our_outputs( ++output_idx; - } // for (pair& outp: txd.output_pub_keys) + } // for (pair& outp: txd.output_pub_keys) } // for (auto it = blk_txs.begin(); it != blk_txs.end(); ++it) @@ -6449,7 +6448,7 @@ construct_tx_context(transaction tx, uint16_t with_ring_signatures = 0) uint64_t outputs_xmr_sum {0}; - for (pair& outp: txd.output_pub_keys) + for (pair& outp: txd.output_pub_keys) { // total number of ouputs in the blockchain for this amount @@ -6469,7 +6468,7 @@ construct_tx_context(transaction tx, uint16_t with_ring_signatures = 0) outputs_xmr_sum += outp.second; outputs.push_back(mstch::map { - {"out_pub_key" , pod_to_hex(outp.first.key)}, + {"out_pub_key" , pod_to_hex(outp.first)}, {"amount" , xmreg::xmr_amount_to_str(outp.second)}, {"amount_idx" , out_amount_index_str}, {"num_outputs" , num_outputs_amount}, @@ -6477,7 +6476,7 @@ construct_tx_context(transaction tx, uint16_t with_ring_signatures = 0) {"output_idx" , fmt::format("{:02d}", output_idx++)} }); - } // for (pair& outp: txd.output_pub_keys) + } // for (pair& outp: txd.output_pub_keys) context["outputs_xmr_sum"] = xmreg::xmr_amount_to_str(outputs_xmr_sum); diff --git a/src/tools.cpp b/src/tools.cpp index 8037616..0e8b957 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -345,7 +345,7 @@ sum_money_in_outputs(const json& _json) array summary_of_in_out_rct( const transaction& tx, - vector>& output_pub_keys, + vector>& output_pub_keys, vector& input_key_imgs) { @@ -357,18 +357,15 @@ summary_of_in_out_rct( for (const tx_out& txout: tx.vout) { - if (txout.target.type() != typeid(txout_to_key)) + public_key output_pub_key; + if (!cryptonote::get_output_public_key(txout, output_pub_key)) { // push empty pair. - output_pub_keys.push_back(pair{}); + output_pub_keys.push_back(pair{}); continue; } - // get tx input key - const txout_to_key& txout_key - = boost::get(txout.target); - - output_pub_keys.push_back(make_pair(txout_key, txout.amount)); + output_pub_keys.push_back(make_pair(output_pub_key, txout.amount)); xmr_outputs += txout.amount; } @@ -619,49 +616,43 @@ sum_fees_in_txs(const vector& txs) -vector> +vector> get_ouputs(const transaction& tx) { - vector> outputs; + vector> outputs; for (const tx_out& txout: tx.vout) { - if (txout.target.type() != typeid(txout_to_key)) + public_key output_pub_key; + if (!cryptonote::get_output_public_key(txout, output_pub_key)) { // push empty pair. - outputs.push_back(pair{}); + outputs.push_back(pair{}); continue; } - // get tx input key - const txout_to_key& txout_key - = boost::get(txout.target); - - outputs.push_back(make_pair(txout_key, txout.amount)); + outputs.push_back(make_pair(output_pub_key, txout.amount)); } return outputs; }; -vector> +vector> get_ouputs_tuple(const transaction& tx) { - vector> outputs; + vector> outputs; for (uint64_t n = 0; n < tx.vout.size(); ++n) { - if (tx.vout[n].target.type() != typeid(txout_to_key)) + public_key output_pub_key; + if (!cryptonote::get_output_public_key(tx.vout[n], output_pub_key)) { continue; } - // get tx input key - const txout_to_key& txout_key - = boost::get(tx.vout[n].target); - - outputs.push_back(make_tuple(txout_key, tx.vout[n].amount, n)); + outputs.push_back(make_tuple(output_pub_key, tx.vout[n].amount, n)); } return outputs; @@ -1166,11 +1157,11 @@ is_output_ours(const size_t& output_index, //cout << "\n" << tx.vout.size() << " " << output_index << endl; // get tx output public key - const txout_to_key tx_out_to_key - = boost::get(tx.vout[output_index].target); + public_key output_pub_key; + cryptonote::get_output_public_key(tx.vout[output_index], output_pub_key); - if (tx_out_to_key.key == pubkey) + if (output_pub_key == pubkey) { return true; } diff --git a/src/tools.h b/src/tools.h index d511e1b..f8be143 100644 --- a/src/tools.h +++ b/src/tools.h @@ -154,7 +154,7 @@ sum_money_in_outputs(const json& _json); array summary_of_in_out_rct( const transaction& tx, - vector>& output_pub_keys, + vector>& output_pub_keys, vector& input_key_imgs); // this version for mempool txs from json @@ -200,10 +200,10 @@ get_mixin_no(const json& _json); vector get_mixin_no_in_txs(const vector& txs); -vector> +vector> get_ouputs(const transaction& tx); -vector> +vector> get_ouputs_tuple(const transaction& tx); vector