refactor: Move -walletbroadcast setting init
What changed, and why it matters
This is a simple code cleanup change. It moves where a wallet setting called -walletbroadcast is read from the command-line/config into the wallet object. Previously it happened inside a locked section; now it happens earlier with other similar settings. The commit message explicitly says this does not require locks and is just relocating initialization. There is no security issue visible in the change.
No security action needed. Treat as normal refactoring code review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch relocates the initialization of fBroadcastTransactions (via SetBroadcastTransactions) from inside a cs_wallet-locked block to the argument-parsing section of CWallet::Create. The commit message frames this as a refactor because modifying fBroadcastTransactions does not need cs_wallet. The functional behavior is unchanged: the same argument, same default, and same wallet instance are used.
Changed components
src/wallet/wallet.cppCWallet::Create-walletbroadcast option initializationInspect captured patch +1 / −1
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 8e1ab28f..d9cf7731 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3069,6 +3069,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
walletInstance->m_confirm_target = args.GetIntArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET);
walletInstance->m_spend_zero_conf_change = args.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE);
walletInstance->m_signal_rbf = args.GetBoolArg("-walletrbf", DEFAULT_WALLET_RBF);
+ walletInstance->SetBroadcastTransactions(args.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));
walletInstance->WalletLogPrintf("Wallet completed loading in %15dms\n", Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
@@ -3090,7 +3091,6 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
{
LOCK(walletInstance->cs_wallet);
- walletInstance->SetBroadcastTransactions(args.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));
walletInstance->WalletLogPrintf("setKeyPool.size() = %u\n", walletInstance->GetKeyPoolSize());
walletInstance->WalletLogPrintf("mapWallet.size() = %u\n", walletInstance->mapWallet.size());
walletInstance->WalletLogPrintf("m_address_book.size() = %u\n", walletInstance->m_address_book.size());
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.