From ae888c38d080c9c41925faeb53044e5bd0b7f9ee Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Tue, 20 Feb 2024 11:49:56 -0500 Subject: [PATCH] wallet: Exit IsTrustedTx early if wtx is already in trusted_parents --- src/wallet/receive.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wallet/receive.cpp b/src/wallet/receive.cpp index f0d7d00763f..620d2bb12c6 100644 --- a/src/wallet/receive.cpp +++ b/src/wallet/receive.cpp @@ -257,6 +257,10 @@ bool CachedTxIsFromMe(const CWallet& wallet, const CWalletTx& wtx, const isminef bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx, std::set& trusted_parents) { AssertLockHeld(wallet.cs_wallet); + + // This wtx is already trusted + if (trusted_parents.contains(wtx.GetHash())) return true; + if (wtx.isConfirmed()) return true; if (wtx.isBlockConflicted()) return false; // using wtx's cached debit