From 059a71fd97e3c879847eff9f1a2a2cdbba61e928 Mon Sep 17 00:00:00 2001 From: sowle Date: Sat, 28 Dec 2024 04:20:50 +0100 Subject: [PATCH] tx hf id: wallet adaptation --- src/currency_core/currency_format_utils.h | 2 +- src/wallet/wallet2.cpp | 28 +++++++++++------------ src/wallet/wallet2.h | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 1503baee..b3cfbeed 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -163,7 +163,7 @@ namespace currency uint64_t expiration_time; crypto::public_key spend_pub_key; // only for validations uint64_t tx_version; - uint8_t tx_hardfork_id = 0; + size_t tx_hardfork_id = 0; uint64_t mode_separate_fee = 0; epee::misc_utils::events_dispatcher* pevents_dispatcher = nullptr; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index ac486389..6dc46bc7 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1162,7 +1162,7 @@ void wallet2::accept_proposal(const crypto::hash& contract_id, uint64_t b_accept //build transaction currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp); - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); prepare_transaction(construct_param, ftp, msc); mark_transfers_as_spent(ftp.selected_transfers, std::string("contract <") + epee::string_tools::pod_to_hex(contract_id) + "> has been accepted with tx <" + epee::string_tools::pod_to_hex(get_transaction_hash(tx)) + ">"); @@ -1182,10 +1182,10 @@ void wallet2::accept_proposal(const crypto::hash& contract_id, uint64_t b_accept *p_acceptance_tx = tx; } //--------------------------------------------------------------------------------- -uint64_t wallet2::get_current_tx_version() +uint64_t wallet2::get_current_tx_version_and_hardfork_id(size_t& tx_hardfork_id) { uint64_t tx_expected_block_height = get_top_block_height() + 1; - return currency::get_tx_version(tx_expected_block_height, this->m_core_runtime_config.hard_forks); + return currency::get_tx_version_and_hardfork_id(tx_expected_block_height, this->m_core_runtime_config.hard_forks, tx_hardfork_id); } //--------------------------------------------------------------------------------- void wallet2::finish_contract(const crypto::hash& contract_id, const std::string& release_type, currency::transaction* p_release_tx /* = nullptr */) @@ -1299,7 +1299,7 @@ void wallet2::request_cancel_contract(const crypto::hash& contract_id, uint64_t construct_param.split_strategy_id = get_current_split_strategy(); currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp); - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); prepare_transaction(construct_param, ftp); currency::transaction tx = AUTO_VAL_INIT(tx); crypto::secret_key sk = AUTO_VAL_INIT(sk); @@ -2393,7 +2393,7 @@ bool wallet2::sweep_bare_unspent_outputs(const currency::account_public_address& currency::finalized_tx ftx{}; currency::finalize_tx_param ftp{}; ftp.pevents_dispatcher = &m_debug_events_dispatcher; - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); if (!prepare_tx_sources(decoys_count, /*use_all_decoys_if_found_less_than_required*/ true, ftp.sources, group.tids)) { @@ -5924,7 +5924,7 @@ void wallet2::build_escrow_release_templates(crypto::hash multisig_id, construct_params.extra.push_back(tsa); { currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp); - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); prepare_transaction(construct_params, ftp); crypto::secret_key sk = AUTO_VAL_INIT(sk); finalize_transaction(ftp, tx_release_template, sk, false); @@ -5941,7 +5941,7 @@ void wallet2::build_escrow_release_templates(crypto::hash multisig_id, construct_params.extra.push_back(tsa); { currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp); - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); prepare_transaction(construct_params, ftp); crypto::secret_key sk = AUTO_VAL_INIT(sk); finalize_transaction(ftp, tx_burn_template, sk, false); @@ -5962,7 +5962,7 @@ void wallet2::build_escrow_cancel_template(crypto::hash multisig_id, construct_tx_param construct_params = AUTO_VAL_INIT(construct_params); currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp); - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); construct_params.fee = it->second.amount() - (ecrow_details.amount_a_pledge + ecrow_details.amount_to_pay + ecrow_details.amount_b_pledge); construct_params.multisig_id = multisig_id; construct_params.split_strategy_id = get_current_split_strategy(); @@ -6045,7 +6045,7 @@ void wallet2::build_escrow_template(const bc_services::contract_private_details& } currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp); - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); prepare_transaction(ctp, ftp); selected_transfers = ftp.selected_transfers; @@ -6181,7 +6181,7 @@ void wallet2::send_escrow_proposal(const bc_services::contract_private_details& ctp.unlock_time = unlock_time; currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp); - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); try { prepare_transaction(ctp, ftp); @@ -6355,7 +6355,7 @@ bool wallet2::build_ionic_swap_template(const wallet_public::ionic_swap_proposal currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp); ftp.mode_separate_fee = ctp.fee; - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); prepare_transaction(ctp, ftp); selected_transfers = ftp.selected_transfers; @@ -6584,7 +6584,7 @@ bool wallet2::accept_ionic_swap_proposal(const wallet_public::ionic_swap_proposa //build transaction currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp); - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); ftp.gen_context = ionic_context.gen_context; prepare_transaction(construct_param, ftp, msc); @@ -8153,7 +8153,7 @@ void wallet2::transfer(construct_tx_param& ctp, TIME_MEASURE_START(prepare_transaction_time); currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp); ftp.pevents_dispatcher = &m_debug_events_dispatcher; - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); if (!prepare_transaction(ctp, ftp)) { result.was_not_prepared = true; @@ -8280,7 +8280,7 @@ void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public } currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp); - ftp.tx_version = this->get_current_tx_version(); + ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id); bool is_hf4 = this->is_in_hardfork_zone(ZANO_HARDFORK_04_ZARCANUM); if (!payment_id.empty()) set_payment_id_to_tx(ftp.attachments, payment_id, is_hf4); diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 8fcced41..cc4d8f53 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -857,7 +857,7 @@ private: bool handle_cancel_proposal(wallet_public::wallet_transfer_info& wti, const bc_services::escrow_cancel_templates_body& ectb, const std::vector& decrypted_attach); bool handle_expiration_list(uint64_t tx_expiration_ts_median); void handle_contract_expirations(uint64_t tx_expiration_ts_median); - uint64_t get_current_tx_version(); + uint64_t get_current_tx_version_and_hardfork_id(size_t& tx_hardfork_id); void change_contract_state(wallet_public::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const wallet_public::wallet_transfer_info& wti) const; void change_contract_state(wallet_public::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const std::string& reason = "internal intention") const; void load_votes_config();