Merge bitcoin/bitcoin#36509: refactor: remove more dead code
What changed, and why it matters
This commit is a routine cleanup that removes unused code, unused compiler warning flags, and stale declarations from Bitcoin Core. None of the changes alter active behavior, fix bugs, or introduce security-sensitive logic. It is purely a refactoring and build-hygiene change.
No security action required. Treat as normal refactoring; standard review and CI testing are sufficient.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The merge commit removes dead code across the Qt GUI, kernel, policy, addrman, logging, netbase, script, fuzz tests, and build system. Examples include unused methods (e.g., ClientModel::getNumBlocks, BitcoinAmountField::SetMaxValue), unused constants (EXTRA_DESCENDANT_TX_SIZE_LIMIT, COLOR_BLACK), unused type aliases (BinarySemaphoreGrant), and enabling additional -Wunused-* compiler warnings. The diff shows only deletions and reordering of warning flags; no functional code paths are modified.
Changed components
src/qt (GUI dead code removal)src/kernel/mempool_limits.hsrc/addrman.cppsrc/logging.hsrc/netbase.hsrc/policy/policy.hsrc/script/signingprovider.h/cppsrc/test/fuzz/utilsrc/test/kernel/test_kernel.cppsrc/wallet/test/util.hCMakeLists.txt (warning flags)Inspect captured patch +4 / −129
### CMakeLists.txt
@@ -480,9 +480,11 @@ else()
try_append_cxx_flags("-Wthread-safety-pointer" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wloop-analysis" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wredundant-decls" TARGET warn_interface SKIP_LINK)
- try_append_cxx_flags("-Wunused-member-function" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wunused-const-variable" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wunused-exception-parameter" TARGET warn_interface SKIP_LINK)
+ try_append_cxx_flags("-Wunused-macros" TARGET warn_interface SKIP_LINK)
+ try_append_cxx_flags("-Wunused-member-function" TARGET warn_interface SKIP_LINK)
+ try_append_cxx_flags("-Wunused-template" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wdate-time" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wconditional-uninitialized" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wduplicated-branches" TARGET warn_interface SKIP_LINK)
### src/addresstype.cpp
@@ -18,7 +18,6 @@
typedef std::vector<unsigned char> valtype;
ScriptHash::ScriptHash(const CScript& in) : BaseHash(Hash160(in)) {}
-ScriptHash::ScriptHash(const CScriptID& in) : BaseHash{in} {}
PKHash::PKHash(const CPubKey& pubkey) : BaseHash(pubkey.GetID()) {}
PKHash::PKHash(const CKeyID& pubkey_id) : BaseHash(pubkey_id) {}
### src/addresstype.h
@@ -65,7 +65,6 @@ struct ScriptHash : public BaseHash<uint160>
explicit ScriptHash(const uint160& hash) : BaseHash(hash) {}
explicit ScriptHash(const CScript& script);
- explicit ScriptHash(const CScriptID& script);
};
CScriptID ToScriptID(const ScriptHash& script_hash);
### src/addrman.cpp
@@ -1278,7 +1278,6 @@ void AddrMan::Unserialize(Stream& s_)
// explicit instantiation
template void AddrMan::Serialize(HashedSourceWriter<AutoFile>&) const;
template void AddrMan::Serialize(DataStream&) const;
-template void AddrMan::Unserialize(AutoFile&);
template void AddrMan::Unserialize(HashVerifier<AutoFile>&);
template void AddrMan::Unserialize(DataStream&);
template void AddrMan::Unserialize(HashVerifier<DataStream>&);
### src/ipc/test/ipc_test.h
@@ -20,7 +20,6 @@ class FooImplementation
CTransactionRef passTransaction(CTransactionRef t) { return t; }
std::vector<CTransactionRef> passTransactions(std::vector<CTransactionRef> t) { return t; }
std::vector<char> passVectorChar(std::vector<char> v) { return v; }
- BlockValidationState passBlockState(BlockValidationState s) { return s; }
CScript passScript(CScript s) { return s; }
};
### src/kernel/mempool_limits.h
@@ -24,15 +24,6 @@ struct MemPoolLimits {
int64_t ancestor_count{DEFAULT_ANCESTOR_LIMIT};
//! The maximum allowed number of transactions in a package including the entry and its descendants.
int64_t descendant_count{DEFAULT_DESCENDANT_LIMIT};
-
- /**
- * @return MemPoolLimits with all the limits set to the maximum
- */
- static constexpr MemPoolLimits NoLimits()
- {
- int64_t no_limit{std::numeric_limits<int64_t>::max()};
- return {std::numeric_limits<unsigned>::max(), no_limit, no_limit, no_limit};
- }
};
} // namespace kernel
### src/logging.h
@@ -232,11 +232,6 @@ namespace BCLog {
STDLOCK(m_cs);
m_category_log_levels = levels;
}
- void AddCategoryLogLevel(LogFlags category, Level level) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
- {
- STDLOCK(m_cs);
- m_category_log_levels[category] = level;
- }
bool SetCategoryLogLevel(std::string_view category_str, std::string_view level_str) EXCLUSIVE_LOCKS_REQUIRED(!m_cs);
Level LogLevel() const { return m_log_level.load(); }
### src/netbase.h
@@ -76,12 +76,6 @@ class Proxy
return proxy.IsValid();
}
- sa_family_t GetFamily() const
- {
- if (m_is_unix_socket) return AF_UNIX;
- return proxy.GetSAFamily();
- }
-
std::string ToString() const
{
if (m_is_unix_socket) return m_unix_socket_path;
### src/policy/policy.h
@@ -82,12 +82,6 @@ inline constexpr bool DEFAULT_ACCEPT_DATACARRIER = true;
* Default setting for -datacarriersize in vbytes.
*/
inline constexpr unsigned int MAX_OP_RETURN_RELAY = MAX_STANDARD_TX_WEIGHT / WITNESS_SCALE_FACTOR;
-/**
- * An extra transaction can be added to a package, as long as it only has one
- * ancestor and is no larger than this. Not really any reason to make this
- * configurable as it doesn't materially change DoS parameters.
- */
-inline constexpr unsigned int EXTRA_DESCENDANT_TX_SIZE_LIMIT{10'000};
/**
* Maximum number of ephemeral dust outputs allowed.
### src/qt/addressbookpage.h
@@ -78,9 +78,6 @@ private Q_SLOTS:
void contextualMenu(const QPoint &point);
/** New entry/entries were added to address table */
void selectNewAddress(const QModelIndex &parent, int begin, int /*end*/);
-
-Q_SIGNALS:
- void sendCoins(QString addr);
};
#endif // BITCOIN_QT_ADDRESSBOOKPAGE_H
### src/qt/bitcoinamountfield.cpp
@@ -85,11 +85,6 @@ class AmountSpinBox: public QAbstractSpinBox
m_min_amount = value;
}
- void SetMaxValue(const CAmount& value)
- {
- m_max_amount = value;
- }
-
void stepBy(int steps) override
{
bool valid = false;
@@ -311,16 +306,6 @@ void BitcoinAmountField::SetMinValue(const CAmount& value)
amount->SetMinValue(value);
}
-void BitcoinAmountField::SetMaxValue(const CAmount& value)
-{
- amount->SetMaxValue(value);
-}
-
-void BitcoinAmountField::setReadOnly(bool fReadOnly)
-{
- amount->setReadOnly(fReadOnly);
-}
-
void BitcoinAmountField::unitChanged(int idx)
{
// Use description tooltip for current unit for the combobox
### src/qt/bitcoinamountfield.h
@@ -38,15 +38,9 @@ class BitcoinAmountField: public QWidget
/** Set the minimum value in satoshis **/
void SetMinValue(const CAmount& value);
- /** Set the maximum value in satoshis **/
- void SetMaxValue(const CAmount& value);
-
/** Set single step in satoshis **/
void setSingleStep(const CAmount& step);
- /** Make read-only **/
- void setReadOnly(bool fReadOnly);
-
/** Mark current value as invalid in UI. */
void setValid(bool valid);
/** Perform input validation, mark field as invalid if entered value is not valid. */
### src/qt/bitcoingui.cpp
@@ -863,13 +863,6 @@ void BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
if (wallet_model) setCurrentWallet(wallet_model);
}
-void BitcoinGUI::removeAllWallets()
-{
- if(!walletFrame)
- return;
- setWalletActionsEnabled(false);
- walletFrame->removeAllWallets();
-}
#endif // ENABLE_WALLET
void BitcoinGUI::setWalletActionsEnabled(bool enabled)
### src/qt/bitcoingui.h
@@ -90,7 +90,6 @@ class BitcoinGUI : public QMainWindow
*/
void addWallet(WalletModel* walletModel);
void removeWallet(WalletModel* walletModel);
- void removeAllWallets();
#endif // ENABLE_WALLET
bool enableWallet = false;
### src/qt/clientmodel.cpp
@@ -2,8 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <bitcoin-build-config.h> // IWYU pragma: keep
-
#include <qt/clientmodel.h>
#include <qt/bantablemodel.h>
@@ -129,15 +127,6 @@ std::map<CNetAddr, LocalServiceInfo> ClientModel::getNetLocalAddresses() const
return m_node.getNetLocalAddresses();
}
-
-int ClientModel::getNumBlocks() const
-{
- if (m_cached_num_blocks == -1) {
- m_cached_num_blocks = m_node.getNumBlocks();
- }
- return m_cached_num_blocks;
-}
-
uint256 ClientModel::getBestBlockHash()
{
uint256 tip{WITH_LOCK(m_cached_tip_mutex, return m_cached_tip_blocks)};
@@ -203,11 +192,6 @@ QString ClientModel::formatSubVersion() const
return QString::fromStdString(strSubVersion);
}
-bool ClientModel::isReleaseVersion() const
-{
- return CLIENT_VERSION_IS_RELEASE;
-}
-
QString ClientModel::formatClientStartupTime() const
{
return QDateTime::currentDateTime().addSecs(-TicksSeconds(GetUptime())).toString();
@@ -230,7 +214,6 @@ void ClientModel::TipChanged(SynchronizationState sync_state, interfaces::BlockT
cachedBestHeaderHeight = tip.block_height;
cachedBestHeaderTime = tip.block_time;
} else if (synctype == SyncType::BLOCK_SYNC) {
- m_cached_num_blocks = tip.block_height;
WITH_LOCK(m_cached_tip_mutex, m_cached_tip_blocks = tip.block_hash;);
}
### src/qt/clientmodel.h
@@ -72,7 +72,6 @@ class ClientModel : public QObject
//! Return number of connections, default is in- and outbound (total)
int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
std::map<CNetAddr, LocalServiceInfo> getNetLocalAddresses() const;
- int getNumBlocks() const;
uint256 getBestBlockHash() EXCLUSIVE_LOCKS_REQUIRED(!m_cached_tip_mutex);
int getHeaderTipHeight() const;
int64_t getHeaderTipTime() const;
@@ -84,7 +83,6 @@ class ClientModel : public QObject
QString formatFullVersion() const;
QString formatSubVersion() const;
- bool isReleaseVersion() const;
QString formatClientStartupTime() const;
QString dataDir() const;
QString blocksDir() const;
@@ -94,7 +92,6 @@ class ClientModel : public QObject
// caches for the best header: hash, number of blocks and block time
mutable std::atomic<int> cachedBestHeaderHeight;
mutable std::atomic<int64_t> cachedBestHeaderTime;
- mutable std::atomic<int> m_cached_num_blocks{-1};
Mutex m_cached_tip_mutex;
uint256 m_cached_tip_blocks GUARDED_BY(m_cached_tip_mutex){};
### src/qt/guiconstants.h
@@ -35,8 +35,6 @@ inline constexpr bool DEFAULT_SPLASHSCREEN = true;
#define COLOR_BAREADDRESS QColor(140, 140, 140)
/* Transaction list -- TX status decoration - danger, tx needs attention */
#define COLOR_TX_STATUS_DANGER QColor(200, 100, 100)
-/* Transaction list -- TX status decoration - default color */
-#define COLOR_BLACK QColor(0, 0, 0)
/* Tooltips longer than this (in characters) are converted into rich text,
so that they can be word-wrapped.
### src/qt/optionsdialog.h
@@ -69,7 +69,6 @@ private Q_SLOTS:
void updateDefaultProxyNets();
Q_SIGNALS:
- void proxyIpChecks(QValidatedLineEdit *pUiProxyIp, uint16_t nProxyPort);
void quitOnReset();
private:
### src/qt/peertablemodel.h
@@ -14,8 +14,6 @@
#include <QStringList>
#include <QVariant>
-class PeerTablePriv;
-
namespace interfaces {
class Node;
}
### src/qt/qvaluecombobox.cpp
@@ -20,11 +20,6 @@ void QValueComboBox::setValue(const QVariant &value)
setCurrentIndex(findData(value, role));
}
-void QValueComboBox::setRole(int _role)
-{
- this->role = _role;
-}
-
void QValueComboBox::handleSelectionChanged(int idx)
{
Q_EMIT valueChanged();
### src/qt/qvaluecombobox.h
@@ -21,9 +21,6 @@ class QValueComboBox : public QComboBox
QVariant value() const;
void setValue(const QVariant &value);
- /** Specify model role to use as ordinal value (defaults to Qt::UserRole) */
- void setRole(int role);
-
Q_SIGNALS:
void valueChanged();
### src/qt/trafficgraphwidget.cpp
@@ -37,8 +37,6 @@ void TrafficGraphWidget::setClientModel(ClientModel *model)
}
}
-std::chrono::minutes TrafficGraphWidget::getGraphRange() const { return m_range; }
-
void TrafficGraphWidget::paintPath(QPainterPath &path, QQueue<float> &samples)
{
int sampleCount = samples.size();
### src/qt/trafficgraphwidget.h
@@ -24,7 +24,6 @@ class TrafficGraphWidget : public QWidget
public:
explicit TrafficGraphWidget(QWidget *parent = nullptr);
void setClientModel(ClientModel *model);
- std::chrono::minutes getGraphRange() const;
protected:
void paintEvent(QPaintEvent *) override;
### src/qt/walletcontroller.cpp
@@ -44,7 +44,6 @@ WalletController::WalletController(ClientModel& client_model, const PlatformStyl
, m_client_model(client_model)
, m_node(client_model.node())
, m_platform_style(platform_style)
- , m_options_model(client_model.getOptionsModel())
{
m_handler_load_wallet = m_node.walletLoader().handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
getOrCreateWallet(std::move(wallet));
### src/qt/walletcontroller.h
@@ -23,7 +23,6 @@
#include <QString>
class ClientModel;
-class OptionsModel;
class PlatformStyle;
class WalletModel;
@@ -78,7 +77,6 @@ class WalletController : public QObject
ClientModel& m_client_model;
interfaces::Node& m_node;
const PlatformStyle* const m_platform_style;
- OptionsModel* const m_options_model;
mutable QMutex m_mutex;
std::vector<WalletModel*> m_wallets;
std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
### src/qt/walletframe.cpp
@@ -123,14 +123,6 @@ void WalletFrame::removeWallet(WalletModel* wallet_model)
delete walletView;
}
-void WalletFrame::removeAllWallets()
-{
- QMap<WalletModel*, WalletView*>::const_iterator i;
- for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
- walletStack->removeWidget(i.value());
- mapWalletViews.clear();
-}
-
bool WalletFrame::handlePaymentRequest(const SendCoinsRecipient &recipient)
{
WalletView *walletView = currentWalletView();
### src/qt/walletframe.h
@@ -38,7 +38,6 @@ class WalletFrame : public QFrame
bool addView(WalletView* walletView);
void setCurrentWallet(WalletModel* wallet_model);
void removeWallet(WalletModel* wallet_model);
- void removeAllWallets();
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
### src/script/signingprovider.cpp
@@ -246,16 +246,6 @@ bool FillableSigningProvider::HaveCScript(const CScriptID& hash) const
return mapScripts.contains(hash);
}
-std::set<CScriptID> FillableSigningProvider::GetCScripts() const
-{
- LOCK(cs_KeyStore);
- std::set<CScriptID> set_script;
- for (const auto& mi : mapScripts) {
- set_script.insert(mi.first);
- }
- return set_script;
-}
-
bool FillableSigningProvider::GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const
{
LOCK(cs_KeyStore);
### src/script/signingprovider.h
@@ -326,7 +326,6 @@ class FillableSigningProvider : public SigningProvider
virtual bool GetKey(const CKeyID &address, CKey &keyOut) const override;
[[nodiscard]] virtual bool AddCScript(const CScript& redeemScript);
virtual bool HaveCScript(const CScriptID &hash) const override;
- virtual std::set<CScriptID> GetCScripts() const;
virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const override;
};
### src/semaphore_grant.h
@@ -88,6 +88,4 @@ class CountingSemaphoreGrant
}
};
-using BinarySemaphoreGrant = CountingSemaphoreGrant<1>;
-
#endif // BITCOIN_SEMAPHORE_GRANT_H
### src/span.h
@@ -109,6 +109,5 @@ template <typename T, size_t N> constexpr auto UCharSpanCast(std::span<T, N> s)
/** Like the std::span constructor, but for (const) unsigned char member types only. Only works for (un)signed char containers. */
template <typename V> constexpr auto MakeUCharSpan(const V& v) -> decltype(UCharSpanCast(std::span{v})) { return UCharSpanCast(std::span{v}); }
-template <typename V> constexpr auto MakeWritableUCharSpan(V&& v) -> decltype(UCharSpanCast(std::span{std::forward<V>(v)})) { return UCharSpanCast(std::span{std::forward<V>(v)}); }
#endif // BITCOIN_SPAN_H
### src/test/fuzz/util/descriptor.h
@@ -35,7 +35,6 @@ class MockedDescriptorConverter {
bool IdIsUnCompPubKey(uint8_t idx) const { return idx % KEY_TYPES_COUNT == 1; }
bool IdIsXOnlyPubKey(uint8_t idx) const { return idx % KEY_TYPES_COUNT == 2; }
bool IdIsConstPrivKey(uint8_t idx) const { return idx % KEY_TYPES_COUNT == 3; }
- bool IdIsXpub(uint8_t idx) const { return idx % KEY_TYPES_COUNT == 4; }
bool IdIsXprv(uint8_t idx) const { return idx % KEY_TYPES_COUNT == 5; }
//! When initializing the target, populate the list of keys.
### src/test/fuzz/util/wallet.h
@@ -73,7 +73,6 @@ struct FuzzedWallet {
return *Assert(wallet->GetNewChangeDestination(type));
}
}
- CScript GetScriptPubKey(FuzzedDataProvider& fuzzed_data_provider) { return GetScriptForDestination(GetDestination(fuzzed_data_provider)); }
};
}
### src/test/kernel/test_kernel.cpp
@@ -86,7 +86,7 @@ constexpr auto VERIFY_ALL_PRE_SEGWIT{ScriptVerificationFlags::P2SH | ScriptVerif
ScriptVerificationFlags::CHECKSEQUENCEVERIFY};
constexpr auto VERIFY_ALL_PRE_TAPROOT{VERIFY_ALL_PRE_SEGWIT | ScriptVerificationFlags::WITNESS};
-void check_equal(std::span<const std::byte> _actual, std::span<const std::byte> _expected, bool equal = true)
+void check_equal(std::span<const std::byte> _actual, std::span<const std::byte> _expected)
{
std::span<const uint8_t> actual{reinterpret_cast<const unsigned char*>(_actual.data()), _actual.size()};
std::span<const uint8_t> expected{reinterpret_cast<const unsigned char*>(_expected.data()), _expected.size()};
### src/wallet/test/util.h
@@ -151,7 +151,6 @@ class FaultInjectingDatabase : public MockableSQLiteDatabase
};
std::unique_ptr<WalletDatabase> CreateMockableWalletDatabase();
-MockableSQLiteDatabase& GetMockableDatabase(CWallet& wallet);
DescriptorScriptPubKeyMan* CreateDescriptor(CWallet& keystore, const std::string& desc_str, bool success);
} // namespace walletWhy 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.