signals: Use a lambda to avoid connecting a signal to another signal
What changed, and why it matters
This is a small code-quality cleanup in Bitcoin Core's wallet code. It changes how an internal notification signal is wired up so that it no longer relies on an obscure, undocumented feature of the Boost signals library. The change prevents a future risk that a Boost update could silently break wallet address notifications, but there is no known current bug or security vulnerability being exploited.
No immediate security action required. Treat as a normal maintainability/portability improvement. Reviewers may want to verify that the lambda forwarding preserves the same signal emission semantics (no argument forwarding is needed here because the source signal carries no arguments).
Security signals we found
Reliance on undocumented/unspecified third-party library behavior
Potential future breakage from Boost.Signals2 behavior change
Signal forwarding in wallet notification path
Evidence from the diff
The commit replaces a direct signal-to-signal connection (spk_man->NotifyCanGetAddressesChanged.connect(NotifyCanGetAddressesChanged)) with an explicit lambda that forwards the signal (connect([this] { NotifyCanGetAddressesChanged(); })). The old pattern depends on unspecified Boost.Signals2 behavior that happens to work today but could change. The change makes the behavior explicit and eases future replacement of Boost.Signals2. The related signal NotifyFirstKeyTimeChanged was already using a lambda and is untouched.
Changed components
src/wallet/wallet.cppCWallet::ConnectScriptPubKeyManNotifiersNotifyCanGetAddressesChanged signalInspect captured patch +3 / −1
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 64d7f191..bda10406 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3549,7 +3549,9 @@ bool CWallet::HaveCryptedKeys() const
void CWallet::ConnectScriptPubKeyManNotifiers()
{
for (const auto& spk_man : GetActiveScriptPubKeyMans()) {
- spk_man->NotifyCanGetAddressesChanged.connect(NotifyCanGetAddressesChanged);
+ spk_man->NotifyCanGetAddressesChanged.connect([this] {
+ NotifyCanGetAddressesChanged();
+ });
spk_man->NotifyFirstKeyTimeChanged.connect([this](const ScriptPubKeyMan*, int64_t time) {
MaybeUpdateBirthTime(time);
});
Why this scored 17/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.