Fixes #33655
The importdescriptors RPC was performing expensive blockchain rescans even when descriptor validation failed, wasting time and resources.
Changes
This PR separates validation logic into a new ValidateDescriptorImport() function that validates all descriptors before any wallet modifications or rescanning occurs.
Behavior
- Before: ProcessDescriptorImport() validated and imported descriptors one by one, triggering a rescan even if some descriptors were invalid
- After: ValidateDescriptorImport() checks all descriptors first, fails fast on any validation error, and only proceeds to ProcessDescriptorImport() and rescanning if all descriptors are valid
Benefits
- Fails fast on invalid descriptors without triggering rescan
- Validates all descriptors upfront before processing any
- Improves user experience with immediate feedback on validation errors
- Saves significant time by avoiding unnecessary blockchain rescans
- Follows the approach suggested by @pinheadmz in the issue discussion