Skip to content

Conversation

@naiyoma
Copy link
Contributor

@naiyoma naiyoma commented Nov 14, 2025

Fixes: #33655

Currently, we validate and import descriptors in the same loop. If any descriptor fails validation, an error is added to the response array, but the complete response (including that error) is only returned to after a rescan completes—potentially wasting significant time when validation error could have been caught immediately.

This PR separates validation from processing: validate all descriptors first, and process in the second loop

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 14, 2025

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33874.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #32861 (Have createwalletdescriptor auto-detect an unused(KEY) by Sjors)
  • #32784 (wallet: derivehdkey RPC to get xpub at arbitrary path by Sjors)
  • #31668 (Added rescan option for import descriptors by saikiran57)
  • #29136 (wallet: addhdkey RPC to add just keys to wallets via new unused(KEY) descriptor by achow101)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@naiyoma naiyoma marked this pull request as draft November 14, 2025 19:15
@naiyoma naiyoma changed the title wallet: refactor ProcessDescriptorImport , validate descriptors before rescan wallet: refactor ProcessDescriptorImport Nov 14, 2025
@DrahtBot DrahtBot changed the title wallet: refactor ProcessDescriptorImport wallet: refactor ProcessDescriptorImport Nov 14, 2025
@naiyoma naiyoma force-pushed the 2025_6/approach_2_validation branch from 6bbff43 to 9cc3309 Compare November 17, 2025 13:48
for (const UniValue& request : requests.getValues()) {
DescriptorImportData validated = ValidateDescriptorImport(*pwallet, request);
UniValue result(UniValue::VOBJ);
result.pushKV("success", UniValue(validated.success));
Copy link
Member

@achow101 achow101 Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dangerous, we should never return success: true if the descriptor hasn't been fully processed yet.

Given how this RPC behaved previously, this can lead to users thinking that their descriptor has actually been imported when it was not.

@achow101
Copy link
Member

Concept meh

importdescriptors was modeled after the old importmulti, which IIRC part of the point was that even if some things couldn't be imported that everything else that can be imported was.

But I do see how exiting early and doing nothing if something can't be imported could be useful, but this is pretty big semantic change and we need to be careful about return values to avoid any possible confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

importdescriptors: check for errors before rescanning

3 participants