diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index f3972253..8ac26a6f 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -508,7 +508,7 @@ namespace currency END_SERIALIZE() }; - struct etc_tx_uint16_t + struct etc_tx_flags16_t { uint16_t v; BEGIN_SERIALIZE() @@ -518,7 +518,7 @@ namespace currency typedef boost::mpl::vector21< tx_service_attachment, tx_comment, tx_payer_old, tx_receiver_old, tx_derivation_hint, std::string, tx_crypto_checksum, etc_tx_time, etc_tx_details_unlock_time, etc_tx_details_expiration_time, - etc_tx_details_flags, crypto::public_key, extra_attachment_info, extra_alias_entry_old, extra_user_data, extra_padding, etc_tx_uint16_t, etc_tx_details_unlock_time2, + etc_tx_details_flags, crypto::public_key, extra_attachment_info, extra_alias_entry_old, extra_user_data, extra_padding, etc_tx_flags16_t, etc_tx_details_unlock_time2, tx_payer, tx_receiver, extra_alias_entry > all_payload_types; @@ -749,7 +749,7 @@ SET_VARIANT_TAGS(currency::extra_user_data, 19, "user_data"); SET_VARIANT_TAGS(currency::extra_alias_entry_old, 20, "alias_entry"); SET_VARIANT_TAGS(currency::extra_padding, 21, "extra_padding"); SET_VARIANT_TAGS(crypto::public_key, 22, "pub_key"); -SET_VARIANT_TAGS(currency::etc_tx_uint16_t, 23, "etc_tx_uint16"); +SET_VARIANT_TAGS(currency::etc_tx_flags16_t, 23, "etc_tx_flags16"); SET_VARIANT_TAGS(uint16_t, 24, "derive_xor"); //txout_v SET_VARIANT_TAGS(currency::ref_by_id, 25, "ref_by_id"); diff --git a/src/currency_core/currency_boost_serialization.h b/src/currency_core/currency_boost_serialization.h index 49f4b9cf..93e240cb 100644 --- a/src/currency_core/currency_boost_serialization.h +++ b/src/currency_core/currency_boost_serialization.h @@ -252,7 +252,7 @@ namespace boost } template - inline void serialize(Archive &a, currency::etc_tx_uint16_t&at, const boost::serialization::version_type ver) + inline void serialize(Archive &a, currency::etc_tx_flags16_t&at, const boost::serialization::version_type ver) { a & at.v; } diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 6bb298f6..4e06493b 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -221,7 +221,7 @@ #define BC_OFFERS_CURRENCY_MARKET_FILENAME "market.bin" -#define WALLET_FILE_SERIALIZATION_VERSION (CURRENCY_FORMATION_VERSION+67) +#define WALLET_FILE_SERIALIZATION_VERSION (CURRENCY_FORMATION_VERSION+68) #define CURRENT_MEMPOOL_ARCHIVE_VER (CURRENCY_FORMATION_VERSION+31) diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index ed017a34..740c7afc 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -710,6 +710,16 @@ namespace currency crypto::chacha_crypt(m.acc_addr, m_key); m_was_crypted_entries = true; } + void operator()(tx_payer_old& pr) + { + crypto::chacha_crypt(pr.acc_addr, m_key); + m_was_crypted_entries = true; + } + void operator()(tx_receiver_old& m) + { + crypto::chacha_crypt(m.acc_addr, m_key); + m_was_crypted_entries = true; + } void operator()(tx_service_attachment& sa) { if (sa.flags&TX_SERVICE_ATTACHMENT_DEFLATE_BODY) @@ -772,7 +782,18 @@ namespace currency crypto::chacha_crypt(receiver_local.acc_addr, rkey); rdecrypted_att.push_back(receiver_local); } - + void operator()(const tx_payer_old& pr) + { + tx_payer_old payer_local = pr; + crypto::chacha_crypt(payer_local.acc_addr, rkey); + rdecrypted_att.push_back(payer_local); + } + void operator()(const tx_receiver_old& pr) + { + tx_receiver_old receiver_local = pr; + crypto::chacha_crypt(receiver_local.acc_addr, rkey); + rdecrypted_att.push_back(receiver_local); + } template void operator()(const attachment_t& att) { @@ -1049,6 +1070,11 @@ namespace currency add_tx_pub_key_to_extra(tx, txkey.pub); one_time_secret_key = txkey.sec; + //add flags + etc_tx_flags16_t e = AUTO_VAL_INIT(e); + //todo: add some flags here + update_or_add_field_to_extra(tx.extra, e); + //include offers if need tx.attachment = attachments; encrypt_attachments(tx, sender_account_keys, crypt_destination_addr, txkey); @@ -2316,18 +2342,15 @@ namespace currency return true; } - bool operator()(const etc_tx_uint16_t& dh) + bool operator()(const etc_tx_flags16_t& dh) { - tv.type = "XOR"; + tv.type = "FLAGS16"; tv.short_view = epee::string_tools::pod_to_hex(dh); tv.datails_view = epee::string_tools::pod_to_hex(dh); return true; } - }; - - //------------------------------------------------------------------ template bool fill_tx_rpc_payload_items(std::vector& target_vector, const t_container& tc) diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index c17d3f14..ce7642b9 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -459,6 +459,35 @@ namespace currency } variant_container.push_back(v); } + //--------------------------------------------------------------- + template + bool has_field_of_type_in_extra(std::vector& variant_container) + { + for (auto& ev : variant_container) + { + if (ev.type() == typeid(variant_type_t)) + { + return true; + } + } + return false; + } + //--------------------------------------------------------------- + template + void remove_field_of_type_from_extra(std::vector& variant_container) + { + for (size_t i = 0; i != variant_container.size();) + { + if (variant_container[i].type() == typeid(variant_type_t)) + { + variant_container.erase(variant_container.begin()+i); + } + else + { + i++; + } + } + } //--------------------------------------------------------------- template diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index b1eae98f..47d7f01d 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1184,6 +1184,15 @@ void wallet2::prepare_wti(wallet_public::wallet_transfer_info& wti, uint64_t hei decrypt_payload_items(decrypt_attachment_as_income, tx, m_account.get_keys(), decrypted_att); + if (is_watch_only() || (height > 638000 && !has_field_of_type_in_extra(decrypted_att))) + { + remove_field_of_type_from_extra(decrypted_att); + remove_field_of_type_from_extra(decrypted_att); + } + if (is_watch_only()) + { + remove_field_of_type_from_extra(decrypted_att); + } prepare_wti_decrypted_attachments(wti, decrypted_att); process_contract_info(wti, decrypted_att); } @@ -4302,6 +4311,19 @@ bool wallet2::is_transfer_ready_to_go(const transfer_details& td, uint64_t fake_ return false; } //---------------------------------------------------------------------------------------------------- +void wallet2::wipeout_extra_if_needed(std::vector& transfer_history) +{ + WLT_LOG_L0("Processing [wipeout_extra_if_needed]..."); + for (auto it = transfer_history.begin(); it != transfer_history.end(); ) + { + if (it->height > 638000) + { + it->remote_addresses.clear(); + } + } + WLT_LOG_L0("Processing [wipeout_extra_if_needed] DONE"); +} +//---------------------------------------------------------------------------------------------------- bool wallet2::is_transfer_able_to_go(const transfer_details& td, uint64_t fake_outputs_count) { if (!td.is_spendable()) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index fedc856e..f8993de0 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -730,8 +730,14 @@ namespace tools a & m_tx_keys; a & m_last_pow_block_h; + //after processing + if (ver < 152) + { + wipeout_extra_if_needed(m_transfer_history); + } } + void wipeout_extra_if_needed(std::vector& transfer_history); bool is_transfer_ready_to_go(const transfer_details& td, uint64_t fake_outputs_count); bool is_transfer_able_to_go(const transfer_details& td, uint64_t fake_outputs_count); uint64_t select_indices_for_transfer(std::vector& ind, free_amounts_cache_type& found_free_amounts, uint64_t needed_money, uint64_t fake_outputs_count);