diff --git a/src/tools.cpp b/src/tools.cpp index 6e0345b..4578536 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -446,6 +446,41 @@ namespace xmreg return key_images; } + bool + get_payment_id(const transaction& tx, + 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)) + { + return false; + } + + tx_extra_nonce extra_nonce; + + if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce)) + { + // first check for encripted id and then for normal one + if(get_encrypted_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id8)) + { + return true; + } + else if (get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id)) + { + return true; + } + } + + return false; + } + + /** * Rough estimate of block height from the time provided * diff --git a/src/tools.h b/src/tools.h index 397bd63..2f06403 100644 --- a/src/tools.h +++ b/src/tools.h @@ -159,6 +159,12 @@ namespace xmreg get_key_images(const transaction& tx); + bool + get_payment_id(const transaction& tx, + crypto::hash& payment_id, + crypto::hash8& payment_id8); + + inline void enable_monero_log() { uint32_t log_level = 0; diff --git a/src/tx_details.cpp b/src/tx_details.cpp index 4ed14da..b839162 100644 --- a/src/tx_details.cpp +++ b/src/tx_details.cpp @@ -205,75 +205,6 @@ namespace xmreg } - - bool - get_payment_id(const transaction& tx, - crypto::hash& payment_id) - { - - payment_id = null_hash; - - std::vector tx_extra_fields; - - if(!parse_tx_extra(tx.extra, tx_extra_fields)) - { - return false; - } - - tx_extra_nonce extra_nonce; - - if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce)) - { - if (!get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id)) - { - return false; - } - } - else - { - return false; - } - - return true; - } - - - bool - get_encrypted_payment_id(const transaction& tx, - crypto::hash8& payment_id8) - { - payment_id8 = null_hash8; - - std::vector tx_extra_fields; - - if(!parse_tx_extra(tx.extra, tx_extra_fields)) - { - return false; - } - - tx_extra_nonce extra_nonce; - - if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce)) - { - - if (!get_encrypted_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id8)) - { - // if (decrypt_payment_id(payment_id8, addr.m_view_public_key, ptx.tx_key)) - // { - // memcpy(payment_id8.data, payment_id8.data, 8); - // } - return false; - } - } - else - { - return false; - } - - return true; - } - - } template<> diff --git a/src/tx_details.h b/src/tx_details.h index db77038..6e7609d 100644 --- a/src/tx_details.h +++ b/src/tx_details.h @@ -52,13 +52,7 @@ namespace xmreg const secret_key& private_view_key, const public_key& public_spend_key); - bool - get_payment_id(const transaction& tx, - crypto::hash& payment_id); - bool - get_encrypted_payment_id(const transaction& tx, - crypto::hash8& payment_id); }