get_payment_id added to tools

master
moneroexamples 9 years ago
parent 95b7e8daf2
commit c323f61adf

@ -446,6 +446,41 @@ namespace xmreg
return key_images; 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_field> 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 * Rough estimate of block height from the time provided
* *

@ -159,6 +159,12 @@ namespace xmreg
get_key_images(const transaction& tx); get_key_images(const transaction& tx);
bool
get_payment_id(const transaction& tx,
crypto::hash& payment_id,
crypto::hash8& payment_id8);
inline void inline void
enable_monero_log() { enable_monero_log() {
uint32_t log_level = 0; uint32_t log_level = 0;

@ -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_field> 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_field> 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<> template<>

@ -52,13 +52,7 @@ namespace xmreg
const secret_key& private_view_key, const secret_key& private_view_key,
const public_key& public_spend_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);
} }

Loading…
Cancel
Save