From 3c0b4f53bb9fd5eb8f0d351e8654f0042deed254 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 26 Mar 2021 19:44:18 +0800 Subject: [PATCH 1/2] 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}, }); } From d31999849a76fe256aed2df94dba723aa0ca775c Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Sat, 27 Mar 2021 19:41:31 +0800 Subject: [PATCH 2/2] readme and cmake updates --- CMakeLists.txt | 2 +- README.md | 11 +++++++---- ext/CMakeLists.txt | 1 + src/CMakeLists.txt | 2 +- src/crypto/CMakeLists.txt | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34ff718..70d3c7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.0.2) set(PROJECT_NAME xmrblocks) diff --git a/README.md b/README.md index 61bac28..338e81d 100644 --- a/README.md +++ b/README.md @@ -296,8 +296,8 @@ Partial results shown: "data": { "block_height": 1268252, "coinbase": false, - "confirmations": 1, - "current_height": 1268253, + "confirmations": 1057855, + "current_height": 2326107, "extra": "01be23e277aed6b5f41f66b05244bf994c13108347366ec678ae16657f0fc3a22b", "inputs": [ { @@ -306,11 +306,13 @@ Partial results shown: "mixins": [ { "block_no": 1238623, - "public_key": "0a5b853c55303c10e1326acfb085b9e246e088b1ccac7e37f7a810d46a28a914" + "public_key": "0a5b853c55303c10e1326acfb085b9e246e088b1ccac7e37f7a810d46a28a914", + "tx_hash": "686555fb053dd53f6f9eb79449e2bdcd377221f823f508158d70d4a1966fe955" }, { "block_no": 1246942, - "public_key": "527cf86f5abbfb006c970f7c6eb40493786d4751306f8985c6a43f98a88c0dff" + "public_key": "527cf86f5abbfb006c970f7c6eb40493786d4751306f8985c6a43f98a88c0dff", + "tx_hash": "4fa1999f9e0d2ad031dbe5594f2e8336651b6cad19dd3cee7980a01c47600f91" } ] } @@ -340,6 +342,7 @@ Partial results shown: }, "status": "success" } + ``` #### api/transactions diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index 282bc15..e598331 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -1,4 +1,5 @@ # first build mstch template library +cmake_minimum_required(VERSION 3.0.2) add_subdirectory("mstch") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c952e91..2b30c58 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.0.2) project(myxrm) diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt index fe7f03c..8cbac5a 100644 --- a/src/crypto/CMakeLists.txt +++ b/src/crypto/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.0.2) project(mycrypto)