Merge pull request #229 from moneroexamples/api_tx

Api tx
master
moneroexamples 4 years ago committed by GitHub
commit 175f563194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 3.0.2)
set(PROJECT_NAME set(PROJECT_NAME
xmrblocks) xmrblocks)

@ -296,8 +296,8 @@ Partial results shown:
"data": { "data": {
"block_height": 1268252, "block_height": 1268252,
"coinbase": false, "coinbase": false,
"confirmations": 1, "confirmations": 1057855,
"current_height": 1268253, "current_height": 2326107,
"extra": "01be23e277aed6b5f41f66b05244bf994c13108347366ec678ae16657f0fc3a22b", "extra": "01be23e277aed6b5f41f66b05244bf994c13108347366ec678ae16657f0fc3a22b",
"inputs": [ "inputs": [
{ {
@ -306,11 +306,13 @@ Partial results shown:
"mixins": [ "mixins": [
{ {
"block_no": 1238623, "block_no": 1238623,
"public_key": "0a5b853c55303c10e1326acfb085b9e246e088b1ccac7e37f7a810d46a28a914" "public_key": "0a5b853c55303c10e1326acfb085b9e246e088b1ccac7e37f7a810d46a28a914",
"tx_hash": "686555fb053dd53f6f9eb79449e2bdcd377221f823f508158d70d4a1966fe955"
}, },
{ {
"block_no": 1246942, "block_no": 1246942,
"public_key": "527cf86f5abbfb006c970f7c6eb40493786d4751306f8985c6a43f98a88c0dff" "public_key": "527cf86f5abbfb006c970f7c6eb40493786d4751306f8985c6a43f98a88c0dff",
"tx_hash": "4fa1999f9e0d2ad031dbe5594f2e8336651b6cad19dd3cee7980a01c47600f91"
} }
] ]
} }
@ -340,6 +342,7 @@ Partial results shown:
}, },
"status": "success" "status": "success"
} }
``` ```
#### api/transactions #### api/transactions

@ -1,4 +1,5 @@
# first build mstch template library # first build mstch template library
cmake_minimum_required(VERSION 3.0.2)
add_subdirectory("mstch") add_subdirectory("mstch")

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 3.0.2)
project(myxrm) project(myxrm)

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 3.0.2)
project(mycrypto) project(mycrypto)

@ -76,7 +76,7 @@ extern __thread randomx_vm *rx_vm;
#define TMPL_MY_CHECKRAWOUTPUTKEYS TMPL_DIR "/checkrawoutputkeys.html" #define TMPL_MY_CHECKRAWOUTPUTKEYS TMPL_DIR "/checkrawoutputkeys.html"
#define ONIONEXPLORER_RPC_VERSION_MAJOR 1 #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 MAKE_ONIONEXPLORER_RPC_VERSION(major,minor) (((major)<<16)|(minor))
#define ONIONEXPLORER_RPC_VERSION \ #define ONIONEXPLORER_RPC_VERSION \
MAKE_ONIONEXPLORER_RPC_VERSION(ONIONEXPLORER_RPC_VERSION_MAJOR, ONIONEXPLORER_RPC_VERSION_MINOR) 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"]; 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<crypto::hash, uint64_t> 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 { mixins.push_back(json {
{"public_key" , pod_to_hex(output_data.pubkey)}, {"public_key" , pod_to_hex(output_data.pubkey)},
{"tx_hash" , pod_to_hex(tx_out_idx.first)},
{"block_no" , output_data.height}, {"block_no" , output_data.height},
}); });
} }

Loading…
Cancel
Save