diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp index 9c58e0fe3f7..9ffea19c474 100644 --- a/src/wallet/rpc/backup.cpp +++ b/src/wallet/rpc/backup.cpp @@ -381,15 +381,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); diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py index f60484d84cd..36d88d17c8a 100755 --- a/test/functional/wallet_importdescriptors.py +++ b/test/functional/wallet_importdescriptors.py @@ -140,6 +140,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)