From 2679da08ce4de7479307bfbb8d7a8b4274207511 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Sat, 20 Aug 2016 18:25:18 +0800 Subject: [PATCH] sum value of inputs and outputs added to tx info --- src/page.h | 11 +++++++++++ src/templates/tx.html | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/page.h b/src/page.h index 3e602e8..04f39d3 100644 --- a/src/page.h +++ b/src/page.h @@ -996,6 +996,8 @@ namespace xmreg { uint64_t input_idx {0}; + uint64_t inputs_xmr_sum {0}; + // make timescale maps for mixins in input for (const txin_to_key& in_key: txd.input_key_imgs) { @@ -1020,6 +1022,8 @@ namespace xmreg { {"ring_sigs" , txd.get_ring_sig_for_input(input_idx)} }); + inputs_xmr_sum += in_key.amount; + // get reference to mixins array created above mstch::array& mixins = boost::get( @@ -1102,6 +1106,7 @@ namespace xmreg { input_idx++; } // for (const txin_to_key& in_key: txd.input_key_imgs) + context["inputs_xmr_sum"] = fmt::format("{:0.12f}", XMR_AMOUNT(inputs_xmr_sum)); context["server_time"] = server_time_str; context["inputs"] = inputs; context["timescales"] = mixins_timescales; @@ -1136,6 +1141,8 @@ namespace xmreg { mstch::array outputs; + uint64_t outputs_xmr_sum {0}; + for (pair& outp: txd.output_pub_keys) { @@ -1153,6 +1160,8 @@ namespace xmreg { out_amount_indices.at(output_idx)); } + outputs_xmr_sum += outp.second; + outputs.push_back(mstch::map { {"out_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", outp.first.key))}, {"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(outp.second))}, @@ -1162,6 +1171,8 @@ namespace xmreg { }); } + context["outputs_xmr_sum"] = fmt::format("{:0.12f}", XMR_AMOUNT(outputs_xmr_sum)); + context["outputs"] = outputs; // read tx.html diff --git a/src/templates/tx.html b/src/templates/tx.html index edc9912..b7a0c73 100644 --- a/src/templates/tx.html +++ b/src/templates/tx.html @@ -44,7 +44,7 @@ -

Outputs ({{outputs_no}})

+

{{outputs_no}} output(s) for total of {{outputs_xmr_sum}} xmr

@@ -84,7 +84,7 @@ -

Inputs ({{inputs_no}})

+

{{inputs_no}} inputs(s) for total of {{inputs_xmr_sum}} xmr

{{#inputs}}