carrot_impl: add serialization impl for more Carrot types
This commit is contained in:
@@ -31,9 +31,13 @@
|
||||
#pragma once
|
||||
|
||||
//local headers
|
||||
#include "carrot_core/core_types.h"
|
||||
#include "carrot_chain_serialization.h"
|
||||
#include "carrot_core/payment_proposal.h"
|
||||
#include "carrot_tx_builder_types.h"
|
||||
#include "subaddress_index.h"
|
||||
|
||||
//third party headers
|
||||
#include <boost/serialization/optional_shim.hpp>
|
||||
#include <boost/serialization/utility.hpp>
|
||||
|
||||
//standard headers
|
||||
@@ -46,6 +50,12 @@ namespace serialization
|
||||
{
|
||||
//---------------------------------------------------
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, mx25519_pubkey &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.data;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, carrot::view_tag_t &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.bytes;
|
||||
@@ -57,5 +67,70 @@ inline void serialize(Archive &a, carrot::encrypted_janus_anchor_t &x, const boo
|
||||
a & x.bytes;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, carrot::encrypted_payment_id_t &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.bytes;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, carrot::CarrotDestinationV1 &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.address_spend_pubkey;
|
||||
a & x.address_view_pubkey;
|
||||
a & x.is_subaddress;
|
||||
a & x.payment_id;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, carrot::CarrotPaymentProposalV1 &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.destination;
|
||||
a & x.amount;
|
||||
a & x.randomness;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, carrot::CarrotPaymentProposalSelfSendV1 &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.destination_address_spend_pubkey;
|
||||
a & x.amount;
|
||||
a & x.enote_type;
|
||||
a & x.enote_ephemeral_pubkey;
|
||||
a & x.internal_message;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, carrot::subaddress_index &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.major;
|
||||
a & x.minor;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, carrot::subaddress_index_extended &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.index;
|
||||
a & x.derive_type;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, carrot::CarrotPaymentProposalVerifiableSelfSendV1 &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.proposal;
|
||||
a & x.subaddr_index;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, carrot::CarrotTransactionProposalV1 &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.key_images_sorted;
|
||||
a & x.normal_payment_proposals;
|
||||
a & x.selfsend_payment_proposals;
|
||||
a & x.dummy_encrypted_payment_id;
|
||||
a & x.fee;
|
||||
a & x.extra;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
} //namespace serialization
|
||||
} //namespace boot
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024, The Monero Project
|
||||
// Copyright (c) 2025, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
|
||||
90
src/carrot_impl/carrot_offchain_serialization.h
Normal file
90
src/carrot_impl/carrot_offchain_serialization.h
Normal file
@@ -0,0 +1,90 @@
|
||||
// Copyright (c) 2025, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
|
||||
//local headers
|
||||
#include "carrot_chain_serialization.h"
|
||||
#include "carrot_core/payment_proposal.h"
|
||||
#include "carrot_tx_builder_types.h"
|
||||
#include "serialization/crypto.h"
|
||||
#include "serialization/optional.h"
|
||||
#include "subaddress_index.h"
|
||||
|
||||
//third party headers
|
||||
|
||||
//standard headers
|
||||
|
||||
//forward declarations
|
||||
|
||||
BLOB_SERIALIZER(carrot::payment_id_t);
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT_FN(carrot::CarrotDestinationV1)
|
||||
FIELD_F(address_spend_pubkey)
|
||||
FIELD_F(address_view_pubkey)
|
||||
FIELD_F(is_subaddress)
|
||||
FIELD_F(payment_id)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT_FN(carrot::CarrotPaymentProposalV1)
|
||||
FIELD_F(destination)
|
||||
VARINT_FIELD_F(amount)
|
||||
FIELD_F(randomness)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT_FN(carrot::CarrotPaymentProposalSelfSendV1)
|
||||
FIELD_F(destination_address_spend_pubkey)
|
||||
VARINT_FIELD_F(amount)
|
||||
VARINT_FIELD_F(enote_type)
|
||||
FIELD_F(enote_ephemeral_pubkey)
|
||||
FIELD_F(internal_message)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT_FN(carrot::subaddress_index)
|
||||
VARINT_FIELD_F(major)
|
||||
VARINT_FIELD_F(minor)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT_FN(carrot::subaddress_index_extended)
|
||||
FIELD_F(index)
|
||||
VARINT_FIELD_F(derive_type)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT_FN(carrot::CarrotPaymentProposalVerifiableSelfSendV1)
|
||||
FIELD_F(proposal)
|
||||
FIELD_F(subaddr_index)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT_FN(carrot::CarrotTransactionProposalV1)
|
||||
FIELD_F(key_images_sorted)
|
||||
FIELD_F(normal_payment_proposals)
|
||||
FIELD_F(selfsend_payment_proposals)
|
||||
FIELD_F(dummy_encrypted_payment_id)
|
||||
VARINT_FIELD_F(fee)
|
||||
FIELD_F(extra)
|
||||
END_SERIALIZE()
|
||||
Reference in New Issue
Block a user