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);