@@ -1903,6 +1903,23 @@ std::set<uint256> CWallet::GetTxConflicts(const CWalletTx& wtx) const
19031903 return result;
19041904}
19051905
1906+ bool CWallet::ShouldResend () const
1907+ {
1908+ // Don't attempt to resubmit if the wallet is configured to not broadcast
1909+ if (!fBroadcastTransactions ) return false ;
1910+
1911+ // During reindex, importing and IBD, old wallet transactions become
1912+ // unconfirmed. Don't resend them as that would spam other nodes.
1913+ // We only allow forcing mempool submission when not relaying to avoid this spam.
1914+ if (!chain ().isReadyToBroadcast ()) return false ;
1915+
1916+ // Do this infrequently and randomly to avoid giving away
1917+ // that these are our transactions.
1918+ if (GetTime () < m_next_resend) return false ;
1919+
1920+ return true ;
1921+ }
1922+
19061923// Resubmit transactions from the wallet to the mempool, optionally asking the
19071924// mempool to relay them. On startup, we will do this for all unconfirmed
19081925// transactions but will not ask the mempool to relay them. We do this on startup
@@ -1934,14 +1951,6 @@ void CWallet::ResubmitWalletTransactions(bool relay, bool force)
19341951 // even if forcing.
19351952 if (!fBroadcastTransactions ) return ;
19361953
1937- // During reindex, importing and IBD, old wallet transactions become
1938- // unconfirmed. Don't resend them as that would spam other nodes.
1939- // We only allow forcing mempool submission when not relaying to avoid this spam.
1940- if (!force && relay && !chain ().isReadyToBroadcast ()) return ;
1941-
1942- // Do this infrequently and randomly to avoid giving away
1943- // that these are our transactions.
1944- if (!force && GetTime () < m_next_resend) return ;
19451954 // resend 12-36 hours from now, ~1 day on average.
19461955 m_next_resend = GetTime () + (12 * 60 * 60 ) + GetRand (24 * 60 * 60 );
19471956
@@ -1979,6 +1988,7 @@ void CWallet::ResubmitWalletTransactions(bool relay, bool force)
19791988void MaybeResendWalletTxs (WalletContext& context)
19801989{
19811990 for (const std::shared_ptr<CWallet>& pwallet : GetWallets (context)) {
1991+ if (!pwallet->ShouldResend ()) continue ;
19821992 pwallet->ResubmitWalletTransactions (/* relay=*/ true , /* force=*/ false );
19831993 }
19841994}
0 commit comments