From 3a7174541e3f2e544e3186c14c0a12d322772038 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 22 Apr 2016 01:54:16 +0000 Subject: [PATCH] indices added to tx info --- src/page.h | 24 ++++++++++++++++++------ src/templates/tx.html | 30 ++++++++++++++---------------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/page.h b/src/page.h index d39bfe7..ed33239 100644 --- a/src/page.h +++ b/src/page.h @@ -573,7 +573,9 @@ namespace xmreg { // initalise page tempate map with basic info about blockchain mstch::map context { {"tx_hash" , tx_hash_str}, - {"blk_height" , _blk_height} + {"blk_height" , _blk_height}, + {"inputs_no" , txd.input_key_imgs.size()}, + {"outputs_no" , txd.output_pub_keys.size()} }; string server_time_str = xmreg::timestamp_to_str(server_timestamp, "%F"); @@ -584,6 +586,9 @@ namespace xmreg { mstch::array mixins_timescales; double timescale_scale {0.0}; // size of one '_' in days + + uint64_t input_idx {0}; + // make timescale maps for mixins in input for (const txin_to_key& in_key: txd.input_key_imgs) { @@ -600,19 +605,21 @@ namespace xmreg { vector mixin_timestamps; - size_t count = 0; inputs.push_back(mstch::map { {"in_key_img", REMOVE_HASH_BRAKETS(fmt::format("{:s}", in_key.k_image))}, - {"amount" , fmt::format("{:0.3f}", XMR_AMOUNT(in_key.amount))}, - {"mixins" , mstch::array{}} + {"amount" , fmt::format("{:0.8f}", XMR_AMOUNT(in_key.amount))}, + {"input_idx" , fmt::format("{:02d}", input_idx++)}, + {"mixins" , mstch::array{}}, }); // get reference to mixins array created above mstch::array& mixins = boost::get( boost::get(inputs.back())["mixins"]); + size_t count = 0; + // for each found output public key find its block to get timestamp for (const uint64_t &i: absolute_offsets) { @@ -642,7 +649,8 @@ namespace xmreg { {"mix_out_indx" , fmt::format("{:d}", tx_out_idx.second)}, {"mix_timestamp" , xmreg::timestamp_to_str(blk.timestamp)}, {"mix_age" , mixin_age.first}, - {"mix_age_format" , mixin_age.second} + {"mix_age_format" , mixin_age.second}, + {"mix_idx" , fmt::format("{:02d}", count)}, }); // get mixin timestamp from its orginal block @@ -670,13 +678,17 @@ namespace xmreg { context["timescales_scale"] = fmt::format("{:0.2f}", timescale_scale / 3600.0 / 24.0); // in days + + uint64_t output_idx {0}; + mstch::array outputs; for (pair& outp: txd.output_pub_keys) { outputs.push_back(mstch::map { {"out_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", outp.first.key))}, - {"amount" , fmt::format("{:0.4f}", XMR_AMOUNT(outp.second))} + {"amount" , fmt::format("{:0.8f}", XMR_AMOUNT(outp.second))}, + {"output_idx" , fmt::format("{:02d}", output_idx++)} }); } diff --git a/src/templates/tx.html b/src/templates/tx.html index 13f06d3..1db41ee 100644 --- a/src/templates/tx.html +++ b/src/templates/tx.html @@ -33,7 +33,7 @@ -

Outputs

+

Outputs ({{outputs_no}})

@@ -42,7 +42,7 @@ {{#outputs}} - + {{/outputs}} @@ -61,31 +61,29 @@ -

Inputs {{inputs_no}}

+

Inputs ({{inputs_no}})

{{out_pub_key}}{{output_idx}}: {{out_pub_key}} {{amount}}
- - - - - {{#inputs}} - - + +
key imageamount
{{in_key_img}}{{amount}}key image {{input_idx}}: {{in_key_img}}amount: {{amount}}
- +
- - - - + + + + {{#mixins}} - + + + +
pub_keyblktimestampageMixin public keyblktimestampage
{{mix_pub_key}} {{mix_blk}} {{mix_timestamp}}{{mix_age}} - {{mix_idx}}: {{mix_pub_key}}{{mix_blk}}{{mix_timestamp}}{{mix_age}}