From f8558a020a8e39e18325ea02bd9599dd0ffbb73e Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 8 Nov 2022 00:00:24 +0100 Subject: [PATCH] construct_miner_tx now can use externally generated one time tx key --- src/currency_core/currency_format_utils.cpp | 10 +++++++--- src/currency_core/currency_format_utils.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 555af2c3..aa89a4b5 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -186,8 +186,9 @@ namespace currency const blobdata& extra_nonce /* = blobdata() */, size_t max_outs /* = CURRENCY_MINER_TX_MAX_OUTS */, bool pos /* = false */, - const pos_entry& pe /* = pos_entry() */, - crypto::scalar_t* blinding_masks_sum_ptr /* = nullptr */ + const pos_entry& pe /* = pos_entry() */, // only pe.stake_unlock_time and pe.stake_amount are used now, TODO: consider refactoring -- sowle + crypto::scalar_t* blinding_masks_sum_ptr /* = nullptr */, + const keypair* tx_one_time_key_to_use /* = nullptr */ ) { bool r = false; @@ -250,7 +251,10 @@ namespace currency tx = AUTO_VAL_INIT_T(transaction); tx.version = tx_version; - keypair txkey = keypair::generate(); + keypair txkey_local{}; + if (!tx_one_time_key_to_use) + txkey_local = keypair::generate(); + const keypair& txkey = tx_one_time_key_to_use ? *tx_one_time_key_to_use : txkey_local; add_tx_pub_key_to_extra(tx, txkey.pub); if (extra_nonce.size()) if (!add_tx_extra_userdata(tx, extra_nonce)) diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 58060643..d2cd4592 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -244,7 +244,8 @@ namespace currency size_t max_outs = CURRENCY_MINER_TX_MAX_OUTS, bool pos = false, const pos_entry& pe = pos_entry(), - crypto::scalar_t* blinding_masks_sum_ptr = nullptr); + crypto::scalar_t* blinding_masks_sum_ptr = nullptr, + const keypair* tx_one_time_key_to_use = nullptr); //--------------------------------------------------------------- uint64_t get_string_uint64_hash(const std::string& str); bool construct_tx_out(const tx_destination_entry& de, const crypto::secret_key& tx_sec_key, size_t output_index, transaction& tx, std::set& deriv_cache, const account_keys& self, crypto::scalar_t& out_blinding_mask, finalized_tx& result, uint8_t tx_outs_attr = CURRENCY_TO_KEY_OUT_RELAXED);