wallet: remove fUpdate argument from AddToWalletIfInvolvingMe
What changed, and why it matters
This is a small internal code cleanup in Bitcoin Core's wallet module. It removes an unused function argument called fUpdate because every place that called the function always passed the value true. There is no change in behavior and no security issue.
No action needed; this is a non-security refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors CWallet::AddToWalletIfInvolvingMe to remove the bool fUpdate parameter. The only caller, SyncTransaction, always passed true, and the removed logic (if fExisted && !fUpdate return false) therefore never triggered. The change is purely a simplification/dead-code removal with no functional or security impact.
Changed components
src/wallet/wallet.cppsrc/wallet/wallet.hInspect captured patch +3 / −5
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index f46c7428..409e0483 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1201,7 +1201,7 @@ bool CWallet::LoadToWallet(const Txid& hash, const UpdateWalletTxFn& fill_wtx)
return true;
}
-bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const SyncTxState& state, bool fUpdate, bool rescanning_old_block)
+bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const SyncTxState& state, bool rescanning_old_block)
{
const CTransaction& tx = *ptx;
{
@@ -1221,7 +1221,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const SyncTxS
}
bool fExisted = mapWallet.contains(tx.GetHash());
- if (fExisted && !fUpdate) return false;
if (fExisted || IsMine(tx) || IsFromMe(tx))
{
/* Check if any keys in the wallet keypool that were supposed to be unused
@@ -1415,7 +1414,7 @@ void CWallet::RecursiveUpdateTxState(WalletBatch* batch, const Txid& tx_hash, co
bool CWallet::SyncTransaction(const CTransactionRef& ptx, const SyncTxState& state, bool rescanning_old_block)
{
- if (!AddToWalletIfInvolvingMe(ptx, state, /*fUpdate=*/true, rescanning_old_block))
+ if (!AddToWalletIfInvolvingMe(ptx, state, rescanning_old_block))
return false; // Not one of ours
// If a transaction changes 'conflicted' state, that changes the balance
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 180668ad..48ebbf66 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -347,7 +347,6 @@ private:
* block_hash.IsNull(), then wallet state is not updated in AddToWallet, but
* notifications happen and cached balances are marked dirty.
*
- * If fUpdate is true, existing transactions will be updated.
* TODO: One exception to this is that the abandoned state is cleared under the
* assumption that any further notification of a transaction that was considered
* abandoned is an indication that it is not safe to be considered abandoned.
@@ -357,7 +356,7 @@ private:
* Should be called with rescanning_old_block set to true, if the transaction is
* not discovered in real time, but during a rescan of old blocks.
*/
- bool AddToWalletIfInvolvingMe(const CTransactionRef& tx, const SyncTxState& state, bool fUpdate, bool rescanning_old_block) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
+ bool AddToWalletIfInvolvingMe(const CTransactionRef& tx, const SyncTxState& state, bool rescanning_old_block) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
/** Mark a transaction (and its in-wallet descendants) as conflicting with a particular block. */
void MarkConflicted(const uint256& hashBlock, int conflicting_height, const Txid& hashTx);
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.