diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-08-12 23:05:53 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-09-26 23:12:38 +0100 |
commit | d9b0bf9f354b5ef212e6b15c7c0ead99b09be624 (patch) | |
tree | a7462f9da4c445b7ef9ea780ae3fed0f38e93f04 | |
parent | serialization: add support for serializing std::pair and std::list (diff) | |
download | monero-d9b0bf9f354b5ef212e6b15c7c0ead99b09be624.tar.xz |
cryptonote_core: make extra field removal more generic
Diffstat (limited to '')
-rw-r--r-- | src/cryptonote_core/cryptonote_format_utils.cpp | 6 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_format_utils.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp index d1ccfc7d1..7e0c75ccf 100644 --- a/src/cryptonote_core/cryptonote_format_utils.cpp +++ b/src/cryptonote_core/cryptonote_format_utils.cpp @@ -366,7 +366,7 @@ namespace cryptonote return true; } //--------------------------------------------------------------- - bool remove_extra_nonce_tx_extra(std::vector<uint8_t>& tx_extra) + bool remove_field_from_tx_extra(std::vector<uint8_t>& tx_extra, const std::type_info &type) { std::string extra_str(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size()); std::istringstream iss(extra_str); @@ -380,7 +380,7 @@ namespace cryptonote tx_extra_field field; bool r = ::do_serialize(ar, field); CHECK_AND_NO_ASSERT_MES_L1(r, false, "failed to deserialize extra field. extra = " << string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size()))); - if (field.type() != typeid(tx_extra_nonce)) + if (field.type() != type) ::do_serialize(newar, field); std::ios_base::iostate state = iss.rdstate(); @@ -512,7 +512,7 @@ namespace cryptonote std::string extra_nonce; set_encrypted_payment_id_to_tx_extra_nonce(extra_nonce, payment_id); - remove_extra_nonce_tx_extra(tx.extra); + remove_field_from_tx_extra(tx.extra, typeid(tx_extra_fields)); if (!add_extra_nonce_to_tx_extra(tx.extra, extra_nonce)) { LOG_ERROR("Failed to add encrypted payment id to tx extra"); diff --git a/src/cryptonote_core/cryptonote_format_utils.h b/src/cryptonote_core/cryptonote_format_utils.h index e6a3bfba4..a42296994 100644 --- a/src/cryptonote_core/cryptonote_format_utils.h +++ b/src/cryptonote_core/cryptonote_format_utils.h @@ -94,7 +94,7 @@ namespace cryptonote crypto::public_key get_tx_pub_key_from_extra(const transaction& tx); bool add_tx_pub_key_to_extra(transaction& tx, const crypto::public_key& tx_pub_key); bool add_extra_nonce_to_tx_extra(std::vector<uint8_t>& tx_extra, const blobdata& extra_nonce); - bool remove_extra_nonce_tx_extra(std::vector<uint8_t>& tx_extra); + bool remove_field_from_tx_extra(std::vector<uint8_t>& tx_extra, const std::type_info &type); void set_payment_id_to_tx_extra_nonce(blobdata& extra_nonce, const crypto::hash& payment_id); void set_encrypted_payment_id_to_tx_extra_nonce(blobdata& extra_nonce, const crypto::hash8& payment_id); bool get_payment_id_from_tx_extra_nonce(const blobdata& extra_nonce, crypto::hash& payment_id); |