From 336f5a738b3d89abb8dd7ebdc4b31ac12a6de85f Mon Sep 17 00:00:00 2001 From: Pol Espinasa Date: Mon, 22 Jun 2026 12:04:42 +0200 Subject: [PATCH 1/2] wallet: reserve walletrescan before checking wallet is at the tip --- src/wallet/rpc/backup.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp index 396be628259..44b49bea12c 100644 --- a/src/wallet/rpc/backup.cpp +++ b/src/wallet/rpc/backup.cpp @@ -380,15 +380,15 @@ RPCMethod importdescriptors() if (!pwallet) return UniValue::VNULL; CWallet& wallet{*pwallet}; - // Make sure the results are valid at least up to the most recent block - // the user could have gotten from another RPC command prior to now - wallet.BlockUntilSyncedToCurrentChain(); - WalletRescanReserver reserver(*pwallet); if (!reserver.reserve(/*with_passphrase=*/true)) { throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait."); } + // Make sure the results are valid at least up to the most recent block + // the user could have gotten from another RPC command prior to now + wallet.BlockUntilSyncedToCurrentChain(); + // Ensure that the wallet is not locked for the remainder of this RPC, as // the passphrase is used to top up the keypool. LOCK(pwallet->m_relock_mutex); From 9e62e4b1f346f70eaa23e83eff769b6e6cc04630 Mon Sep 17 00:00:00 2001 From: Pol Espinasa Date: Tue, 23 Jun 2026 09:58:26 +0200 Subject: [PATCH 2/2] test: slow down rescaning process --- test/functional/wallet_importdescriptors.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py index f9429079bbd..06ffef9b432 100755 --- a/test/functional/wallet_importdescriptors.py +++ b/test/functional/wallet_importdescriptors.py @@ -136,6 +136,9 @@ class ImportDescriptorsTest(BitcoinTestFramework): "timestamp": 0, "range": [0, 10000]}] conflicting_desc = [{"desc": descsum_create("pkh(" + xpriv + "/1h/*h)"), "timestamp": 0, "range": [0, 10000]}] + num_relevant_blocks = 1000 + self.generatetoaddress(self.nodes[0], num_relevant_blocks, self.nodes[0].deriveaddresses(slow_desc[0]['desc'], [0, 0])[0]) + self.generatetoaddress(self.nodes[0], num_relevant_blocks, self.nodes[0].deriveaddresses(conflicting_desc[0]['desc'], [0, 0])[0]) start = threading.Barrier(3)