From 1d883a398ef637204f739cc45039c0b7ae414cb7 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 1 Dec 2016 10:28:54 +0800 Subject: [PATCH] added: output keys checker shows RingCToutputs amounts --- src/page.h | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/page.h b/src/page.h index ddbc57d..da6073b 100644 --- a/src/page.h +++ b/src/page.h @@ -2513,7 +2513,6 @@ public: } catch (const std::exception &e) { - string error_msg = fmt::format("Failed to import outputs: {:s}", e.what()); context["has_error"] = true; @@ -2535,6 +2534,45 @@ public: uint64_t xmr_amount = td.amount(); + // if the output is RingCT, i.e., tx version is 2 + // need to decode its amount + if (td.m_tx.version == 2) + { + // get tx associated with the given output + transaction tx; + + if (!mcore->get_tx(td.m_txid, tx)) + { + string error_msg = fmt::format("Cant get tx of hash: {:s}", td.m_txid); + + context["has_error"] = true; + context["error_msg"] = error_msg; + + return mstch::render(full_page, context); + } + + public_key tx_pub_key = xmreg::get_tx_pub_key_from_received_outs(tx); + + bool r = decode_ringct(tx.rct_signatures, + tx_pub_key, + prv_view_key, + td.m_internal_output_index, + tx.rct_signatures.ecdhInfo[td.m_internal_output_index].mask, + xmr_amount); + + if (!r) + { + string error_msg = fmt::format( + "Cant decode RingCT for output: {:s}", + txout_key.key); + + context["has_error"] = true; + context["error_msg"] = error_msg; + + return mstch::render(full_page, context); + } + } + uint64_t blk_timestamp = core_storage ->get_db().get_block_timestamp(td.m_block_height);