What changed, and why it matters
This commit simply deletes unused code, comments, and internal statistics counters from the Monero codebase. It does not change any active behavior, fix a bug, or alter how the software processes transactions, blocks, or keys. There is no security issue here.
No security action needed. Treat as routine code cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes dead/unreferenced code: the unused account_generators.h header, unused typedef ring_signature, unused short_hash_str and get_hash_stats helpers, unused hash cache counters, an unused template t_serializable_object_from_blob, an unused hardfork getter, and an unused merge_mining path helper. No call sites are modified to compensate for removed functionality, indicating the code was genuinely unused. No security-sensitive logic is changed.
Changed components
src/cryptonote_basic/account.hsrc/cryptonote_basic/account_boost_serialization.hsrc/cryptonote_basic/account_generators.hsrc/cryptonote_basic/cryptonote_basic.hsrc/cryptonote_basic/cryptonote_format_utils.cppsrc/cryptonote_basic/cryptonote_format_utils.hsrc/cryptonote_basic/hardfork.hsrc/cryptonote_basic/merge_mining.cppsrc/cryptonote_basic/merge_mining.hInspect captured patch +0 / −127
diff --git a/src/cryptonote_basic/account.h b/src/cryptonote_basic/account.h
index 71b5b64..6242f38 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<crypto::secret_key> &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 eed280d..adf8da7 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 00a31ae..0000000
--- 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 8261109..4639da3 100644
--- a/src/cryptonote_basic/cryptonote_basic.h
+++ b/src/cryptonote_basic/cryptonote_basic.h
@@ -52,9 +52,6 @@
namespace cryptonote
{
- typedef std::vector<crypto::signature> ring_signature;
-
-
/* outputs */
struct txout_to_script
@@ -152,7 +149,6 @@ namespace cryptonote
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_to_key, txout_to_tagged_key> txout_target_v;
- //typedef std::pair<uint64_t, txout> 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 759e166..803e248 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<unsigned int> default_decimal_point(CRYPTONOTE_DISPLAY_DECIMAL_POINT);
-static std::atomic<uint64_t> tx_hashes_calculated_count(0);
-static std::atomic<uint64_t> tx_hashes_cached_count(0);
-static std::atomic<uint64_t> block_hashes_calculated_count(0);
-static std::atomic<uint64_t> 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<crypto::view_tag>();
}
//---------------------------------------------------------------
- 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 8d019e3..d1f8187 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<class t_object>
- bool t_serializable_object_from_blob(t_object& to, const blobdata& b_blob)
- {
- binary_archive<false> ba{epee::strspan<std::uint8_t>(b_blob)};
- bool r = ::serialization::serialize(ba, to);
- return r;
- }
//---------------------------------------------------------------
template<class t_object>
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 a9e5a63..097d47d 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 82cf664..affebf1 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 ec82cd0..b8e1a70 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);
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.