From 066a22823a2e4b5bc86e3da1f11b355bebbc3645 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 28 Sep 2017 12:48:54 +0800 Subject: [PATCH] adds decoding of payment id as ascii https://github.com/moneroexamples/onion-monero-blockchain-explorer/issues/81 --- src/page.h | 12 ++++++++++++ src/templates/partials/tx_details.html | 1 + 2 files changed, 13 insertions(+) diff --git a/src/page.h b/src/page.h index 50e2549..1758776 100644 --- a/src/page.h +++ b/src/page.h @@ -30,6 +30,7 @@ #include #include #include +#include #define TMPL_DIR "./templates" #define TMPL_PARIALS_DIR TMPL_DIR "/partials" @@ -140,6 +141,8 @@ namespace xmreg crypto::hash payment_id = null_hash; // normal crypto::hash8 payment_id8 = null_hash8; // encrypted + string payment_id_as_ascii; + std::vector> signatures; // key images of inputs @@ -5274,6 +5277,9 @@ namespace xmreg string tx_json = obj_to_json_str(tx); + // use this regex to remove all non friendly characters in payment_id_as_ascii string + static std::regex e {"[^a-zA-Z0-9 ./\\\\!]"}; + // initalise page tempate map with basic info about blockchain mstch::map context { {"testnet" , testnet}, @@ -5296,6 +5302,7 @@ namespace xmreg {"has_payment_id8" , txd.payment_id8 != null_hash8}, {"confirmations" , txd.no_confirmations}, {"payment_id" , pid_str}, + {"payment_id_as_ascii" , std::regex_replace(txd.payment_id_as_ascii, e, " ")}, {"payment_id8" , pid8_str}, {"extra" , txd.get_extra_str()}, {"with_ring_signatures" , static_cast( @@ -5732,6 +5739,11 @@ namespace xmreg txd.extra = tx.extra; + if (txd.payment_id != null_hash) + { + txd.payment_id_as_ascii = std::string(txd.payment_id.data, crypto::HASH_SIZE); + } + // get tx signatures for each input txd.signatures = tx.signatures; diff --git a/src/templates/partials/tx_details.html b/src/templates/partials/tx_details.html index c58d0b1..d92da77 100644 --- a/src/templates/partials/tx_details.html +++ b/src/templates/partials/tx_details.html @@ -9,6 +9,7 @@ {{#has_payment_id}}
Payment id: {{payment_id}}
+
Payment id as ascii ([a-zA-Z0-9 /!]): {{payment_id_as_ascii}}
{{/has_payment_id}} {{#has_payment_id8}}