From a549f251384a4bcc78b99d0446ab1d9c36f01196 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Tue, 25 Jul 2017 11:28:54 +0800 Subject: [PATCH] get_payment_id_as_string added --- src/page.h | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/page.h b/src/page.h index 897acae..a9fc9ac 100644 --- a/src/page.h +++ b/src/page.h @@ -4939,6 +4939,32 @@ namespace xmreg private: + + string + get_payment_id_as_string( + tx_details const& txd, + secret_key const& prv_view_key) + { + string payment_id; + + // decrypt encrypted payment id, as used in integreated addresses + crypto::hash8 decrypted_payment_id8 = txd.payment_id8; + + if (decrypted_payment_id8 != null_hash8) + { + if (decrypt_payment_id(decrypted_payment_id8, txd.pk, prv_view_key)) + { + payment_id = pod_to_hex(decrypted_payment_id8); + } + } + else if(txd.payment_id != null_hash) + { + payment_id = pod_to_hex(txd.payment_id); + } + + return payment_id; + } + template bool find_our_outputs( @@ -5031,23 +5057,7 @@ namespace xmreg if (mine_output) { - - string payment_id; - - // decrypt encrypted payment id, as used in integreated addresses - crypto::hash8 decrypted_payment_id8 = txd.payment_id8; - - if (decrypted_payment_id8 != null_hash8) - { - if (decrypt_payment_id(decrypted_payment_id8, txd.pk, prv_view_key)) - { - payment_id = pod_to_hex(decrypted_payment_id8); - } - } - else if(txd.payment_id != null_hash) - { - payment_id = pod_to_hex(txd.payment_id); - } + string payment_id_str = get_payment_id_as_string(txd, prv_view_key); j_outptus.push_back(json { {"output_pubkey" , pod_to_hex(outp.first.key)}, @@ -5056,7 +5066,7 @@ namespace xmreg {"in_mempool" , is_mempool}, {"output_idx" , output_idx}, {"tx_hash" , pod_to_hex(txd.hash)}, - {"payment_id" , payment_id} + {"payment_id" , payment_id_str} }); } @@ -5066,7 +5076,6 @@ namespace xmreg } // for (auto it = blk_txs.begin(); it != blk_txs.end(); ++it) - return true; }