When rescanning a wallet for transactions, it will remove transactions that are no longer in the wallet.
Required for #15129
When rescanning a wallet for transactions, it will remove transactions that are no longer in the wallet.
Required for #15129
874 | @@ -875,6 +875,22 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose) 875 | return true; 876 | } 877 | 878 | +bool CWallet::RemoveFromWallet(const CTransaction& tx) 879 | +{ 880 | + LOCK(cs_wallet);
Prefer AssertLockHeld?
962 | @@ -947,7 +963,10 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const CBlockI 963 | if (pIndex != nullptr) 964 | wtx.SetMerkleBranch(pIndex, posInBlock); 965 | 966 | - return AddToWallet(wtx, false); 967 | + if (IsMine(tx) || IsFromMe(tx)) 968 | + return AddToWallet(wtx, false); 969 | + 970 | + return RemoveFromWallet(tx);
Does it make sense to return the result of RemoveFromWallet in AddToWalletIfInvolvingMe?
884 | + } 885 | + 886 | + WalletLogPrintf("RemoveFromWallet %s\n", tx.GetHash().ToString()); 887 | + 888 | + // Notify UI of removed transaction 889 | + NotifyTransactionChanged(this, tx.GetHash(), CT_DELETED);
Unused notification?
This looks very inefficient. RemoveWallet is called for all non-wallet transactions. The lack of tests doesn't support this change.
Yes, when I suggested to split I meant to make this one rebased on that.