Skip to content

12.x: Append witness script for P2WSH in Plan::satisfy()#909

Open
evanlinjin wants to merge 1 commit intorust-bitcoin:release-12.xfrom
evanlinjin:fix/12.x-plan-satisft-does-not-append-witness-script-for-p2wsh-v2
Open

12.x: Append witness script for P2WSH in Plan::satisfy()#909
evanlinjin wants to merge 1 commit intorust-bitcoin:release-12.xfrom
evanlinjin:fix/12.x-plan-satisft-does-not-append-witness-script-for-p2wsh-v2

Conversation

@evanlinjin
Copy link
Contributor

@evanlinjin evanlinjin commented Mar 13, 2026

This is a back-port of #897 to the 12.x branch.

This back-port does not include the integration tests.

Are we able to create a patch release of 12.x with this fix included? This is required for bdk_tx to function properly.

Fix Plan::satisfy() to correctly append the witnessScript as the final
witness stack element for P2WSH descriptor types (Wsh, WshSortedMulti,
ShWsh, ShWshSortedMulti).

Previously, these types were incorrectly grouped with Wpkh and Tr,
which don't require a trailing witness script. This caused transactions
built using Plan::satisfy() to fail validation with "Witness program
hash mismatch" when broadcast.

The fix separates the descriptor type handling:
- Wpkh/Tr: return stack as-is (no witness script needed)
- Wsh/WshSortedMulti: append witness script, empty script_sig
- ShWpkh: return stack with unsigned_script_sig (no witness script)
- ShWsh/ShWshSortedMulti: append witness script and unsigned_script_sig

Closes rust-bitcoin#896

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@evanlinjin evanlinjin force-pushed the fix/12.x-plan-satisft-does-not-append-witness-script-for-p2wsh-v2 branch from 5a4bce0 to d6e2afd Compare March 13, 2026 07:48
@apoelstra
Copy link
Member

apoelstra commented Mar 14, 2026

Could you add two commits:

  • One which removes the [ and ] from the doccomment in src/policy/concrete.rs line 352 which starts with the compiler document in (this is unrelated to your PR, but at some point CI started failing because of it, so we might as well fix it here)
  • One which bumps the version of the project to 12.3.6 in Cargo.toml, as well as Cargo-minimal.lock and Cargo-recent.lock (this way we can immediately cut a release with the bugfix after merging)

@apoelstra
Copy link
Member

But otherwise utack d6e2afd -- confirmed this is an exact backport. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants