test/mutation: check wallet listings and wrapped P2WSH addresses in wallet_migration.py

bitcoin/bitcoin: PR #36968

The review is inconclusive; no findings were published.

Coverage details

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

Migration was explicitly intended to preserve the complete set of output scripts recognized by the legacy wallet, including both native and wrapped P2WSH—not merely the addresses originally imported or currently funded.

PR #31495 explains that migration must compute every output script the legacy wallet watches. Its candidate set includes each stored script as a bare output, P2SH redeemScript, P2WSH witnessScript, and P2SH-P2WSH witnessScript. Filtering those candidates through the original IsMine behavior avoids losing legacy edge cases. The stated tradeoff was retaining IsMine and CanProvide as migration code rather than deleting them. This establishes the compatibility rationale for requiring ismine=true for the wrapped compressed-key output.

Source 1

The original test expressly required descriptors for both P2WSH and P2SH-P2WSH, and separately established that valid compressed-key wsh(pkh()) retains ownership and witness-script information through migration.

Ava Chow's historical test commit says both forms are detected by legacy IsMine and that descriptors for both must reach the descriptor wallet. It deliberately imports sh(wsh(pkh())) to exercise stored-script migration rather than only the watch-only path. Its post-migration assertions check ismine and embedded for the native address. The compressed-key qualification matters: the same test distinguishes valid outputs from disallowed witness-script constructions, for which script information need not survive migration. The current assertion extends the positive check to the already-described wrapped form.

Source 1

Ralph's inferences

Preserving embedded-script reporting for sh(wsh(pkh())) is a supported consequence of the historical compatibility design, but the inspected record does not establish it as a separately articulated wrapped-address RPC guarantee.

The pinned base and head RPC code both retrieve a P2SH redeemScript and recursively describe its embedded destination; the P2WSH visitor similarly retrieves and describes the witnessScript. Retaining the wrapped descriptor and its scripts therefore supports embedded reporting as well as ownership. Combined with the historical native-address assertion, this explains the added wrapped check without claiming that the older test already asserted it. The new assertion checks the presence of embedded, not the complete nested report's contents.

Source 1 · Source 2