diff --git a/src/carrot_impl/carrot_tx_format_utils.cpp b/src/carrot_impl/carrot_tx_format_utils.cpp index 60e1322..34ca0df 100644 --- a/src/carrot_impl/carrot_tx_format_utils.cpp +++ b/src/carrot_impl/carrot_tx_format_utils.cpp @@ -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 &enotes) + const std::vector &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; } diff --git a/src/carrot_impl/carrot_tx_format_utils.h b/src/carrot_impl/carrot_tx_format_utils.h index 1a1e06e..bf94bad 100644 --- a/src/carrot_impl/carrot_tx_format_utils.h +++ b/src/carrot_impl/carrot_tx_format_utils.h @@ -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 &enotes); + const std::vector &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 - diff --git a/tests/unit_tests/tx_construction_helpers.cpp b/tests/unit_tests/tx_construction_helpers.cpp index 70a176d..1f28cac 100644 --- a/tests/unit_tests/tx_construction_helpers.cpp +++ b/tests/unit_tests/tx_construction_helpers.cpp @@ -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 {