From 5215ad45ed705579ec30a35632adfa44d52ebca8 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 6 Oct 2017 09:37:23 +0800 Subject: [PATCH] Show payment id status in the index page https://github.com/moneroexamples/onion-monero-blockchain-explorer/issues/83#issuecomment-334315512 --- src/MempoolStatus.cpp | 12 ++++++++++++ src/MempoolStatus.h | 4 ++++ src/page.h | 12 ++++++++++++ src/templates/index2.html | 4 ++-- src/templates/mempool.html | 4 ++-- src/templates/partials/tx_details.html | 2 +- 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/MempoolStatus.cpp b/src/MempoolStatus.cpp index 76c91a6..92da790 100644 --- a/src/MempoolStatus.cpp +++ b/src/MempoolStatus.cpp @@ -182,6 +182,18 @@ MempoolStatus::read_mempool() last_tx.txsize = fmt::format("{:0.2f}", static_cast(_tx_info.blob_size)/1024.0); + last_tx.pID = '-'; + + crypto::hash payment_id; + crypto::hash8 payment_id8; + + get_payment_id(tx, payment_id, payment_id8); + + if (payment_id != null_hash) + last_tx.pID = 'l'; // legacy payment id + else if (payment_id8 != null_hash8) + last_tx.pID = 'e'; // encrypted payment id + } // if (hex_to_pod(_tx_info.id_hash, mem_tx_hash)) } // for (size_t i = 0; i < mempool_tx_info.size(); ++i) diff --git a/src/MempoolStatus.h b/src/MempoolStatus.h index 44607ea..8a42ab5 100644 --- a/src/MempoolStatus.h +++ b/src/MempoolStatus.h @@ -42,6 +42,10 @@ struct MempoolStatus string xmr_outputs_str; string timestamp_str; string txsize; + + char pID; // '-' - no payment ID, + // 'l' - legacy, long 64 character payment id, + // 'e' - encrypted, short, from integrated addresses }; diff --git a/src/page.h b/src/page.h index bb5890a..25f5e71 100644 --- a/src/page.h +++ b/src/page.h @@ -134,6 +134,9 @@ namespace xmreg uint64_t size; uint64_t blk_height; size_t version; + char pID; // '-' - no payment ID, + // 'l' - legacy, long 64 character payment id, + // 'e' - encrypted, short, from integrated addresses uint64_t unlock_time; uint64_t no_confirmations; vector extra; @@ -188,6 +191,7 @@ namespace xmreg {"version" , static_cast(version)}, {"has_payment_id" , payment_id != null_hash}, {"has_payment_id8" , payment_id8 != null_hash8}, + {"pID" , string {pID}}, {"payment_id" , pod_to_hex(payment_id)}, {"confirmations" , no_confirmations}, {"extra" , get_extra_str()}, @@ -885,6 +889,7 @@ namespace xmreg {"xmr_outputs" , mempool_tx.xmr_outputs_str}, {"no_inputs" , mempool_tx.no_inputs}, {"no_outputs" , mempool_tx.no_outputs}, + {"pID" , string {mempool_tx.pID}}, {"no_nonrct_inputs", mempool_tx.num_nonrct_inputs}, {"mixin" , mempool_tx.mixin_no}, {"txsize" , mempool_tx.txsize} @@ -5756,6 +5761,8 @@ namespace xmreg } } + txd.pID = '-'; // no payment ID + get_payment_id(tx, txd.payment_id, txd.payment_id8); // get tx size in bytes @@ -5766,6 +5773,11 @@ namespace xmreg if (txd.payment_id != null_hash) { txd.payment_id_as_ascii = std::string(txd.payment_id.data, crypto::HASH_SIZE); + txd.pID = 'l'; // legacy payment id + } + else if (txd.payment_id8 != null_hash8) + { + txd.pID = 'e'; // encrypted payment id } // get tx signatures for each input diff --git a/src/templates/index2.html b/src/templates/index2.html index 53da4f8..c83eb91 100644 --- a/src/templates/index2.html +++ b/src/templates/index2.html @@ -76,7 +76,7 @@ tx hash fees outputs - in(nonrct)/out + in/out/pID ring size tx size [kB] @@ -88,7 +88,7 @@ {{hash}} {{tx_fee_short}} {{sum_outputs_short}} - {{no_inputs}}({{no_nonrct_inputs}})/{{no_outputs}} + {{no_inputs}}/{{no_outputs}}/{{pID}} {{mixin}} {{tx_size_short}} diff --git a/src/templates/mempool.html b/src/templates/mempool.html index 361865e..f508b2a 100644 --- a/src/templates/mempool.html +++ b/src/templates/mempool.html @@ -10,7 +10,7 @@ transaction hash fee outputs - in(nonrct)/out + in/out/pID ring size tx size [kB] @@ -20,7 +20,7 @@ {{hash}} {{fee}} {{xmr_outputs}} - {{no_inputs}}({{no_nonrct_inputs}})/{{no_outputs}} + {{no_inputs}}/{{no_outputs}}/{{pID}} {{mixin}} {{txsize}} diff --git a/src/templates/partials/tx_details.html b/src/templates/partials/tx_details.html index d92da77..9fd52c3 100644 --- a/src/templates/partials/tx_details.html +++ b/src/templates/partials/tx_details.html @@ -9,7 +9,7 @@ {{#has_payment_id}}
Payment id: {{payment_id}}
-
Payment id as ascii ([a-zA-Z0-9 /!]): {{payment_id_as_ascii}}
+
Payment id as ascii: {{payment_id_as_ascii}}
{{/has_payment_id}} {{#has_payment_id8}}