From a4c3def3916d076ba039d757a268014bbe60b87f Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Tue, 6 Dec 2016 07:48:36 +0800 Subject: [PATCH] fix: checking if key_image is spend only when td.m_key_image_known is True --- src/page.h | 17 +++++++++++++++-- src/templates/checkrawkeyimgs.html | 2 +- src/templates/checkrawoutputkeys.html | 22 +++++++++++++--------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/page.h b/src/page.h index 5a345a0..e70e5eb 100644 --- a/src/page.h +++ b/src/page.h @@ -2521,6 +2521,8 @@ public: uint64_t total_xmr {0}; uint64_t output_no {0}; + context["are_key_images_known"] = false; + for (const tools::wallet2::transfer_details& td: outputs) { @@ -2573,9 +2575,20 @@ public: uint64_t blk_timestamp = core_storage ->get_db().get_block_timestamp(td.m_block_height); - const key_image& output_key_img = td.m_key_image; + const key_image* output_key_img; + + bool is_output_spent {false}; + + if (td.m_key_image_known) + { + //are_key_images_known - bool is_output_spent = core_storage->have_tx_keyimg_as_spent(output_key_img); + output_key_img = &td.m_key_image; + + is_output_spent = core_storage->have_tx_keyimg_as_spent(*output_key_img); + + context["are_key_images_known"] = true; + } mstch::map output_info { {"output_no" , fmt::format("{:03d}", output_no)}, diff --git a/src/templates/checkrawkeyimgs.html b/src/templates/checkrawkeyimgs.html index 4588859..0d9927c 100644 --- a/src/templates/checkrawkeyimgs.html +++ b/src/templates/checkrawkeyimgs.html @@ -30,7 +30,7 @@

Key images for address: {{address}}

Viewkey: {{viewkey}}

{{#has_total_xmr}} -

Total value of xmr spend: {{total_xmr}}

+

Total xmr: {{total_xmr}}

{{/has_total_xmr}}
diff --git a/src/templates/checkrawoutputkeys.html b/src/templates/checkrawoutputkeys.html index 3db3843..5544df2 100644 --- a/src/templates/checkrawoutputkeys.html +++ b/src/templates/checkrawoutputkeys.html @@ -30,7 +30,7 @@

Output keys for address: {{address}}

Viewkey: {{viewkey}}

{{#has_total_xmr}} -

Total xmr balance: {{total_xmr}}

+

Total xmr: {{total_xmr}}

{{/has_total_xmr}}
@@ -42,7 +42,9 @@ Public key Timestamp RingCT - Is spent? + {{#are_key_images_known}} + Is spent? + {{/are_key_images_known}} Amount {{#output_keys}} @@ -52,13 +54,15 @@ {{output_pub_key}} {{timestamp}} {{is_ringct}} - {{^is_spent}} - {{is_spent}} - {{/is_spent}} - {{#is_spent}} - {{is_spent}} - {{/is_spent}} - + {{#are_key_images_known}} + {{^is_spent}} + {{is_spent}} + {{/is_spent}} + {{#is_spent}} + {{is_spent}} + {{/is_spent}} + + {{/are_key_images_known}} {{amount}}