From 24dc2502fde3f7538f3839c483309c097e5c4903 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 7 Oct 2016 13:36:34 +0800 Subject: [PATCH] show which key images were spend for ran signed tx --- src/page.h | 30 ++++++++++++++++++++------ src/templates/partials/tx_details.html | 14 +++++++++++- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/page.h b/src/page.h index ab08551..ed836e5 100644 --- a/src/page.h +++ b/src/page.h @@ -1520,6 +1520,8 @@ namespace xmreg { for (mstch::node& input_node: inputs) { + mstch::map& input_map = boost::get(input_node); + // show input amount string& amount = boost::get( boost::get(input_node)["amount"] @@ -1527,6 +1529,22 @@ namespace xmreg { amount = fmt::format("{:0.12f}", XMR_AMOUNT(real_amounts.at(input_idx))); + // check if key images are spend or not + + string& in_key_img_str = boost::get( + boost::get(input_node)["in_key_img"] + ); + + key_image key_imgage; + + if (epee::string_tools::hex_to_pod(in_key_img_str, key_imgage)) + { + + input_map["already_spent"] = core_storage->get_db().has_key_image(key_imgage); + } + + // mark real mixings + mstch::array& mixins = boost::get( boost::get(input_node)["mixins"] ); @@ -1573,7 +1591,6 @@ namespace xmreg { ++idx; } - boost::get(context["txs"]).push_back(tx_context); } @@ -2320,11 +2337,12 @@ namespace xmreg { outputs); inputs.push_back(mstch::map { - {"in_key_img", REMOVE_HASH_BRAKETS(fmt::format("{:s}", in_key.k_image))}, - {"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(in_key.amount))}, - {"input_idx" , fmt::format("{:02d}", input_idx)}, - {"mixins" , mstch::array{}}, - {"ring_sigs" , txd.get_ring_sig_for_input(input_idx)} + {"in_key_img" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", in_key.k_image))}, + {"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(in_key.amount))}, + {"input_idx" , fmt::format("{:02d}", input_idx)}, + {"mixins" , mstch::array{}}, + {"ring_sigs" , txd.get_ring_sig_for_input(input_idx)}, + {"already_spent", false} // placeholder for later }); inputs_xmr_sum += in_key.amount; diff --git a/src/templates/partials/tx_details.html b/src/templates/partials/tx_details.html index b056b42..2736d72 100644 --- a/src/templates/partials/tx_details.html +++ b/src/templates/partials/tx_details.html @@ -125,7 +125,19 @@ {{#inputs}} - +
key image {{input_idx}}: {{in_key_img}} + key image {{input_idx}}: {{in_key_img}} + {{#have_raw_tx}} + Already spent: + {{#already_spent}} + True + {{/already_spent}} + {{^already_spent}} + False + {{/already_spent}} + + {{/#have_raw_tx}} + amount: {{amount}}