diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h index 97ec2be2..c0d46af3 100644 --- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h +++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h @@ -453,6 +453,30 @@ namespace epee } return r; } + //------------------------------------------------------------------------------------------------------------------- + //boost::shared_ptr + template + bool kv_serialize(const boost::shared_ptr& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname) + { + if (d.get()) + { + return kv_serialize(*d, stg, hparent_section, pname); + } + return true; + } + //------------------------------------------------------------------------------------------------------------------- + template + bool kv_unserialize(boost::shared_ptr& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname) + { + d.reset(); + t_type* ptr = new t_type(); + bool r = kv_unserialize(*ptr, stg, hparent_section, pname); + if (!r) + { + d.reset(ptr); + } + return r; + } } diff --git a/src/common/crypto_serialization.h b/src/common/crypto_serialization.h index 0ce6b263..79af98bc 100644 --- a/src/common/crypto_serialization.h +++ b/src/common/crypto_serialization.h @@ -119,6 +119,7 @@ VARIANT_TAG(debug_archive, crypto::signature, "signature"); // KV_ENABLE_POD_SERIALIZATION_AS_HEX(crypto::scalar_t); +KV_ENABLE_POD_SERIALIZATION_AS_HEX(crypto::hash); // // Boost serialization diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index a3d7409d..aeaea8cc 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -650,7 +650,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t } if (out_type_zc) - td.m_opt_blinding_mask = out.blinding_mask; + td.m_opt_blinding_mask.reset(new crypto::scalar_t(out.blinding_mask)); size_t transfer_index = m_transfers.size() - 1; if (out_is_to_htlc(out_v)) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 621e7aa9..d78d092b 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -381,7 +382,8 @@ namespace tools uint64_t m_spent_height; uint32_t m_flags; uint64_t m_amount; - boost::optional m_opt_blinding_mask; + boost::shared_ptr m_opt_blinding_mask; + boost::shared_ptr m_asset_id; // @#@ will throw if type is not tx_out_bare, TODO: change according to new model, // need to replace all get_tx_out_bare_from_out_v() to proper code @@ -392,7 +394,7 @@ namespace tools bool is_spent() const { return m_flags & WALLET_TRANSFER_DETAIL_FLAG_SPENT; } bool is_spendable() const { return (m_flags & (WALLET_TRANSFER_DETAIL_FLAG_SPENT | WALLET_TRANSFER_DETAIL_FLAG_BLOCKED | WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION | WALLET_TRANSFER_DETAIL_FLAG_COLD_SIG_RESERVATION)) == 0; } bool is_reserved_for_escrow() const { return ( (m_flags & WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION) != 0 ); } - bool is_zc() const { return m_opt_blinding_mask != boost::none; } + bool is_zc() const { return m_opt_blinding_mask.get(); } BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE_CUSTOM(m_ptx_wallet_info, const transaction_wallet_info&, tools::wallet2::transform_ptr_to_value, tools::wallet2::transform_value_to_ptr) @@ -401,6 +403,7 @@ namespace tools KV_SERIALIZE(m_flags) KV_SERIALIZE(m_amount) KV_SERIALIZE_N(m_opt_blinding_mask, "blinding_mask") + KV_SERIALIZE(m_asset_id) KV_SERIALIZE_EPHEMERAL_N(uint64_t, tools::wallet2::transfer_details_base_to_amount, "amount") KV_SERIALIZE_EPHEMERAL_N(std::string, tools::wallet2::transfer_details_base_to_tx_hash, "tx_id") END_KV_SERIALIZE_MAP() @@ -1169,6 +1172,8 @@ namespace boost return; } a & x.m_amount; + a & x.m_opt_blinding_mask; + a & x.m_asset_id; }