@@ -1903,6 +1903,23 @@ std::set<uint256> CWallet::GetTxConflicts(const CWalletTx& wtx) const
1903
1903
return result;
1904
1904
}
1905
1905
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
+
1906
1923
// Resubmit transactions from the wallet to the mempool, optionally asking the
1907
1924
// mempool to relay them. On startup, we will do this for all unconfirmed
1908
1925
// 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)
1934
1951
// even if forcing.
1935
1952
if (!fBroadcastTransactions ) return ;
1936
1953
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 ;
1945
1954
// resend 12-36 hours from now, ~1 day on average.
1946
1955
m_next_resend = GetTime () + (12 * 60 * 60 ) + GetRand (24 * 60 * 60 );
1947
1956
@@ -1979,6 +1988,7 @@ void CWallet::ResubmitWalletTransactions(bool relay, bool force)
1979
1988
void MaybeResendWalletTxs (WalletContext& context)
1980
1989
{
1981
1990
for (const std::shared_ptr<CWallet>& pwallet : GetWallets (context)) {
1991
+ if (!pwallet->ShouldResend ()) continue ;
1982
1992
pwallet->ResubmitWalletTransactions (/* relay=*/ true , /* force=*/ false );
1983
1993
}
1984
1994
}
0 commit comments