From c1df77c81ae9b94f76a49661c0835ce327260453 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 19 Aug 2026 16:26:04 +0200 Subject: [PATCH] cryptonote_basic: remove dead code --- src/cryptonote_basic/account.h | 3 - .../account_boost_serialization.h | 1 - src/cryptonote_basic/account_generators.h | 71 ------------------- src/cryptonote_basic/cryptonote_basic.h | 4 -- .../cryptonote_format_utils.cpp | 27 ------- .../cryptonote_format_utils.h | 9 --- src/cryptonote_basic/hardfork.h | 1 - src/cryptonote_basic/merge_mining.cpp | 10 --- src/cryptonote_basic/merge_mining.h | 1 - 9 files changed, 127 deletions(-) delete mode 100644 src/cryptonote_basic/account_generators.h diff --git a/src/cryptonote_basic/account.h b/src/cryptonote_basic/account.h index 71b5b64a1..6242f3866 100644 --- a/src/cryptonote_basic/account.h +++ b/src/cryptonote_basic/account.h @@ -109,9 +109,6 @@ namespace cryptonote uint64_t get_createtime() const { return m_creation_timestamp; } void set_createtime(uint64_t val) { m_creation_timestamp = val; } - bool load(const std::string& file_path); - bool store(const std::string& file_path); - void forget_spend_key(); void set_spend_key(const crypto::secret_key& spend_secret_key); const std::vector &get_multisig_keys() const { return m_keys.m_multisig_keys; } diff --git a/src/cryptonote_basic/account_boost_serialization.h b/src/cryptonote_basic/account_boost_serialization.h index eed280d2c..adf8da7f4 100644 --- a/src/cryptonote_basic/account_boost_serialization.h +++ b/src/cryptonote_basic/account_boost_serialization.h @@ -33,7 +33,6 @@ #include "account.h" #include "cryptonote_boost_serialization.h" -//namespace cryptonote { namespace boost { namespace serialization diff --git a/src/cryptonote_basic/account_generators.h b/src/cryptonote_basic/account_generators.h deleted file mode 100644 index 00a31ae82..000000000 --- a/src/cryptonote_basic/account_generators.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2021-2024, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#pragma once - -#include "crypto/crypto.h" -#include "crypto/generators.h" - - -namespace cryptonote -{ - -enum class account_generator_era : unsigned char -{ - unknown = 0, - cryptonote = 1 //and ringct -}; - -struct account_generators -{ - crypto::public_key m_primary; //e.g. for spend key - crypto::public_key m_secondary; //e.g. for view key -}; - -inline crypto::public_key get_primary_generator(const account_generator_era era) -{ - if (era == account_generator_era::cryptonote) - return crypto::get_G(); - else - return crypto::null_pkey; //error -} - -inline crypto::public_key get_secondary_generator(const account_generator_era era) -{ - if (era == account_generator_era::cryptonote) - return crypto::get_G(); - else - return crypto::null_pkey; //error -} - -inline account_generators get_account_generators(const account_generator_era era) -{ - return account_generators{get_primary_generator(era), get_secondary_generator(era)}; -} - -} //namespace cryptonote diff --git a/src/cryptonote_basic/cryptonote_basic.h b/src/cryptonote_basic/cryptonote_basic.h index 826110931..4639da3b3 100644 --- a/src/cryptonote_basic/cryptonote_basic.h +++ b/src/cryptonote_basic/cryptonote_basic.h @@ -52,9 +52,6 @@ namespace cryptonote { - typedef std::vector ring_signature; - - /* outputs */ struct txout_to_script @@ -152,7 +149,6 @@ namespace cryptonote typedef boost::variant txout_target_v; - //typedef std::pair out_t; struct tx_out { uint64_t amount; diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp index 759e166d3..803e24854 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -51,10 +51,6 @@ using namespace crypto; static std::atomic default_decimal_point(CRYPTONOTE_DISPLAY_DECIMAL_POINT); -static std::atomic tx_hashes_calculated_count(0); -static std::atomic tx_hashes_cached_count(0); -static std::atomic block_hashes_calculated_count(0); -static std::atomic block_hashes_cached_count(0); #define CHECK_AND_ASSERT_THROW_MES_L1(expr, message) {if(!(expr)) {MWARNING(message); throw std::runtime_error(message);}} @@ -955,14 +951,6 @@ namespace cryptonote : boost::optional(); } //--------------------------------------------------------------- - std::string short_hash_str(const crypto::hash& h) - { - std::string res = string_tools::pod_to_hex(h); - CHECK_AND_ASSERT_MES(res.size() == 64, res, "wrong hash256 with string_tools::pod_to_hex conversion"); - auto erased_pos = res.erase(8, 48); - res.insert(8, "...."); - return res; - } //--------------------------------------------------------------- void set_tx_out(const uint64_t amount, const crypto::public_key& output_public_key, const bool use_view_tags, const crypto::view_tag& view_tag, tx_out& out) { @@ -1327,11 +1315,9 @@ namespace cryptonote CHECK_AND_ASSERT_THROW_MES(!calculate_transaction_prunable_hash(t, blobdata, res) || t.hash == res, "tx hash cash integrity failure"); #endif res = t.prunable_hash; - ++tx_hashes_cached_count; return res; } - ++tx_hashes_calculated_count; CHECK_AND_ASSERT_THROW_MES(calculate_transaction_prunable_hash(t, blobdata, res), "Failed to calculate tx prunable hash"); t.set_prunable_hash(res); return res; @@ -1441,10 +1427,8 @@ namespace cryptonote } *blob_size = t.blob_size; } - ++tx_hashes_cached_count; return true; } - ++tx_hashes_calculated_count; bool ret = calculate_transaction_hash(t, res, blob_size); if (!ret) return false; @@ -1523,10 +1507,8 @@ namespace cryptonote CHECK_AND_ASSERT_THROW_MES(!calculate_block_hash(b, res) || b.hash == res, "block hash cash integrity failure"); #endif res = b.hash; - ++block_hashes_cached_count; return true; } - ++block_hashes_calculated_count; bool ret = calculate_block_hash(b, res); if (!ret) return false; @@ -1571,7 +1553,6 @@ namespace cryptonote if (block_hash) { calculate_block_hash(b, *block_hash, &b_blob); - ++block_hashes_calculated_count; b.set_hash(*block_hash); } return true; @@ -1695,14 +1676,6 @@ namespace cryptonote return amount < 10; // are we left with 1 leading digit? } //--------------------------------------------------------------- - void get_hash_stats(uint64_t &tx_hashes_calculated, uint64_t &tx_hashes_cached, uint64_t &block_hashes_calculated, uint64_t & block_hashes_cached) - { - tx_hashes_calculated = tx_hashes_calculated_count; - tx_hashes_cached = tx_hashes_cached_count; - block_hashes_calculated = block_hashes_calculated_count; - block_hashes_cached = block_hashes_cached_count; - } - //--------------------------------------------------------------- crypto::secret_key encrypt_key(crypto::secret_key key, const epee::wipeable_string &passphrase) { crypto::hash hash; diff --git a/src/cryptonote_basic/cryptonote_format_utils.h b/src/cryptonote_basic/cryptonote_format_utils.h index 8d019e386..d1f8187d1 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.h +++ b/src/cryptonote_basic/cryptonote_format_utils.h @@ -110,7 +110,6 @@ namespace cryptonote void get_blob_hash(const blobdata_ref& blob, crypto::hash& res); crypto::hash get_blob_hash(const blobdata& blob); crypto::hash get_blob_hash(const blobdata_ref& blob); - std::string short_hash_str(const crypto::hash& h); crypto::hash get_transaction_hash(const transaction& t); bool get_transaction_hash(const transaction& t, crypto::hash& res); @@ -154,13 +153,6 @@ namespace cryptonote uint64_t round_money_up(uint64_t amount, unsigned significant_digits); std::string round_money_up(const std::string &amount, unsigned significant_digits); //--------------------------------------------------------------- - template - bool t_serializable_object_from_blob(t_object& to, const blobdata& b_blob) - { - binary_archive ba{epee::strspan(b_blob)}; - bool r = ::serialization::serialize(ba, to); - return r; - } //--------------------------------------------------------------- template bool t_serializable_object_to_blob(const t_object& to, blobdata& b_blob) @@ -267,7 +259,6 @@ namespace cryptonote const uint8_t major_version, const crypto::hash &seed_hash); bool is_valid_decomposed_amount(uint64_t amount); - void get_hash_stats(uint64_t &tx_hashes_calculated, uint64_t &tx_hashes_cached, uint64_t &block_hashes_calculated, uint64_t & block_hashes_cached); crypto::secret_key encrypt_key(crypto::secret_key key, const epee::wipeable_string &passphrase); crypto::secret_key decrypt_key(crypto::secret_key key, const epee::wipeable_string &passphrase); diff --git a/src/cryptonote_basic/hardfork.h b/src/cryptonote_basic/hardfork.h index a9e5a63ab..097d47d34 100644 --- a/src/cryptonote_basic/hardfork.h +++ b/src/cryptonote_basic/hardfork.h @@ -229,7 +229,6 @@ namespace cryptonote /** * @brief returns the size of the voting window in blocks */ - uint64_t get_window_size() const { return window_size; } /** * @brief returns info for all known hard forks diff --git a/src/cryptonote_basic/merge_mining.cpp b/src/cryptonote_basic/merge_mining.cpp index 82cf66462..affebf19d 100644 --- a/src/cryptonote_basic/merge_mining.cpp +++ b/src/cryptonote_basic/merge_mining.cpp @@ -60,16 +60,6 @@ uint32_t get_aux_slot(const crypto::hash &id, uint32_t nonce, uint32_t n_aux_cha return SWAP32LE(v) % n_aux_chains; } //--------------------------------------------------------------- -uint32_t get_path_from_aux_slot(uint32_t slot, uint32_t n_aux_chains) -{ - CHECK_AND_ASSERT_THROW_MES(n_aux_chains > 0, "n_aux_chains is 0"); - CHECK_AND_ASSERT_THROW_MES(slot < n_aux_chains, "slot >= n_aux_chains"); - - uint32_t path = 0; - CHECK_AND_ASSERT_THROW_MES(tree_path(n_aux_chains, slot, &path), "Failed to get path from aux slot"); - return path; -} -//--------------------------------------------------------------- uint64_t encode_mm_depth(uint32_t n_aux_chains, uint32_t nonce) { CHECK_AND_ASSERT_THROW_MES(n_aux_chains > 0, "n_aux_chains is 0"); diff --git a/src/cryptonote_basic/merge_mining.h b/src/cryptonote_basic/merge_mining.h index ec82cd01b..b8e1a7009 100644 --- a/src/cryptonote_basic/merge_mining.h +++ b/src/cryptonote_basic/merge_mining.h @@ -34,7 +34,6 @@ namespace cryptonote { uint32_t get_aux_slot(const crypto::hash &id, uint32_t nonce, uint32_t n_aux_chains); - uint32_t get_path_from_aux_slot(uint32_t slot, uint32_t n_aux_chains); uint64_t encode_mm_depth(uint32_t n_aux_chains, uint32_t nonce); bool decode_mm_depth(uint64_t depth, uint32_t &n_aux_chains, uint32_t &nonce); }