From ed24a53534e55ac239751e2f8b2edfd324e4d894 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Mon, 9 May 2016 04:07:10 +0000 Subject: [PATCH] show_my_outputs templated added --- src/page.h | 20 ++++++++++++++++---- src/templates/my_outputs.html | 5 +++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/page.h b/src/page.h index 08e5653..3d2e188 100644 --- a/src/page.h +++ b/src/page.h @@ -1213,6 +1213,8 @@ namespace xmreg { // initalise page tempate map with basic info about blockchain mstch::map context { {"tx_hash" , tx_hash_str}, + {"xmr_address" , xmr_address_str}, + {"viewkey" , viewkey_str}, {"tx_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", txd.pk))}, {"blk_height" , tx_blk_height_str}, {"tx_size" , fmt::format("{:0.4f}", @@ -1247,6 +1249,8 @@ namespace xmreg { mstch::array outputs; + uint64_t sum_xmr {0}; + for (pair& outp: txd.output_pub_keys) { @@ -1264,6 +1268,11 @@ namespace xmreg { // check if generated public key matches the current output's key bool mine_output = (outp.first.key == pubkey); + if (mine_output) + { + sum_xmr += 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))}, @@ -1273,13 +1282,16 @@ namespace xmreg { } - context["outputs"] = outputs; + cout << "outputs.size(): " << outputs.size() << endl; - // read tx.html - string tx_html = xmreg::read(TMPL_MY_OUTPUTS); + context["outputs"] = outputs; + context["sum_xmr"] = XMR_AMOUNT(sum_xmr); + + // read my_outputs.html + string my_outputs_html = xmreg::read(TMPL_MY_OUTPUTS); // add header and footer - string full_page = get_full_page(tx_html); + string full_page = get_full_page(my_outputs_html); // render the page return mstch::render(full_page, context); diff --git a/src/templates/my_outputs.html b/src/templates/my_outputs.html index 60492fb..7012292 100644 --- a/src/templates/my_outputs.html +++ b/src/templates/my_outputs.html @@ -25,6 +25,9 @@ +

Checking which outputs belong to the given address and viewkey

+
address: {{xmr_address}}
+
viewkey: {{viewkey}}

Outputs ({{outputs_no}})

@@ -42,6 +45,8 @@ {{/outputs}} + +

Our XMR: {{sum_xmr}}