From 10d91c5abe9ed7dcc237c9d52c588e7d26e162a4 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Wed, 24 Aug 2022 16:40:30 -0400 Subject: wallet: Deduplicate Resend and ReacceptWalletTransactions Both of these functions do almost the exact same thing. They can be deduplicated so that their behavior matches except for the filtering aspect. As this function will now always be called on wallet loading, nNextResend will also always be initialized, so wallet_resendwallettransactions.py is updated to account for that. This also resolves a bug where ResendWalletTransactions would fail to rebroadcast txs in insertion order thereby potentially rebroadcasting a child transaction before its parent and causing the child to not actually get rebroadcast. Also names the combined function to ResubmitWalletTransactions as the function just submits the transactions to the mempool rather than doing any sending by itself. --- test/functional/wallet_resendwallettransactions.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'test/functional') diff --git a/test/functional/wallet_resendwallettransactions.py b/test/functional/wallet_resendwallettransactions.py index 4ef259efe1..850070dca4 100755 --- a/test/functional/wallet_resendwallettransactions.py +++ b/test/functional/wallet_resendwallettransactions.py @@ -29,12 +29,6 @@ class ResendWalletTransactionsTest(BitcoinTestFramework): self.log.info("Create a new transaction and wait until it's broadcast") txid = node.sendtoaddress(node.getnewaddress(), 1) - # Wallet rebroadcast is first scheduled 1 min sec after startup (see - # nNextResend in ResendWalletTransactions()). Tell scheduler to call - # MaybeResendWalletTxs now to initialize nNextResend before the first - # setmocktime call below. - node.mockscheduler(60) - # Can take a few seconds due to transaction trickling peer_first.wait_for_broadcast([txid]) @@ -51,7 +45,7 @@ class ResendWalletTransactionsTest(BitcoinTestFramework): block.solve() node.submitblock(block.serialize().hex()) - # Set correct m_best_block_time, which is used in ResendWalletTransactions + # Set correct m_best_block_time, which is used in ResubmitWalletTransactions node.syncwithvalidationinterfacequeue() now = int(time.time()) @@ -66,7 +60,7 @@ class ResendWalletTransactionsTest(BitcoinTestFramework): self.log.info("Bump time & check that transaction is rebroadcast") # Transaction should be rebroadcast approximately 24 hours in the future, # but can range from 12-36. So bump 36 hours to be sure. - with node.assert_debug_log(['ResendWalletTransactions: resubmit 1 unconfirmed transactions']): + with node.assert_debug_log(['resubmit 1 unconfirmed transactions']): node.setmocktime(now + 36 * 60 * 60) # Tell scheduler to call MaybeResendWalletTxs now. node.mockscheduler(60) -- cgit v1.2.3