carrot_impl: store extra_nonce to coinbase txs

This commit is contained in:
jeffro256
2025-04-20 17:26:13 -05:00
committed by akildemir
parent 70bde9353b
commit b7ea8d0b22
3 changed files with 14 additions and 6 deletions

View File

@@ -350,7 +350,8 @@ 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 std::vector<CarrotCoinbaseEnoteV1> &enotes,
const cryptonote::blobdata &extra_nonce)
{
const size_t nouts = enotes.size();
const std::uint64_t block_index = enotes.at(0).block_index;
@@ -383,8 +384,13 @@ cryptonote::transaction store_carrot_to_coinbase_transaction_v1(
//ephemeral pubkeys: D_e
store_carrot_ephemeral_pubkeys_to_extra(enotes, tx.extra);
//we don't need to sort tx_extra since we only added one field
//if you add more tx_extra fields here in the future, then please sort <3
//add extra_nonce to tx_extra
CHECK_AND_ASSERT_THROW_MES(cryptonote::add_extra_nonce_to_tx_extra(tx.extra, extra_nonce),
"store_carrot_to_coinbase_transaction_v1: failed to add extra nonce to tx_extra");
// sort tx_extra
CHECK_AND_ASSERT_THROW_MES(cryptonote::sort_tx_extra(tx.extra, tx.extra),
"store_carrot_to_coinbase_transaction_v1: failed to sort tx_extra");
return tx;
}

View File

@@ -30,6 +30,7 @@
//local headers
#include "carrot_core/carrot_enote_types.h"
#include "cryptonote_basic/blobdatatype.h"
#include "cryptonote_basic/cryptonote_basic.h"
#include "cryptonote_basic/tx_extra.h"
@@ -127,11 +128,12 @@ bool try_load_carrot_from_transaction_v1(const cryptonote::transaction &tx,
/**
* brief: store_carrot_to_coinbase_transaction_v1 - store coinbase Carrot info to a cryptonote::transaction
* param: enotes -
* param: block_index -
* param: extra_nonce -
* return: a full coinbase transaction containing given Carrot information
*/
cryptonote::transaction store_carrot_to_coinbase_transaction_v1(
const std::vector<CarrotCoinbaseEnoteV1> &enotes);
const std::vector<CarrotCoinbaseEnoteV1> &enotes,
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 -

View File

@@ -74,7 +74,7 @@ bool construct_miner_tx_fake_reward_1out(const size_t height,
height,
coinbase_enotes);
tx = carrot::store_carrot_to_coinbase_transaction_v1(coinbase_enotes);
tx = carrot::store_carrot_to_coinbase_transaction_v1(coinbase_enotes, "");
}
else // !is_carrot
{