From 906e55f87bb6bf71f4b223cdf69bbe392c991078 Mon Sep 17 00:00:00 2001 From: akildemir <34187742+akildemir@users.noreply.github.com> Date: Wed, 6 Aug 2025 17:00:56 +0300 Subject: [PATCH] add return into type to wallet serialization (#42) --- src/carrot_core/account.h | 51 +++++++++++++++++ .../cryptonote_boost_serialization.h | 5 ++ src/serialization/crypto.h | 3 + src/wallet/wallet2.cpp | 56 +++++++++---------- src/wallet/wallet2.h | 3 + 5 files changed, 87 insertions(+), 31 deletions(-) diff --git a/src/carrot_core/account.h b/src/carrot_core/account.h index e102ca39f..07f45a590 100644 --- a/src/carrot_core/account.h +++ b/src/carrot_core/account.h @@ -52,6 +52,16 @@ namespace carrot crypto::secret_key x; crypto::secret_key y; + return_output_info_t() { + // Default constructor for serialization + input_context = input_context_t(); + K_o = crypto::public_key(); + K_change = crypto::public_key(); + key_image = crypto::key_image(); + x = crypto::secret_key(); + y = crypto::secret_key(); + } + return_output_info_t( const input_context_t &input_context, const crypto::public_key &K_o, @@ -65,6 +75,15 @@ namespace carrot key_image(key_image), x(x), y(y) {} + + BEGIN_SERIALIZE_OBJECT() + FIELD(input_context) + FIELD(K_o) + FIELD(K_change) + FIELD(key_image) + FIELD(x) + FIELD(y) + END_SERIALIZE() }; @@ -148,3 +167,35 @@ namespace carrot std::unordered_map return_output_map; }; } + +namespace boost +{ + namespace serialization + { + template + inline typename std::enable_if::type initialize_transfer_details(Archive &a, carrot::return_output_info_t &x, const boost::serialization::version_type ver) + { + } + template + inline typename std::enable_if::type initialize_transfer_details(Archive &a, carrot::return_output_info_t &x, const boost::serialization::version_type ver) + { + x.input_context = carrot::input_context_t(); + x.K_o = crypto::public_key(); + x.K_change = crypto::public_key(); + x.key_image = crypto::key_image(); + x.x = crypto::secret_key(); + x.y = crypto::secret_key(); + } + + template + inline void serialize(Archive &a, carrot::return_output_info_t &x, const boost::serialization::version_type ver) + { + a & x.input_context; + a & x.K_o; + a & x.K_change; + a & x.key_image; + a & x.x; + a & x.y; + } + } +} diff --git a/src/cryptonote_basic/cryptonote_boost_serialization.h b/src/cryptonote_basic/cryptonote_boost_serialization.h index e9b50fc83..1f55a3f60 100644 --- a/src/cryptonote_basic/cryptonote_boost_serialization.h +++ b/src/cryptonote_basic/cryptonote_boost_serialization.h @@ -73,6 +73,11 @@ namespace boost a & reinterpret_cast(x); } template + inline void serialize(Archive &a, carrot::input_context_t &x, const boost::serialization::version_type ver) + { + a & reinterpret_cast(x); + } + template inline void serialize(Archive &a, crypto::view_tag &x, const boost::serialization::version_type ver) { a & reinterpret_cast(x); diff --git a/src/serialization/crypto.h b/src/serialization/crypto.h index ca7fa776c..a06bb604e 100644 --- a/src/serialization/crypto.h +++ b/src/serialization/crypto.h @@ -38,6 +38,7 @@ #include "crypto/crypto.h" #include "crypto/hash.h" #include "mx25519.h" +#include "carrot_core/core_types.h" // read template