sum value of inputs and outputs added to tx info

master
moneroexamples 8 years ago
parent fc167d86b0
commit 2679da08ce

@ -996,6 +996,8 @@ namespace xmreg {
uint64_t input_idx {0}; uint64_t input_idx {0};
uint64_t inputs_xmr_sum {0};
// make timescale maps for mixins in input // make timescale maps for mixins in input
for (const txin_to_key& in_key: txd.input_key_imgs) 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)} {"ring_sigs" , txd.get_ring_sig_for_input(input_idx)}
}); });
inputs_xmr_sum += in_key.amount;
// get reference to mixins array created above // get reference to mixins array created above
mstch::array& mixins = boost::get<mstch::array>( mstch::array& mixins = boost::get<mstch::array>(
@ -1102,6 +1106,7 @@ namespace xmreg {
input_idx++; input_idx++;
} // for (const txin_to_key& in_key: txd.input_key_imgs) } // 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["server_time"] = server_time_str;
context["inputs"] = inputs; context["inputs"] = inputs;
context["timescales"] = mixins_timescales; context["timescales"] = mixins_timescales;
@ -1136,6 +1141,8 @@ namespace xmreg {
mstch::array outputs; mstch::array outputs;
uint64_t outputs_xmr_sum {0};
for (pair<txout_to_key, uint64_t>& outp: txd.output_pub_keys) for (pair<txout_to_key, uint64_t>& outp: txd.output_pub_keys)
{ {
@ -1153,6 +1160,8 @@ namespace xmreg {
out_amount_indices.at(output_idx)); out_amount_indices.at(output_idx));
} }
outputs_xmr_sum += outp.second;
outputs.push_back(mstch::map { outputs.push_back(mstch::map {
{"out_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", outp.first.key))}, {"out_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", outp.first.key))},
{"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(outp.second))}, {"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; context["outputs"] = outputs;
// read tx.html // read tx.html

@ -44,7 +44,7 @@
</table> </table>
<h3>Outputs ({{outputs_no}})</h3> <h3>{{outputs_no}} output(s) for total of {{outputs_xmr_sum}} xmr</h3>
<div class="center"> <div class="center">
<table class="center"> <table class="center">
<tr> <tr>
@ -84,7 +84,7 @@
</div> </div>
<h3>Inputs ({{inputs_no}})</h3> <h3>{{inputs_no}} inputs(s) for total of {{inputs_xmr_sum}} xmr</h3>
<div class="center"> <div class="center">
<table class="center"> <table class="center">
{{#inputs}} {{#inputs}}

Loading…
Cancel
Save