carrot_impl: file reorganization
This commit is contained in:
@@ -29,9 +29,10 @@
|
||||
set(carrot_impl_sources
|
||||
address_device_ram_borrowed.cpp
|
||||
address_utils_compat.cpp
|
||||
carrot_tx_builder_utils.cpp
|
||||
carrot_tx_format_utils.cpp
|
||||
format_utils.cpp
|
||||
input_selection.cpp
|
||||
tx_builder_outputs.cpp
|
||||
tx_proposal_utils.cpp
|
||||
)
|
||||
|
||||
monero_find_all_headers(carrot_impl_headers, "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
//local headers
|
||||
#include "carrot_chain_serialization.h"
|
||||
#include "carrot_core/payment_proposal.h"
|
||||
#include "carrot_tx_builder_types.h"
|
||||
#include "subaddress_index.h"
|
||||
#include "tx_proposal.h"
|
||||
|
||||
//third party headers
|
||||
#include <boost/serialization/optional_shim.hpp>
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
//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"
|
||||
#include "tx_proposal.h"
|
||||
|
||||
//third party headers
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//paired header
|
||||
#include "carrot_tx_format_utils.h"
|
||||
#include "format_utils.h"
|
||||
|
||||
//local headers
|
||||
#include "carrot_core/enote_utils.h"
|
||||
@@ -84,19 +84,6 @@ static void stable_sort_indices_by_amount(const epee::span<const CarrotPreSelect
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
static void stable_sort_indices_by_block_index(const epee::span<const CarrotPreSelectedInput> input_candidates,
|
||||
std::vector<size_t> &indices_inout)
|
||||
{
|
||||
std::stable_sort(indices_inout.begin(), indices_inout.end(),
|
||||
[input_candidates](const std::size_t a, const std::size_t b) -> bool
|
||||
{
|
||||
CARROT_CHECK_AND_THROW(a < input_candidates.size() && b < input_candidates.size(),
|
||||
std::out_of_range, "input candidate index out of range");
|
||||
return input_candidates[a].block_index < input_candidates[b].block_index;
|
||||
});
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
static std::pair<std::size_t, boost::multiprecision::uint128_t> input_count_for_max_usable_money(
|
||||
const epee::span<const CarrotPreSelectedInput> input_candidates,
|
||||
const std::set<std::size_t> &selectable_inputs,
|
||||
@@ -463,7 +450,7 @@ select_inputs_func_t make_single_transfer_input_selector(
|
||||
|
||||
// Filter all dust out of subset unless ALLOW_DUST flag is provided
|
||||
std::set<std::size_t> candidate_subset_filtered = input_candidate_subset;
|
||||
if (!(flags * ALLOW_DUST))
|
||||
if (!(flags & ALLOW_DUST))
|
||||
{
|
||||
const rct::xmr_amount dust_threshold = fee_by_input_count.at(n_inputs)
|
||||
- (n_inputs > CARROT_MIN_TX_INPUTS ? fee_by_input_count.at(n_inputs - 1) : 0);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#pragma once
|
||||
|
||||
//local headers
|
||||
#include "carrot_tx_builder_types.h"
|
||||
#include "tx_proposal_utils.h"
|
||||
|
||||
//third party headers
|
||||
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
// Copyright (c) 2024, 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.
|
||||
|
||||
//paired header
|
||||
#include "tx_builder_outputs.h"
|
||||
|
||||
//local headers
|
||||
#include "carrot_core/output_set_finalization.h"
|
||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||
#include "format_utils.h"
|
||||
#include "ringct/rctSigs.h"
|
||||
|
||||
//third party headers
|
||||
|
||||
//standard headers
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
#define MONERO_DEFAULT_LOG_CATEGORY "carrot_impl.tbo"
|
||||
|
||||
namespace carrot
|
||||
{
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
void get_output_enote_proposals_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
std::vector<RCTOutputEnoteProposal> &output_enote_proposals_out,
|
||||
encrypted_payment_id_t &encrypted_payment_id_out,
|
||||
std::vector<std::pair<bool, std::size_t>> *payment_proposal_order_out)
|
||||
{
|
||||
// collect self-sends proposal cores
|
||||
std::vector<CarrotPaymentProposalSelfSendV1> selfsend_payment_proposal_cores;
|
||||
selfsend_payment_proposal_cores.reserve(tx_proposal.selfsend_payment_proposals.size());
|
||||
for (const auto &selfsend_payment_proposal : tx_proposal.selfsend_payment_proposals)
|
||||
selfsend_payment_proposal_cores.push_back(selfsend_payment_proposal.proposal);
|
||||
|
||||
// derive enote proposals
|
||||
get_output_enote_proposals(tx_proposal.normal_payment_proposals,
|
||||
selfsend_payment_proposal_cores,
|
||||
tx_proposal.dummy_encrypted_payment_id,
|
||||
s_view_balance_dev,
|
||||
k_view_dev,
|
||||
tx_proposal.key_images_sorted.at(0),
|
||||
output_enote_proposals_out,
|
||||
encrypted_payment_id_out,
|
||||
payment_proposal_order_out);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
void make_signable_tx_hash_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
crypto::hash &signable_tx_hash_out)
|
||||
{
|
||||
//! @TODO: there's a more efficient way to do this than constructing&serializing a whole cryptonote::transaction
|
||||
// HW devices will need to implement this function to sign tx proposals, and most of these devices don't have a lot of memory
|
||||
|
||||
cryptonote::transaction pruned_tx;
|
||||
make_pruned_transaction_from_proposal_v1(tx_proposal,
|
||||
s_view_balance_dev,
|
||||
k_view_dev,
|
||||
pruned_tx);
|
||||
|
||||
//! @TODO: better input number calculation in get_pre_mlsag_hash. possible?
|
||||
pruned_tx.rct_signatures.p.pseudoOuts.resize(pruned_tx.vin.size());
|
||||
|
||||
// see cryptonote::Blockchain::expand_transaction_2()
|
||||
pruned_tx.rct_signatures.message = rct::hash2rct(cryptonote::get_transaction_prefix_hash(pruned_tx));
|
||||
|
||||
hw::device &hwdev = hw::get_device("default");
|
||||
const rct::key signable_tx_hash_k = rct::get_pre_mlsag_hash(pruned_tx.rct_signatures, hwdev);
|
||||
|
||||
signable_tx_hash_out = rct::rct2hash(signable_tx_hash_k);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
void make_pruned_transaction_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
cryptonote::transaction &pruned_tx_out)
|
||||
{
|
||||
// derive enote proposals
|
||||
std::vector<RCTOutputEnoteProposal> output_enote_proposals;
|
||||
encrypted_payment_id_t encrypted_payment_id;
|
||||
get_output_enote_proposals_from_proposal_v1(tx_proposal,
|
||||
s_view_balance_dev,
|
||||
k_view_dev,
|
||||
output_enote_proposals,
|
||||
encrypted_payment_id);
|
||||
|
||||
// collect enotes
|
||||
std::vector<CarrotEnoteV1> enotes;
|
||||
enotes.reserve(output_enote_proposals.size());
|
||||
for (const RCTOutputEnoteProposal &output_enote_proposal : output_enote_proposals)
|
||||
enotes.push_back(output_enote_proposal.enote);
|
||||
|
||||
// serialize tx
|
||||
pruned_tx_out = store_carrot_to_transaction_v1(enotes,
|
||||
tx_proposal.key_images_sorted,
|
||||
tx_proposal.fee,
|
||||
encrypted_payment_id);
|
||||
|
||||
// add extra payload and sort
|
||||
if (!tx_proposal.extra.empty())
|
||||
{
|
||||
std::vector<std::uint8_t> sorted_extra;
|
||||
pruned_tx_out.extra.insert(pruned_tx_out.extra.end(), tx_proposal.extra.cbegin(), tx_proposal.extra.cend());
|
||||
CHECK_AND_ASSERT_THROW_MES(cryptonote::sort_tx_extra(pruned_tx_out.extra, sorted_extra),
|
||||
"make_pruned_transaction_from_proposal_v1: failed to sort tx extra");
|
||||
pruned_tx_out.extra = std::move(sorted_extra);
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
} //namespace carrot
|
||||
@@ -0,0 +1,59 @@
|
||||
// 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 "cryptonote_basic/cryptonote_basic.h"
|
||||
#include "tx_proposal.h"
|
||||
|
||||
//third party headers
|
||||
|
||||
//standard headers
|
||||
|
||||
//forward declarations
|
||||
|
||||
namespace carrot
|
||||
{
|
||||
void get_output_enote_proposals_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
std::vector<RCTOutputEnoteProposal> &output_enote_proposals_out,
|
||||
encrypted_payment_id_t &encrypted_payment_id_out,
|
||||
std::vector<std::pair<bool, std::size_t>> *payment_proposal_order_out = nullptr);
|
||||
|
||||
void make_signable_tx_hash_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
crypto::hash &signable_tx_hash_out);
|
||||
|
||||
void make_pruned_transaction_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
cryptonote::transaction &pruned_tx_out);
|
||||
} //namespace carrot
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024, The Monero Project
|
||||
// Copyright (c) 2025, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
@@ -30,56 +30,23 @@
|
||||
|
||||
//local headers
|
||||
#include "carrot_core/payment_proposal.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "ringct/rctTypes.h"
|
||||
#include "subaddress_index.h"
|
||||
|
||||
//third party headers
|
||||
#include <boost/multiprecision/cpp_int.hpp>
|
||||
|
||||
//standard headers
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
//forward declarations
|
||||
|
||||
namespace carrot
|
||||
{
|
||||
struct CarrotSelectedInput
|
||||
{
|
||||
rct::xmr_amount amount;
|
||||
crypto::key_image key_image;
|
||||
};
|
||||
static inline bool operator==(const CarrotSelectedInput &a, const CarrotSelectedInput &b)
|
||||
{
|
||||
return a.amount == b.amount && a.key_image == b.key_image;
|
||||
}
|
||||
static inline bool operator!=(const CarrotSelectedInput &a, const CarrotSelectedInput &b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
struct CarrotPaymentProposalVerifiableSelfSendV1
|
||||
{
|
||||
CarrotPaymentProposalSelfSendV1 proposal;
|
||||
subaddress_index_extended subaddr_index;
|
||||
};
|
||||
|
||||
using select_inputs_func_t = std::function<void(
|
||||
const boost::multiprecision::uint128_t&, // nominal output sum, w/o fee
|
||||
const std::map<std::size_t, rct::xmr_amount>&, // absolute fee per input count
|
||||
const std::size_t, // number of normal payment proposals
|
||||
const std::size_t, // number of self-send payment proposals
|
||||
std::vector<CarrotSelectedInput>& // selected inputs result
|
||||
)>;
|
||||
|
||||
using carve_fees_and_balance_func_t = std::function<void(
|
||||
const boost::multiprecision::uint128_t&, // input sum amount
|
||||
const rct::xmr_amount, // fee
|
||||
std::vector<CarrotPaymentProposalV1>&, // normal payment proposals [inout]
|
||||
std::vector<CarrotPaymentProposalVerifiableSelfSendV1>& // selfsend payment proposals [inout]
|
||||
)>;
|
||||
|
||||
/**
|
||||
* brief: CarrotTransactionProposalV1
|
||||
*/
|
||||
@@ -94,5 +61,4 @@ struct CarrotTransactionProposalV1
|
||||
|
||||
std::vector<std::uint8_t> extra;
|
||||
};
|
||||
|
||||
} //namespace carrot
|
||||
+3
-94
@@ -27,25 +27,19 @@
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//paired header
|
||||
#include "carrot_tx_builder_utils.h"
|
||||
#include "tx_proposal_utils.h"
|
||||
|
||||
//local headers
|
||||
#include "carrot_core/output_set_finalization.h"
|
||||
#include "carrot_tx_format_utils.h"
|
||||
extern "C"
|
||||
{
|
||||
#include "crypto/crypto-ops.h"
|
||||
}
|
||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||
#include "ringct/rctSigs.h"
|
||||
#include "ringct/rctOps.h"
|
||||
#include "misc_log_ex.h"
|
||||
|
||||
//third party headers
|
||||
|
||||
//standard headers
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
#define MONERO_DEFAULT_LOG_CATEGORY "carrot_impl"
|
||||
#define MONERO_DEFAULT_LOG_CATEGORY "carrot_impl.tpu"
|
||||
|
||||
namespace carrot
|
||||
{
|
||||
@@ -489,89 +483,4 @@ void make_carrot_transaction_proposal_v1_sweep(
|
||||
tx_proposal_out);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
void get_output_enote_proposals_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
std::vector<RCTOutputEnoteProposal> &output_enote_proposals_out,
|
||||
encrypted_payment_id_t &encrypted_payment_id_out,
|
||||
std::vector<std::pair<bool, std::size_t>> *payment_proposal_order_out)
|
||||
{
|
||||
// collect self-sends proposal cores
|
||||
std::vector<CarrotPaymentProposalSelfSendV1> selfsend_payment_proposal_cores;
|
||||
selfsend_payment_proposal_cores.reserve(tx_proposal.selfsend_payment_proposals.size());
|
||||
for (const auto &selfsend_payment_proposal : tx_proposal.selfsend_payment_proposals)
|
||||
selfsend_payment_proposal_cores.push_back(selfsend_payment_proposal.proposal);
|
||||
|
||||
// derive enote proposals
|
||||
get_output_enote_proposals(tx_proposal.normal_payment_proposals,
|
||||
selfsend_payment_proposal_cores,
|
||||
tx_proposal.dummy_encrypted_payment_id,
|
||||
s_view_balance_dev,
|
||||
k_view_dev,
|
||||
tx_proposal.key_images_sorted.at(0),
|
||||
output_enote_proposals_out,
|
||||
encrypted_payment_id_out,
|
||||
payment_proposal_order_out);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
void make_signable_tx_hash_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
crypto::hash &signable_tx_hash_out)
|
||||
{
|
||||
//! @TODO: there's a more efficient way to do this than constructing&serializing a whole cryptonote::transaction
|
||||
// HW devices will need to implement this function to sign tx proposals, and most of these devices don't have a lot of memory
|
||||
|
||||
cryptonote::transaction pruned_tx;
|
||||
make_pruned_transaction_from_proposal_v1(tx_proposal,
|
||||
s_view_balance_dev,
|
||||
k_view_dev,
|
||||
pruned_tx);
|
||||
|
||||
//! @TODO: better input number calculation in get_pre_mlsag_hash. possible?
|
||||
pruned_tx.rct_signatures.p.pseudoOuts.resize(pruned_tx.vin.size());
|
||||
|
||||
hw::device &hwdev = hw::get_device("default");
|
||||
const rct::key signable_tx_hash_k = rct::get_pre_mlsag_hash(pruned_tx.rct_signatures, hwdev);
|
||||
|
||||
signable_tx_hash_out = rct::rct2hash(signable_tx_hash_k);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
void make_pruned_transaction_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
cryptonote::transaction &pruned_tx_out)
|
||||
{
|
||||
// derive enote proposals
|
||||
std::vector<RCTOutputEnoteProposal> output_enote_proposals;
|
||||
encrypted_payment_id_t encrypted_payment_id;
|
||||
get_output_enote_proposals_from_proposal_v1(tx_proposal,
|
||||
s_view_balance_dev,
|
||||
k_view_dev,
|
||||
output_enote_proposals,
|
||||
encrypted_payment_id);
|
||||
|
||||
// collect enotes
|
||||
std::vector<CarrotEnoteV1> enotes;
|
||||
enotes.reserve(output_enote_proposals.size());
|
||||
for (const RCTOutputEnoteProposal &output_enote_proposal : output_enote_proposals)
|
||||
enotes.push_back(output_enote_proposal.enote);
|
||||
|
||||
// serialize tx
|
||||
pruned_tx_out = store_carrot_to_transaction_v1(enotes,
|
||||
tx_proposal.key_images_sorted,
|
||||
tx_proposal.fee,
|
||||
encrypted_payment_id);
|
||||
|
||||
// add extra payload and sort
|
||||
if (!tx_proposal.extra.empty())
|
||||
{
|
||||
std::vector<std::uint8_t> sorted_extra;
|
||||
pruned_tx_out.extra.insert(pruned_tx_out.extra.end(), tx_proposal.extra.cbegin(), tx_proposal.extra.cend());
|
||||
CHECK_AND_ASSERT_THROW_MES(cryptonote::sort_tx_extra(pruned_tx_out.extra, sorted_extra),
|
||||
"make_pruned_transaction_from_proposal_v1: failed to sort tx extra");
|
||||
pruned_tx_out.extra = std::move(sorted_extra);
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
} //namespace carrot
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024, The Monero Project
|
||||
// Copyright (c) 2025, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
@@ -29,10 +29,10 @@
|
||||
#pragma once
|
||||
|
||||
//local headers
|
||||
#include "carrot_tx_builder_types.h"
|
||||
#include "cryptonote_basic/cryptonote_basic.h"
|
||||
#include "tx_proposal.h"
|
||||
|
||||
//third party headers
|
||||
#include <boost/multiprecision/cpp_int.hpp>
|
||||
|
||||
//standard headers
|
||||
#include <cstddef>
|
||||
@@ -41,6 +41,34 @@
|
||||
|
||||
namespace carrot
|
||||
{
|
||||
struct CarrotSelectedInput
|
||||
{
|
||||
rct::xmr_amount amount;
|
||||
crypto::key_image key_image;
|
||||
};
|
||||
static inline bool operator==(const CarrotSelectedInput &a, const CarrotSelectedInput &b)
|
||||
{
|
||||
return a.amount == b.amount && a.key_image == b.key_image;
|
||||
}
|
||||
static inline bool operator!=(const CarrotSelectedInput &a, const CarrotSelectedInput &b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
using select_inputs_func_t = std::function<void(
|
||||
const boost::multiprecision::uint128_t&, // nominal output sum, w/o fee
|
||||
const std::map<std::size_t, rct::xmr_amount>&, // absolute fee per input count
|
||||
const std::size_t, // number of normal payment proposals
|
||||
const std::size_t, // number of self-send payment proposals
|
||||
std::vector<CarrotSelectedInput>& // selected inputs result
|
||||
)>;
|
||||
|
||||
using carve_fees_and_balance_func_t = std::function<void(
|
||||
const boost::multiprecision::uint128_t&, // input sum amount
|
||||
const rct::xmr_amount, // fee
|
||||
std::vector<CarrotPaymentProposalV1>&, // normal payment proposals [inout]
|
||||
std::vector<CarrotPaymentProposalVerifiableSelfSendV1>& // selfsend payment proposals [inout]
|
||||
)>;
|
||||
|
||||
std::uint64_t get_carrot_default_tx_extra_size(const std::size_t n_outputs);
|
||||
|
||||
@@ -84,21 +112,4 @@ void make_carrot_transaction_proposal_v1_sweep(
|
||||
const subaddress_index_extended &change_address_index,
|
||||
CarrotTransactionProposalV1 &tx_proposal_out);
|
||||
|
||||
void get_output_enote_proposals_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
std::vector<RCTOutputEnoteProposal> &output_enote_proposals_out,
|
||||
encrypted_payment_id_t &encrypted_payment_id_out,
|
||||
std::vector<std::pair<bool, std::size_t>> *payment_proposal_order_out = nullptr);
|
||||
|
||||
void make_signable_tx_hash_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
crypto::hash &signable_tx_hash_out);
|
||||
|
||||
void make_pruned_transaction_from_proposal_v1(const CarrotTransactionProposalV1 &tx_proposal,
|
||||
const view_balance_secret_device *s_view_balance_dev,
|
||||
const view_incoming_key_device *k_view_dev,
|
||||
cryptonote::transaction &pruned_tx_out);
|
||||
|
||||
} //namespace carrot
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "string_tools.h"
|
||||
using namespace epee;
|
||||
|
||||
#include "carrot_impl/carrot_tx_format_utils.h"
|
||||
#include "carrot_impl/format_utils.h"
|
||||
#include "common/apply_permutation.h"
|
||||
#include "cryptonote_tx_utils.h"
|
||||
#include "cryptonote_config.h"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "carrot_core/enote_utils.h"
|
||||
#include "carrot_core/lazy_amount_commitment.h"
|
||||
#include "carrot_core/scan.h"
|
||||
#include "carrot_impl/carrot_tx_format_utils.h"
|
||||
#include "carrot_impl/format_utils.h"
|
||||
#include "common/container_helpers.h"
|
||||
#include "crypto/generators.h"
|
||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
#include "carrot_core/config.h"
|
||||
#include "carrot_core/device_ram_borrowed.h"
|
||||
#include "carrot_core/enote_utils.h"
|
||||
#include "carrot_impl/carrot_tx_builder_utils.h"
|
||||
#include "carrot_impl/carrot_tx_format_utils.h"
|
||||
#include "carrot_impl/tx_builder_outputs.h"
|
||||
#include "carrot_impl/format_utils.h"
|
||||
#include "carrot_impl/input_selection.h"
|
||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||
#include "common/container_helpers.h"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#pragma once
|
||||
|
||||
//local headers
|
||||
#include "carrot_impl/carrot_tx_builder_types.h"
|
||||
#include "carrot_impl/tx_proposal_utils.h"
|
||||
#include "wallet2.h"
|
||||
|
||||
//third party headers
|
||||
|
||||
@@ -95,7 +95,7 @@ using namespace epee;
|
||||
#include "device/device_cold.hpp"
|
||||
#include "device_trezor/device_trezor.hpp"
|
||||
#include "net/socks_connect.h"
|
||||
#include "carrot_impl/carrot_tx_format_utils.h"
|
||||
#include "carrot_impl/format_utils.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user