Skip to content
This repository was archived by the owner on Oct 22, 2026. It is now read-only.

plan: fix missing signatures for fresh Taproot script spends - #1062

Merged
apoelstra merged 1 commit into
rust-bitcoin:masterfrom
starius:plan-tap-leaf-hash
Oct 16, 2026
Merged

apoelstra merged 1 commit into
rust-bitcoin:masterfrom
starius:plan-tap-leaf-hash

Conversation

@starius

@starius starius commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

When Plan::update_psbt_input prepares a fresh PSBT input for a Taproot script spend, it records the signing keys but gives their tap_key_origins entries an empty leaf-hash list. That list tells the signer which scripts to sign. With no hashes listed, rust-bitcoin's Psbt::sign produces no script-path signature, even when it has the required private key.

Initialize new entries with the selected script's leaf hash. New key-path entries get an empty list, since those spends use no script.

The tests check leaf hashes for key spends and pkh/multi_a leaves, accumulation without duplicates across repeated updates, and signing a freshly prepared script spend.

This pre-existing bug was found while working on #954.

🤖 AI disclosure: The patch and tests were generated with Claude Opus 5.5. Codex reviewed the change and drafted this description.

When applying a script-path plan to a fresh PSBT input,
update_psbt_input recorded the signing keys but omitted the selected
script's leaf hash. rust-bitcoin's Psbt::sign uses these hashes to
choose scripts to sign, so it produced no script-path signature.

Initialize new key-origin entries with the selected leaf hash.
New key-path entries remain empty; existing entries continue to
accumulate hashes without duplicates.

Test leaf-hash metadata, repeated updates, and signing a freshly
prepared script spend.

Assisted-by: Claude Opus 5.5

@apoelstra apoelstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 3e9074d; successfully ran local tests

@apoelstra
apoelstra merged commit d7d1610 into rust-bitcoin:master Oct 16, 2026
13 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants