BIP389 multipath descriptors can be imported into the wallet, but we forget the original form. A subsequent call to listdescriptors will show a receive and change descriptor, and a call to getaddressinfo returns only the receive or change variant.
This is confusing, but more importantly it's problem with hardware wallets that need a register descriptor or BIP388 policy.
HWI recently added a registerdescriptor command in https://github.com/bitcoin-core/HWI/pull/842. It handles the conversion from descriptor to BIP388 for us, but it does need a multipath descriptor.
There's are several ways we can go about this:
- Find matches using simple string manipulation, e.g. replace
1/*in change descriptors with0/*and see if it matches the receive descriptor. - Advanced string parsing that matches
.../n/...change descriptors with.../m/...receive descriptors for anym < n. - Have the
Descriptorclass match at a lower level, see prototype in https://github.com/Sjors/bitcoin/pull/123 - Make multipath descriptors a first class wallet citizen, see prototype in https://github.com/Sjors/bitcoin/pull/124
- (new) add a wallet record to track multipath parts, see prototype in (https://github.com/Sjors/bitcoin/pull/125
I think (4) is the better approach, and if done correctly can be expanded to more generic multipath support. Downsides are that it's very involved and such wallets are not backward compatible.