@@ -1180,6 +1180,8 @@ void CWallet::blockDisconnected(const CBlock& block, int height)
11801180void CWallet::updatedBlockTip (bool is_ibd)
11811181{
11821182 m_best_block_time = GetTime ();
1183+ LOCK (cs_wallet);
1184+ m_is_ibd = is_ibd;
11831185}
11841186
11851187
@@ -2014,6 +2016,8 @@ void CWallet::ResendWalletTransactions()
20142016 { // cs_wallet scope
20152017 LOCK (cs_wallet);
20162018
2019+ if (m_is_ibd) return ;
2020+
20172021 // Relay transactions
20182022 for (std::pair<const uint256, CWalletTx>& item : mapWallet) {
20192023 CWalletTx& wtx = item.second ;
@@ -2587,9 +2591,9 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
25872591 return true ;
25882592}
25892593
2590- static bool IsCurrentForAntiFeeSniping (interfaces::Chain& chain, const uint256& block_hash)
2594+ static bool IsCurrentForAntiFeeSniping (interfaces::Chain& chain, bool is_ibd, const uint256& block_hash)
25912595{
2592- if (chain. isInitialBlockDownload () ) {
2596+ if (is_ibd ) {
25932597 return false ;
25942598 }
25952599 constexpr int64_t MAX_ANTI_FEE_SNIPING_TIP_AGE = 8 * 60 * 60 ; // in seconds
@@ -2605,7 +2609,7 @@ static bool IsCurrentForAntiFeeSniping(interfaces::Chain& chain, const uint256&
26052609 * Return a height-based locktime for new transactions (uses the height of the
26062610 * current chain tip unless we are not synced with the current chain
26072611 */
2608- static uint32_t GetLocktimeForNewTransaction (interfaces::Chain& chain, const uint256& block_hash, int block_height)
2612+ static uint32_t GetLocktimeForNewTransaction (interfaces::Chain& chain, bool is_ibd, const uint256& block_hash, int block_height)
26092613{
26102614 uint32_t locktime;
26112615 // Discourage fee sniping.
@@ -2628,7 +2632,7 @@ static uint32_t GetLocktimeForNewTransaction(interfaces::Chain& chain, const uin
26282632 // enough, that fee sniping isn't a problem yet, but by implementing a fix
26292633 // now we ensure code won't be written that makes assumptions about
26302634 // nLockTime that preclude a fix later.
2631- if (IsCurrentForAntiFeeSniping (chain, block_hash)) {
2635+ if (IsCurrentForAntiFeeSniping (chain, is_ibd, block_hash)) {
26322636 locktime = block_height;
26332637
26342638 // Secondly occasionally randomly pick a nLockTime even further back, so
@@ -2707,7 +2711,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
27072711 {
27082712 std::set<CInputCoin> setCoins;
27092713 LOCK (cs_wallet);
2710- txNew.nLockTime = GetLocktimeForNewTransaction (chain (), GetLastBlockHash (), GetLastBlockHeight ());
2714+ txNew.nLockTime = GetLocktimeForNewTransaction (chain (), m_is_ibd, GetLastBlockHash (), GetLastBlockHeight ());
27112715 {
27122716 std::vector<COutput> vAvailableCoins;
27132717 AvailableCoins (vAvailableCoins, true , &coin_control, 1 , MAX_MONEY, MAX_MONEY, 0 );
0 commit comments