signals: use an alias for the boost::signals2 namespace
What changed, and why it matters
This commit is a simple code cleanup: it creates a project-specific alias `btcsignals` for the external library namespace `boost::signals2`, and replaces all direct uses of `boost::signals2` with the new alias. There is no functional change, no bug fix, and no security-relevant behavior change.
No security action required. Treat as ordinary refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change introduces namespace btcsignals = boost::signals2; in src/btcsignals.h and mechanically substitutes boost::signals2:: with btcsignals:: across 10 files. It is a pure refactoring/namespace-aliasing commit intended to prepare for a future custom implementation in the same namespace. No logic, signatures, or runtime behavior is altered.
Changed components
src/btcsignals.hsrc/common/interfaces.cppsrc/interfaces/handler.hsrc/node/interface_ui.cppsrc/node/interface_ui.hsrc/noui.cppsrc/qt/bitcoin.cppsrc/qt/test/wallettests.cppsrc/wallet/scriptpubkeyman.hsrc/wallet/wallet.hInspect captured patch +35 / −33
diff --git a/src/btcsignals.h b/src/btcsignals.h
index 816d9125..415d8b86 100644
--- a/src/btcsignals.h
+++ b/src/btcsignals.h
@@ -9,4 +9,6 @@
#include <boost/signals2/optional_last_value.hpp>
#include <boost/signals2/signal.hpp>
+namespace btcsignals = boost::signals2;
+
#endif // BITCOIN_BTCSIGNALS_H
diff --git a/src/common/interfaces.cpp b/src/common/interfaces.cpp
index dc98fac6..de028f9c 100644
--- a/src/common/interfaces.cpp
+++ b/src/common/interfaces.cpp
@@ -23,11 +23,11 @@ public:
class SignalHandler : public interfaces::Handler
{
public:
- explicit SignalHandler(boost::signals2::connection connection) : m_connection(std::move(connection)) {}
+ explicit SignalHandler(btcsignals::connection connection) : m_connection(std::move(connection)) {}
void disconnect() override { m_connection.disconnect(); }
- boost::signals2::scoped_connection m_connection;
+ btcsignals::scoped_connection m_connection;
};
class EchoImpl : public interfaces::Echo
@@ -44,7 +44,7 @@ std::unique_ptr<Handler> MakeCleanupHandler(std::function<void()> cleanup)
return std::make_unique<common::CleanupHandler>(std::move(cleanup));
}
-std::unique_ptr<Handler> MakeSignalHandler(boost::signals2::connection connection)
+std::unique_ptr<Handler> MakeSignalHandler(btcsignals::connection connection)
{
return std::make_unique<common::SignalHandler>(std::move(connection));
}
diff --git a/src/interfaces/handler.h b/src/interfaces/handler.h
index 5de131ee..09c23638 100644
--- a/src/interfaces/handler.h
+++ b/src/interfaces/handler.h
@@ -24,8 +24,8 @@ public:
virtual void disconnect() = 0;
};
-//! Return handler wrapping a boost signal connection.
-std::unique_ptr<Handler> MakeSignalHandler(boost::signals2::connection connection);
+//! Return handler wrapping a btcsignals connection.
+std::unique_ptr<Handler> MakeSignalHandler(btcsignals::connection connection);
//! Return handler wrapping a cleanup function.
std::unique_ptr<Handler> MakeCleanupHandler(std::function<void()> cleanup);
diff --git a/src/node/interface_ui.cpp b/src/node/interface_ui.cpp
index 525d341e..6b1fe72f 100644
--- a/src/node/interface_ui.cpp
+++ b/src/node/interface_ui.cpp
@@ -13,22 +13,22 @@ using util::MakeUnorderedList;
CClientUIInterface uiInterface;
struct UISignals {
- boost::signals2::signal<CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::optional_last_value<bool>> ThreadSafeMessageBox;
- boost::signals2::signal<CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::optional_last_value<bool>> ThreadSafeQuestion;
- boost::signals2::signal<CClientUIInterface::InitMessageSig> InitMessage;
- boost::signals2::signal<CClientUIInterface::InitWalletSig> InitWallet;
- boost::signals2::signal<CClientUIInterface::NotifyNumConnectionsChangedSig> NotifyNumConnectionsChanged;
- boost::signals2::signal<CClientUIInterface::NotifyNetworkActiveChangedSig> NotifyNetworkActiveChanged;
- boost::signals2::signal<CClientUIInterface::NotifyAlertChangedSig> NotifyAlertChanged;
- boost::signals2::signal<CClientUIInterface::ShowProgressSig> ShowProgress;
- boost::signals2::signal<CClientUIInterface::NotifyBlockTipSig> NotifyBlockTip;
- boost::signals2::signal<CClientUIInterface::NotifyHeaderTipSig> NotifyHeaderTip;
- boost::signals2::signal<CClientUIInterface::BannedListChangedSig> BannedListChanged;
+ btcsignals::signal<CClientUIInterface::ThreadSafeMessageBoxSig, btcsignals::optional_last_value<bool>> ThreadSafeMessageBox;
+ btcsignals::signal<CClientUIInterface::ThreadSafeQuestionSig, btcsignals::optional_last_value<bool>> ThreadSafeQuestion;
+ btcsignals::signal<CClientUIInterface::InitMessageSig> InitMessage;
+ btcsignals::signal<CClientUIInterface::InitWalletSig> InitWallet;
+ btcsignals::signal<CClientUIInterface::NotifyNumConnectionsChangedSig> NotifyNumConnectionsChanged;
+ btcsignals::signal<CClientUIInterface::NotifyNetworkActiveChangedSig> NotifyNetworkActiveChanged;
+ btcsignals::signal<CClientUIInterface::NotifyAlertChangedSig> NotifyAlertChanged;
+ btcsignals::signal<CClientUIInterface::ShowProgressSig> ShowProgress;
+ btcsignals::signal<CClientUIInterface::NotifyBlockTipSig> NotifyBlockTip;
+ btcsignals::signal<CClientUIInterface::NotifyHeaderTipSig> NotifyHeaderTip;
+ btcsignals::signal<CClientUIInterface::BannedListChangedSig> BannedListChanged;
};
static UISignals g_ui_signals;
#define ADD_SIGNALS_IMPL_WRAPPER(signal_name) \
- boost::signals2::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \
+ btcsignals::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \
{ \
return g_ui_signals.signal_name.connect(fn); \
}
diff --git a/src/node/interface_ui.h b/src/node/interface_ui.h
index 8c90bdf4..c33df59a 100644
--- a/src/node/interface_ui.h
+++ b/src/node/interface_ui.h
@@ -67,7 +67,7 @@ public:
#define ADD_SIGNALS_DECL_WRAPPER(signal_name, rtype, ...) \
rtype signal_name(__VA_ARGS__); \
using signal_name##Sig = rtype(__VA_ARGS__); \
- boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn)
+ btcsignals::connection signal_name##_connect(std::function<signal_name##Sig> fn)
/** Show message box. */
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const bilingual_str& message, unsigned int style);
diff --git a/src/noui.cpp b/src/noui.cpp
index af04cb00..6f33b227 100644
--- a/src/noui.cpp
+++ b/src/noui.cpp
@@ -13,9 +13,9 @@
#include <string>
/** Store connections so we can disconnect them when suppressing output */
-boost::signals2::connection noui_ThreadSafeMessageBoxConn;
-boost::signals2::connection noui_ThreadSafeQuestionConn;
-boost::signals2::connection noui_InitMessageConn;
+btcsignals::connection noui_ThreadSafeMessageBoxConn;
+btcsignals::connection noui_ThreadSafeQuestionConn;
+btcsignals::connection noui_InitMessageConn;
bool noui_ThreadSafeMessageBox(const bilingual_str& message, unsigned int style)
{
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index cb236bd7..0b89c605 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -485,9 +485,9 @@ int GuiMain(int argc, char* argv[])
util::ThreadSetInternalName("main");
// Subscribe to global signals from core
- boost::signals2::scoped_connection handler_message_box = ::uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox);
- boost::signals2::scoped_connection handler_question = ::uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion);
- boost::signals2::scoped_connection handler_init_message = ::uiInterface.InitMessage_connect(noui_InitMessage);
+ btcsignals::scoped_connection handler_message_box = ::uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox);
+ btcsignals::scoped_connection handler_question = ::uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion);
+ btcsignals::scoped_connection handler_init_message = ::uiInterface.InitMessage_connect(noui_InitMessage);
// Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory
diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp
index b62b2a3b..4369a078 100644
--- a/src/qt/test/wallettests.cpp
+++ b/src/qt/test/wallettests.cpp
@@ -87,7 +87,7 @@ Txid SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CTxDesti
->findChild<QCheckBox*>("optInRBF")
->setCheckState(rbf ? Qt::Checked : Qt::Unchecked);
Txid txid;
- boost::signals2::scoped_connection c(wallet.NotifyTransactionChanged.connect([&txid](const Txid& hash, ChangeType status) {
+ btcsignals::scoped_connection c(wallet.NotifyTransactionChanged.connect([&txid](const Txid& hash, ChangeType status) {
if (status == CT_NEW) txid = hash;
}));
ConfirmSend(/*text=*/nullptr, confirm_type);
diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h
index 8647ae48..f6eb9cd3 100644
--- a/src/wallet/scriptpubkeyman.h
+++ b/src/wallet/scriptpubkeyman.h
@@ -155,10 +155,10 @@ public:
};
/** Keypool has new keys */
- boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
+ btcsignals::signal<void ()> NotifyCanGetAddressesChanged;
/** Birth time changed */
- boost::signals2::signal<void (const ScriptPubKeyMan* spkm, int64_t new_birth_time)> NotifyFirstKeyTimeChanged;
+ btcsignals::signal<void (const ScriptPubKeyMan* spkm, int64_t new_birth_time)> NotifyFirstKeyTimeChanged;
};
/** OutputTypes supported by the LegacyScriptPubKeyMan */
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index a46a6455..7d14ecff 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -826,13 +826,13 @@ public:
void Close();
/** Wallet is about to be unloaded */
- boost::signals2::signal<void ()> NotifyUnload;
+ btcsignals::signal<void ()> NotifyUnload;
/**
* Address book entry changed.
* @note called without lock cs_wallet held.
*/
- boost::signals2::signal<void(const CTxDestination& address,
+ btcsignals::signal<void(const CTxDestination& address,
const std::string& label, bool isMine,
AddressPurpose purpose, ChangeType status)>
NotifyAddressBookChanged;
@@ -841,19 +841,19 @@ public:
* Wallet transaction added, removed or updated.
* @note called with lock cs_wallet held.
*/
- boost::signals2::signal<void(const Txid& hashTx, ChangeType status)> NotifyTransactionChanged;
+ btcsignals::signal<void(const Txid& hashTx, ChangeType status)> NotifyTransactionChanged;
/** Show progress e.g. for rescan */
- boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
+ btcsignals::signal<void (const std::string &title, int nProgress)> ShowProgress;
/** Keypool has new keys */
- boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
+ btcsignals::signal<void ()> NotifyCanGetAddressesChanged;
/**
* Wallet status (encrypted, locked) changed.
* Note: Called without locks held.
*/
- boost::signals2::signal<void (CWallet* wallet)> NotifyStatusChanged;
+ btcsignals::signal<void (CWallet* wallet)> NotifyStatusChanged;
/** Inquire whether this wallet broadcasts transactions. */
bool GetBroadcastTransactions() const { return fBroadcastTransactions; }
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.