From 3c0b4f53bb9fd5eb8f0d351e8654f0042deed254 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 26 Mar 2021 19:44:18 +0800 Subject: [PATCH] Add tx_hash to mixins in api/transaction api https://github.com/moneroexamples/onion-monero-blockchain-explorer/issues/213 --- src/page.h | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/page.h b/src/page.h index 77a047c..dbd513f 100644 --- a/src/page.h +++ b/src/page.h @@ -76,7 +76,7 @@ extern __thread randomx_vm *rx_vm; #define TMPL_MY_CHECKRAWOUTPUTKEYS TMPL_DIR "/checkrawoutputkeys.html" #define ONIONEXPLORER_RPC_VERSION_MAJOR 1 -#define ONIONEXPLORER_RPC_VERSION_MINOR 1 +#define ONIONEXPLORER_RPC_VERSION_MINOR 2 #define MAKE_ONIONEXPLORER_RPC_VERSION(major,minor) (((major)<<16)|(minor)) #define ONIONEXPLORER_RPC_VERSION \ MAKE_ONIONEXPLORER_RPC_VERSION(ONIONEXPLORER_RPC_VERSION_MAJOR, ONIONEXPLORER_RPC_VERSION_MINOR) @@ -4501,10 +4501,41 @@ json_transaction(string tx_hash_str) json& mixins = inputs.back()["mixins"]; - for (const output_data_t& output_data: outputs) + // mixin counter + size_t count = 0; + + for (const uint64_t& abs_offset: absolute_offsets) { + + // get basic information about mixn's output + cryptonote::output_data_t output_data = 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 << '\n'; + + break; + } + + string out_pub_key_str = pod_to_hex(output_data.pubkey); + mixins.push_back(json { {"public_key" , pod_to_hex(output_data.pubkey)}, + {"tx_hash" , pod_to_hex(tx_out_idx.first)}, {"block_no" , output_data.height}, }); }