carrot_impl: make_single_enote_carrot_coinbase_transaction_v1

This commit is contained in:
jeffro256
2025-04-29 15:27:01 -05:00
committed by akildemir
parent 4989c4cece
commit d4a61dbb66
2 changed files with 36 additions and 0 deletions

View File

@@ -31,6 +31,7 @@
//local headers
#include "carrot_core/enote_utils.h"
#include "carrot_core/payment_proposal.h"
#include "common/container_helpers.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "cryptonote_config.h"
@@ -395,6 +396,28 @@ cryptonote::transaction store_carrot_to_coinbase_transaction_v1(
return tx;
}
//-------------------------------------------------------------------------------------------------------------------
cryptonote::transaction make_single_enote_carrot_coinbase_transaction_v1(const CarrotDestinationV1 &destination,
const rct::xmr_amount block_reward,
const std::uint64_t block_index,
const cryptonote::blobdata &extra_nonce)
{
CHECK_AND_ASSERT_THROW_MES(!destination.is_subaddress,
"make_single_enote_carrot_coinbase_transaction_v1: subaddress are not allowed in miner transactions");
CHECK_AND_ASSERT_THROW_MES(destination.payment_id == null_payment_id,
"make_single_enote_carrot_coinbase_transaction_v1: integrated addresses are not allowed in miner transactions");
const CarrotPaymentProposalV1 payment_proposal{
.destination = destination,
.amount = block_reward,
.randomness = gen_janus_anchor()
};
std::vector<CarrotCoinbaseEnoteV1> enotes(1);
get_coinbase_output_proposal_v1(payment_proposal, block_index, enotes.front());
return store_carrot_to_coinbase_transaction_v1(enotes, extra_nonce);
}
//-------------------------------------------------------------------------------------------------------------------
bool try_load_carrot_coinbase_enote_from_transaction_v1(const cryptonote::transaction &tx,
const epee::span<const mx25519_pubkey> enote_ephemeral_pubkeys,
const std::size_t local_output_index,

View File

@@ -30,6 +30,7 @@
//local headers
#include "carrot_core/carrot_enote_types.h"
#include "carrot_core/destination.h"
#include "cryptonote_basic/blobdatatype.h"
#include "cryptonote_basic/cryptonote_basic.h"
#include "cryptonote_basic/tx_extra.h"
@@ -134,6 +135,18 @@ bool try_load_carrot_from_transaction_v1(const cryptonote::transaction &tx,
cryptonote::transaction store_carrot_to_coinbase_transaction_v1(
const std::vector<CarrotCoinbaseEnoteV1> &enotes,
const cryptonote::blobdata &extra_nonce);
/**
* brief: make_single_enote_carrot_coinbase_transaction_v1 - store one coinbase Carrot enote to a cryptonote::transaction
* param: destination -
* param: block_reward -
* param: block_index -
* param: extra_nonce -
* return: a full coinbase transaction containing given Carrot information
*/
cryptonote::transaction make_single_enote_carrot_coinbase_transaction_v1(const CarrotDestinationV1 &destination,
const rct::xmr_amount block_reward,
const std::uint64_t block_index,
const cryptonote::blobdata &extra_nonce);
/**
* brief: try_load_carrot_coinbase_enote_from_transaction_v1 - load one coinbase Carrot enote from a cryptonote::transaction
* param: tx -