cryptonote_core: make extra field removal more generic
This commit is contained in:
parent
98f19d40aa
commit
d9b0bf9f35
2 changed files with 4 additions and 4 deletions
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue