From c193e8adeb07bcaddbc88a910c4a54a96105cd9e Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 19 Oct 2016 10:46:33 +0800 Subject: [PATCH] payment_id added to details of unsigned raw tx --- src/page.h | 16 +++++++++++++++- src/templates/checkrawtx.html | 10 +++++++++- src/tools.cpp | 17 +++++++++++++---- src/tools.h | 5 +++++ 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/page.h b/src/page.h index d09b8e3..4d386df 100644 --- a/src/page.h +++ b/src/page.h @@ -1342,12 +1342,26 @@ namespace xmreg { const tx_destination_entry& tx_change = tx_cd.change_dts; + crypto::hash payment_id = null_hash; + crypto::hash8 payment_id8 = null_hash8; + + get_payment_id(tx_cd.extra, payment_id, payment_id8); + + // payments id. both normal and encrypted (payment_id8) + string pid_str = REMOVE_HASH_BRAKETS(fmt::format("{:s}", payment_id)); + string pid8_str = REMOVE_HASH_BRAKETS(fmt::format("{:s}", payment_id8)); + + mstch::map tx_cd_data { {"no_of_sources" , no_of_sources}, {"use_rct" , tx_cd.use_rct}, {"change_amount" , fmt::format("{:0.12f}", XMR_AMOUNT(tx_change.amount))}, + {"has_payment_id" , (payment_id != null_hash)}, + {"has_payment_id8" , (payment_id8 != null_hash8)}, + {"payment_id" , pid_str}, + {"payment_id8" , pid8_str}, {"dest_sources" , mstch::array{}}, - {"dest_infos" , mstch::array{}}, + {"dest_infos" , mstch::array{}}, }; mstch::array& dest_sources = boost::get(tx_cd_data["dest_sources"]); diff --git a/src/templates/checkrawtx.html b/src/templates/checkrawtx.html index b212160..bfcb6cc 100644 --- a/src/templates/checkrawtx.html +++ b/src/templates/checkrawtx.html @@ -27,11 +27,19 @@ {{#txs}}
-

Destination information

+

Basic information

{{#dest_infos}} Send {{dest_amount}} to {{dest_address}}
{{/dest_infos}} + + {{#has_payment_id}} + Payment id: {{payment_id}}
+ {{/has_payment_id}} + + {{#has_payment_id8}} + Payment id (encrypted): {{payment_id8}}
+ {{/has_payment_id8}}

diff --git a/src/tools.cpp b/src/tools.cpp index bc13b73..c210b49 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -472,18 +472,18 @@ namespace xmreg return key_images; } + bool - get_payment_id(const transaction& tx, + get_payment_id(const vector& extra, crypto::hash& payment_id, crypto::hash8& payment_id8) { - payment_id = null_hash; payment_id8 = null_hash8; std::vector tx_extra_fields; - if(!parse_tx_extra(tx.extra, tx_extra_fields)) + if(!parse_tx_extra(extra, tx_extra_fields)) { return false; } @@ -492,7 +492,7 @@ namespace xmreg if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce)) { - // first check for encripted id and then for normal one + // first check for encrypted id and then for normal one if(get_encrypted_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id8)) { return true; @@ -507,6 +507,15 @@ namespace xmreg } + bool + get_payment_id(const transaction& tx, + crypto::hash& payment_id, + crypto::hash8& payment_id8) + { + return get_payment_id(tx.extra, payment_id, payment_id8); + } + + /** * Rough estimate of block height from the time provided * diff --git a/src/tools.h b/src/tools.h index a4e9a69..1dfc92e 100644 --- a/src/tools.h +++ b/src/tools.h @@ -163,6 +163,11 @@ namespace xmreg get_key_images(const transaction& tx); + bool + get_payment_id(const vector& extra, + crypto::hash& payment_id, + crypto::hash8& payment_id8); + bool get_payment_id(const transaction& tx, crypto::hash& payment_id,