3 minor findings · 7 suggestions
Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.
Findings
[minor] · Wallet-held odd-parity keys are missed for x-only Taproot imports
A public-only tr(X) import can be rejected despite the wallet holding its private key, because the new lookups match compressed pubkeys exactly and miss odd-Y keys.
Location: src/wallet/imports.cpp:149 (head).
Details and suggested fix
For example, import wpkh(WIF) for an odd-Y key, then import tr(X) for its 32-byte x-only pubkey. Parsing the latter produces 02||X, but GetKnownKeys indexes the secret under its actual 03||X pubkey, so this lookup misses. With no other supplied private keys, the import is rejected; with another private key, a new descriptor can import with the missing-keys warning but without this secret. A standalone tr(WIF) source has an additional problem after reload: its serialized tr(X) form reparses as the even representative, so discovery itself misses the stored odd-parity key ID. Use parity-aware lookup at both stages for x-only expressions, insert secrets under key.GetPubKey().GetID(), and retain exact matching for full pubkeys. Add odd-Y x-only cases, including one after reload; the new individual-key test uses the 33-byte form.
[minor] · Substitution prevents reimport from matching an account-rooted descriptor
Once the master xprv is known, reimporting an existing account-rooted descriptor creates a duplicate manager, so updates and deactivation miss the original.
Location: src/wallet/imports.cpp:134 (head).
Details and suggested fix
A wallet can already contain tr([fp/87h/1h/0h]acct_xprv/0/*), for example from a pre-PR import of derivehdkey output or an import made before adding the master. Reimporting its public or private form now rewrites it to tr(master_xpub/87h/1h/0h/0/*) before manager lookup. Those expressions have different canonical strings, so AddWalletDescriptor creates a second manager. Range and timestamp updates reach the duplicate and bypass the original manager's range-containment check. With active=false, ID-specific deactivation also leaves the original active. First look for a manager matching the unmodified expression; if found, preserve that expression and supply the derived account secret separately. Add a reimport/deactivation test for this sequence. How often existing wallets contain this state is unconfirmed.
[minor] · Failed origin derivation can still trigger substitution
An unsuccessful origin-path derivation still reaches the equality check and can replace an importable expression with an underivable path.
Location: src/script/descriptor.cpp:1201 (head).
Details and suggested fix
The break only exits the derivation loop, so the partially derived key is still compared with the descriptor's xpub. For a concrete case, use a known master and an origin containing 256 steps whose xpub actually names the 255-step descendant. CExtKey::Derive fails at depth 255 without changing its output, the comparison passes, and substitution prepends all 256 steps. Expansion then fails, although the original non-ranged expression could import with another private key supplied. This requires inaccurate origin metadata on an unusually deep path and is unlikely in practice. Track whether every step succeeded and skip the candidate on any failure.
Optional improvements
[suggestion] · Every import eagerly retrieves all wallet root keys
Each validated request enumerates every manager under cs_wallet, decrypting available roots in encrypted wallets, and every multipath expansion copies the complete xprv map.
Location: src/wallet/imports.cpp:124 (head).
Details and suggested fix
GetKnownKeys copies every WalletDescriptor, including its cache, and calls GetKey for each descriptor root. In an unlocked encrypted wallet, each hit runs DecryptKey and VerifyPubKey, so batches repeat that work across requests even when the requests already contain their secrets. Private-keys-disabled wallets also incur enumeration. Prefer on-demand exact key lookups and decrypt only fingerprint-matching candidate roots needed for origin substitution, rather than retrieving every secret. Skip discovery when private keys are disabled, and pass the read-only substitution map by const& instead of copying it for every expansion. Any batch optimization must preserve visibility of keys imported by earlier requests, as the MuSig batch now relies on that behavior. Timing was not measured.
[suggestion] · MuSig participant enumeration also changes HD-key RPC defaults
Returning MuSig participants changes gethdkeys output and can make automatic HD-key selection ambiguous, beyond the import behavior this PR targets.
Location: src/script/descriptor.cpp:1117 (head).
Details and suggested fix
GetHDPubKeys uses GetPubKeys, so gethdkeys now lists MuSig participant roots, including cosigner xpubs without wallet-held secrets. With one otherwise selectable active root and an active tr(musig(own,cosigner)/0/*) containing a distinct cosigner root, createwalletdescriptor can no longer select an implicit hdkey. derivehdkey encounters the same ambiguity when no unused(KEY) root overrides active-root selection. This is consistent with ordinary multi() enumeration and may be intended. If so, add active-MuSig coverage for gethdkeys and HD-key defaulting and document the RPC change in a release note. Otherwise, restrict participant expansion to import discovery.
[suggestion] · Public reimports can reset and deactivate the wallet's default descriptor
Reimporting a public default descriptor string now reaches existing state-reset semantics, so omitted activation and index fields can deactivate it and permit address reuse after reactivation.
Location: src/wallet/imports.cpp:134 (head).
Details and suggested fix
For example, the public wpkh([fp/84h/1h/0h]acct_xpub/0/*) string from listdescriptors rewrites to the stored master-rooted expression. If the import range covers the current range, the existing manager is updated: omitted next_index becomes range_start, the timestamp and range are replaced, and omitted active deactivates it. Address generation for that type then fails until reactivation, and previously issued addresses can be reused; rescanning does not recover addresses merely handed out. Private master-form reimports already have these semantics, so this is not a new update-code defect. Document that public equivalents perform the same update and add a same-wallet public round-trip test that checks activation and index behavior.
[suggestion] · MuSig warning assertions no longer cover reused or missing participant keys
The success-only checks for results 1 and 3 miss regressions in batch participant-key reuse, and no remaining case asserts a genuinely missing MuSig participant warning.
Location: test/functional/wallet_importdescriptors.py:296 (head).
Details and suggested fix
Request 0 imports acc_xprv2, which participant discovery now makes available to requests 1 and 3 in the same batch. Those results should therefore have no warnings, but the PR removes their warning assertions without replacing them. If discovery stopped finding keys from earlier MuSig imports, both requests would still succeed because they supply xprv1; only their warnings would change. The new mixed-Taproot case does not replace this coverage because its unknown internal key independently forces a warning. Assert warning absence for results 1 and 3, then add a separate request with a previously unseen participant xpub and assert MISSING_KEYS_WARNING.
[suggestion] · Substitution tests miss a matching fingerprint with the wrong xpub
The new tests do not exercise the derived-xpub equality guard, so fingerprint-only substitution could change imported scripts without failing these assertions.
Location: test/functional/wallet_importdescriptors.py:317 (head).
Details and suggested fix
The current derived.Neuter() comparison correctly rejects an unrelated xpub carrying the wallet master's fingerprint. The positive tests all use matching origins, while the final negative test uses a standalone pubkey, so neither depends on this guard. Add an origin-wrapped unrelated xpub with the master's fingerprint and a path that does not derive to it. Include an explicit private key in another branch so the descriptor imports without substitution rather than merely hitting the no-private-keys rejection. Assert that listdescriptors retains the original xpub and that derived addresses match the input descriptor.
[suggestion] · SubstituteMasterExtPubs documents a different operation
The comment promises private-key replacement, but the function only rewrites matching origin-wrapped xpub expressions into public root-xpub expressions.
Location: src/script/descriptor.h:215 (head).
Details and suggested fix
This function only handles an OriginPubkeyProvider wrapping a BIP32PubkeyProvider. It replaces [fp/path]xpub/... with root_xpub/path/... when a supplied secret derives to the named xpub; it leaves standalone pubkeys unchanged and installs no secrets. ImportDescriptor adds those separately to its signing provider. Reword the comment to describe that public-expression rewrite and explicitly state that it adds no private keys. Also clarify the root-key scope: the implementation has no depth-zero check, so either use a name without Master or enforce that restriction if it is intended.
[suggestion] · Public-descriptor import capability has no release note
importdescriptors now accepts public descriptors using wallet-held secrets, but the release notes do not describe this user-visible capability or its limits.
Location: src/wallet/imports.cpp:136 (head).
Details and suggested fix
Add a PR-specific release note, such as doc/release-notes-35377.md, describing public-descriptor imports into private-key-enabled wallets. Explain that matching wallet-held secrets are stored alongside the descriptor and matching origin-wrapped xpub expressions can be rewritten to root form. Fully public requests without any matching wallet secret remain rejected in those wallets. Derivable descriptors with only some matching keys can import with the missing-keys warning. For origin substitution, the wallet must hold the root secret identified by the fingerprint, and deriving the origin path must reproduce the supplied xpub. The existing release-notes-34861.md only documents timestamp validation.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Define the scope of literal-key matching for wallet-held HD keys