forked from lthn/blockchain
fixed few issues with attachment encryption
This commit is contained in:
parent
01dc176ff4
commit
13accb65ad
7 changed files with 91 additions and 11 deletions
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ namespace boost
|
|||
}
|
||||
|
||||
template <class Archive>
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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<typename attachment_t>
|
||||
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<class t_container>
|
||||
bool fill_tx_rpc_payload_items(std::vector<tx_extra_rpc_entry>& target_vector, const t_container& tc)
|
||||
|
|
|
|||
|
|
@ -459,6 +459,35 @@ namespace currency
|
|||
}
|
||||
variant_container.push_back(v);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
template<class variant_type_t, class variant_t>
|
||||
bool has_field_of_type_in_extra(std::vector<variant_t>& variant_container)
|
||||
{
|
||||
for (auto& ev : variant_container)
|
||||
{
|
||||
if (ev.type() == typeid(variant_type_t))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
template<class variant_type_t, class variant_t>
|
||||
void remove_field_of_type_from_extra(std::vector<variant_t>& 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<typename t_container>
|
||||
|
|
|
|||
|
|
@ -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<etc_tx_flags16_t>(decrypted_att)))
|
||||
{
|
||||
remove_field_of_type_from_extra<tx_receiver_old>(decrypted_att);
|
||||
remove_field_of_type_from_extra<tx_payer_old>(decrypted_att);
|
||||
}
|
||||
if (is_watch_only())
|
||||
{
|
||||
remove_field_of_type_from_extra<tx_comment>(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<wallet_public::wallet_transfer_info>& 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())
|
||||
|
|
|
|||
|
|
@ -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<wallet_public::wallet_transfer_info>& 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<uint64_t>& ind, free_amounts_cache_type& found_free_amounts, uint64_t needed_money, uint64_t fake_outputs_count);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue