3 minor findings · 12 suggestions
Earlier concerns neither republished nor resolved: 2 minor findings · 2 suggestions. See the Run archive for their assessments.
Findings
[minor] · getdescriptorinfo returns a different descriptor than its help promises
For multipath input, descriptor now contains the complete multipath expression, but its help still promises the first expansion and the PR provides no release note or compatibility transition.
Location: src/rpc/output_script.cpp:212 (head).
Details and suggested fix
Previously this field serialized the first concrete branch; it now serializes the multipath parent. Clients forwarding the field to deriveaddresses receive nested branch arrays, mining RPCs reject it, and importdescriptors rejects it with internal or a non-empty label. PUBLIC serialization also changes for non-multipath keys mixing ' and h. Update the help to describe the retained multipath form and direct callers needing the old value to multipath_expansion[0]. Add a release note and either provide the previous behavior through -deprecatedrpc or explain the exception to the logical-meaning compatibility guideline in doc/developer-notes.md:1409.
[minor] · Multipath signer rejection escapes GUI wallet creation
When a configured signer returns a valid multipath descriptor, the new exception escapes the GUI creation worker and bypasses normal error reporting and progress cleanup.
Location: src/wallet/wallet.cpp:3520 (head).
Details and suggested fix
SetupDescriptorScriptPubKeyMans() now throws instead of importing the first branch. The exception propagates through wallet creation and the loader into the QTimer::singleShot worker callback, which has no catch. It skips both setting m_error_message and scheduling finish(), so the intended failure dialog and progress cleanup do not run; Qt may also terminate on the escaped exception. The RPC layer already converts this exception to an RPC error. The GUI gap existed for malformed replies, but this guard adds a valid-descriptor trigger. No signer returning such multipath descriptors was identified, so production impact is unconfirmed. Keep the rejection, but return a wallet-creation error or catch backend exceptions at the worker boundary and always schedule finish().
[minor] · Multipath normalization reports success with an invalid origin
The normalization API can return true with an unparsable descriptor when a hardened multipath element moves into the origin.
Location: src/script/descriptor.cpp:639 (head).
Details and suggested fix
With the private key available, normalizing wpkh(xprv/<0h;1h>/*) finds <0h;1h> through alternative zero and copies the whole element into origin.path. GetDerivedExtKey() derives only the 0h xpub, producing an origin containing <0h;1h> that Parse rejects because origins disallow multipath. An origin wrapper does not prevent this. Current production callers normalize stored single-path descriptors, and the fuzz targets normalize expansions; no current production trigger was identified. Return false when normalization would move a multipath element into an origin, document that callers should normalize each GetMultipathExpansion() result, and add a direct parent-normalization test.
Optional improvements
[suggestion] · Multipath expansion copies every alternative for every branch
Expanding N alternatives makes O(N²) alternative copies, while the in-place selection API also leaves MuSig aggregate state stale if used after caching.
Location: src/script/descriptor.cpp:1246 (head).
Details and suggested fix
GetMultipathExpansion() clones the unresolved descriptor N times. Each BIP32 clone copies all N alternatives before ChooseMultipath(pos) discards all but one; the previous placeholder approach copied only a fixed-depth scalar path per branch. The parser has no small cap on N, although ordinary two-branch descriptors stay cheap and wall-clock cost is unmeasured. Replace clone-then-mutate with a const branch-selecting clone that passes the position through origins, MuSig participants and subdescriptors, copying only selected alternatives into independently owned outputs. This also avoids the latent cache hazard: MuSig's mutator changes paths and participants without resetting its aggregate provider. Current expansion mutates only fresh clones whose caches are empty, so no current wrong-script path was identified.
[suggestion] · Descriptor range evaluation rebuilds expansions at every index
Ranged evaluation repeatedly clones even single-path descriptor trees and discards reusable MuSig aggregate caches across the default 1,001-index range.
Location: src/rpc/util.cpp:1368 (head).
Details and suggested fix
GetMultipathExpansion() sits inside the range loop and always clones, even for one branch. This rebuilds the tree 1,001 times for the default ranged evaluation, and potentially more for explicit ranges; non-ranged input executes once. For aggregate-then-derive musig() with non-ranged participants, each fresh clone repeats participant GetPubKey(0) and aggregation because it has no cached aggregate provider. Compute const auto expansions = desc->GetMultipathExpansion(); before the range loop and iterate over it, renaming the shadowing inner variable. This preserves output order and provider accumulation while retaining the caches for scans and descriptor-based PSBT evaluation. Runtime cost has not been measured.
[suggestion] · Mixed hardened markers change Miniscript compatibility hashes
Preserving each hardened marker changes the documented-stable CompatDescriptorHash and the DescriptorSPKM IDs assigned to newly imported mixed-marker Miniscript descriptors.
Location: src/script/descriptor.cpp:300 (head).
Details and suggested fix
Miniscript COMPAT deliberately uses PUBLIC key serialization. Previously one marker, selected by the last hardened marker parsed across the origin, wildcard and suffix path, rendered the whole key expression. PUBLIC now preserves each element's spelling. For example, [deadbeef/0h/1']xpub.../2/* inside Miniscript previously rendered the origin as 0'/1', but now retains 0h/1', changing the compatibility hash. Existing stored strings retain their old spelling, loading uses stored IDs, and duplicate detection uses canonical equivalence, so this does not establish a load failure; downgrade behavior remains unverified. Preserve the legacy rendering specifically on the Miniscript COMPAT path, or explicitly narrow the stability guarantee, and add a mixed-marker compatibility-hash test with an expectation computed on base.
[suggestion] · The wallet fuzz helper stores unsupported multipath parents
CreateWalletDescriptor can pass an unexpanded multipath parent into wallet storage, creating fixture state that production import avoids and database loading rejects.
Location: src/wallet/test/fuzz/scriptpubkeyman.cpp:80 (head).
Details and suggested fix
wpkh(%04/<0;1>/*), where %04 supplies an xpub, passes the converter and expense filters. Expand(0, ...) succeeds using alternative zero but leaves the descriptor multipath. The helper then stores that parent through WalletDescriptor and AddWalletDescriptor, which persist its multipath string without rejecting it. Production import selects concrete expansions first, while FromStream refuses the unresolved form. Select the first GetMultipathExpansion() result before both the expansion check and wallet-descriptor construction to restore the previous fixture behavior. Also consider enforcing the single-path invariant at the wallet-descriptor boundary so callers cannot accidentally construct this unsupported state.
[suggestion] · Ordinary key-origin steps now each own a heap allocation
Using the multipath-capable KeyPath for origins adds per-index allocations to ordinary derivation and PSBT handling, although serialization writes only the first alternative.
Location: src/script/keyorigin.h:16 (head).
Details and suggested fix
Each scalar KeyPathElement constructs a one-element vector instead of storing a contiguous numeric index. GetPubKey() copies these allocations into info.path on every derivation, PSBT deserialization constructs one per four-byte index, and by-value origin serialization copies them again. The origin type can also hold alternatives that serialization silently truncates to alternative zero; a default element has no index and its scalar operations throw. Keep multipath alternatives in descriptor-internal paths and use a single-index origin path, such as std::vector<SingleKeyPathElement>, that still retains hardened spelling. This preserves the wire format. Alternatively, store scalar elements inline and allocate only for actual multipath elements. The overhead has not been measured; expansion and wallet TopUp benchmarks would quantify it.
[suggestion] · The key-path round-trip assertion compares the result with itself
The element-by-element assertion always passes, so this unit test no longer checks that formatting and reparsing preserve child numbers.
Location: src/test/bip32_tests.cpp:475 (head).
Details and suggested fix
BOOST_CHECK_EQUAL(res2->at(i).ChildNumber(), res2->at(i).ChildNumber()) compares the same value twice. The following string comparison checks formatting stability, not equality with the original path, so a formatter that consistently drops hardened markers could satisfy it. Compare the second operand with res1->at(i).ChildNumber(), or compare *res2 == *res1; semantic path equality ignores hardened-marker spelling.
[suggestion] · CheckMultipath no longer tests standalone expansion lifetime
The lifetime check operates on the multipath parent rather than a branch that outlives its parent and sibling expansions.
Location: src/test/descriptor_tests.cpp:570 (head).
Details and suggested fix
Returning parsed from the lambda keeps the original multipath object alive and never exercises expansion ownership. DoCheck obtains branches but retains their parsed sources. Inside this lambda, call GetMultipathExpansion(), move out one branch, and assert that it is not multipath. The parent and sibling branches will then be destroyed before the existing ToString() and Expand() calls exercise the retained branch.
[suggestion] · Descriptor tests skip parent serialization and continue after parse failures
The unit and fuzz helpers serialize expansions rather than checking multipath-parent round trips, and DoCheck dereferences parse results after non-fatal failure checks.
Location: src/test/descriptor_tests.cpp:210 (head).
Details and suggested fix
CheckMultipath discards the parent's ToString() result, and both descriptor fuzz targets pass only expansions to their serialization helper. The functional test covers public parent serialization for two simple descriptors, leaving private/canonical parent output and round trips through origins, hardening, tr(), musig() and Miniscript unchecked by these helpers. Assert expected public/private parent strings in CheckMultipath, then reparse them and compare ordered expansions; serialize and reparse the parent in the fuzz targets too. Also change DoCheck's parse checks to BOOST_REQUIRE_MESSAGE: a failed parse currently continues into GetMultipathExpansion() through a null unique_ptr.
[suggestion] · Parser comments still describe the expanded-vector API
Parse still documents an empty vector on failure, while nearby comments describe removed state and already-expanded keys.
Location: src/script/descriptor.h:232 (head).
Details and suggested fix
Document that Parse returns null on failure and may return a multipath object on success, with GetMultipathExpansion() providing concrete branches. Remove the orphaned hardened-derivation comment at descriptor.cpp:2172, which described the removed apostrophe variable. Describe KeyParser::m_keys and the multi() providers vector as key-expression providers that may retain multipath alternatives, not as expanded keys.
[suggestion] · Solving-data tests do not require a later multipath branch
The migrated FundTransaction caller must expand every branch, but the existing solving-data tests would still pass if it expanded only the first.
Location: src/wallet/rpc/spend.cpp:651 (head).
Details and suggested fix
The external-input tests use single-path descriptors such as sh(pkh(WIF)) and sh(wsh(pkh(WIF))), so they do not protect the new expansion loop. Extend the fixture with a checksummed non-ranged descriptor such as sh(wpkh(XPUB/<0;1>)). Fund branch 1, keep the descriptor unimported in the funding wallet, and preselect that UTXO without input_weights. Assert that funding fails without solving data and succeeds with the multipath descriptor. This makes the test depend on a later branch populating the external provider. Use a non-ranged descriptor because this caller expands only at index zero.
[suggestion] · Indexes() exposes unused alternative-vector storage
The new Indexes() accessor has no caller and unnecessarily exposes KeyPathElement's internal vector.
Location: src/util/bip32.h:76 (head).
Details and suggested fix
Multipath selection already uses Index(pos), and parsing constructs elements directly. Remove Indexes() and retain Index() and MultipathLen() so the public API does not expose a storage representation that no caller needs.
[suggestion] · ParseScript retains an unused result accumulator
After the single-descriptor refactor, ParseScript declares ret but never uses it.
Location: src/script/descriptor.cpp:2353 (head).
Details and suggested fix
Every branch now returns a descriptor or an empty pointer directly. The local std::unique_ptr<DescriptorImpl> ret; remains null for its entire lifetime and suggests a shared result accumulator that no longer exists. Delete the declaration.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Initialize the default key-path index
- [minor]: Reject malformed paths that collapse to the root
- [suggestion]: Avoid copying path elements in the hardened-path scan
- [minor]: Self-expansion check misses hardened multipath alternatives