From a45d63bdf811746d86138e39744d31994b0a5a2a Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Wed, 7 Feb 2024 18:18:30 +0400 Subject: [PATCH] added fee bruning --- src/currency_core/blockchain_storage.cpp | 11 ++++++++++- src/currency_core/currency_format_utils.cpp | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 1c85df9f..5278ebb2 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -1345,7 +1345,12 @@ bool blockchain_storage::validate_miner_transaction(const block& b, return false; } - uint64_t block_reward = base_reward + fee; + uint64_t block_reward = base_reward; + // we burn fees after hardfork 4 + if (b.miner_tx.version < TRANSACTION_VERSION_POST_HF4) + { + block_reward += fee; + } crypto::hash tx_id_for_post_hf4_era = b.miner_tx.version > TRANSACTION_VERSION_PRE_HF4 ? get_transaction_hash(b.miner_tx) : null_hash; if (!check_tx_balance(b.miner_tx, tx_id_for_post_hf4_era, block_reward)) @@ -6663,6 +6668,10 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt return false; } bei.already_generated_coins = already_generated_coins - burned_coins + base_reward; + if (bei.bl.miner_tx.version >= TRANSACTION_VERSION_POST_HF4) + { + bei.already_generated_coins -= fee_summary; + } auto blocks_index_ptr = m_db_blocks_index.get(id); if (blocks_index_ptr) diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 27cf9417..bb8f9e11 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -380,7 +380,13 @@ namespace currency LOG_ERROR("Block is too big"); return false; } - uint64_t block_reward = block_reward_without_fee + fee; + + uint64_t block_reward = block_reward_without_fee; + // burn fees after HF4 + if (tx_version < TRANSACTION_VERSION_POST_HF4) + { + block_reward += fee; + } if (!destinations.size()) {