From bd34433be23593807ec23480d7eb9d84318e9293 Mon Sep 17 00:00:00 2001 From: jeffro256 Date: Mon, 19 May 2025 14:44:58 -0500 Subject: [PATCH] carrot_impl: refactor for encrypted_payment_id_t type separation --- src/carrot_impl/carrot_boost_serialization.h | 6 ++++++ src/carrot_impl/carrot_chain_serialization.h | 1 + src/carrot_impl/carrot_offchain_serialization.h | 14 +++++++++++++- src/carrot_impl/tx_proposal_utils.cpp | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/carrot_impl/carrot_boost_serialization.h b/src/carrot_impl/carrot_boost_serialization.h index 86e086478..9e2af0b32 100644 --- a/src/carrot_impl/carrot_boost_serialization.h +++ b/src/carrot_impl/carrot_boost_serialization.h @@ -68,6 +68,12 @@ inline void serialize(Archive &a, carrot::encrypted_janus_anchor_t &x, const boo } //--------------------------------------------------- template +inline void serialize(Archive &a, carrot::payment_id_t &x, const boost::serialization::version_type ver) +{ + a & x.bytes; +} +//--------------------------------------------------- +template inline void serialize(Archive &a, carrot::encrypted_payment_id_t &x, const boost::serialization::version_type ver) { a & x.bytes; diff --git a/src/carrot_impl/carrot_chain_serialization.h b/src/carrot_impl/carrot_chain_serialization.h index 009eabd03..d3b7cf0ca 100644 --- a/src/carrot_impl/carrot_chain_serialization.h +++ b/src/carrot_impl/carrot_chain_serialization.h @@ -40,3 +40,4 @@ BLOB_SERIALIZER(carrot::view_tag_t); BLOB_SERIALIZER(carrot::encrypted_janus_anchor_t); +BLOB_SERIALIZER(carrot::encrypted_payment_id_t); diff --git a/src/carrot_impl/carrot_offchain_serialization.h b/src/carrot_impl/carrot_offchain_serialization.h index d016f5867..7b7dc070e 100644 --- a/src/carrot_impl/carrot_offchain_serialization.h +++ b/src/carrot_impl/carrot_offchain_serialization.h @@ -42,7 +42,19 @@ //forward declarations -BLOB_SERIALIZER(carrot::payment_id_t); +BEGIN_SERIALIZE_OBJECT_FN(carrot::payment_id_t) + bool is_null = v == carrot::null_payment_id; + FIELD(is_null) + if (is_null) + { + v = carrot::null_payment_id; + } + else + { + ar.tag("data"); + ar.serialize_blob(&v, sizeof(v)); + } +END_SERIALIZE() BEGIN_SERIALIZE_OBJECT_FN(carrot::CarrotDestinationV1) FIELD_F(address_spend_pubkey) diff --git a/src/carrot_impl/tx_proposal_utils.cpp b/src/carrot_impl/tx_proposal_utils.cpp index f9b8979bd..9bd3f54c1 100644 --- a/src/carrot_impl/tx_proposal_utils.cpp +++ b/src/carrot_impl/tx_proposal_utils.cpp @@ -163,7 +163,7 @@ void make_carrot_transaction_proposal_v1(const std::vector