plan: add Plan::tap_sighash_default accessor#949
Closed
evanlinjin wants to merge 1 commit into
Closed
Conversation
Exposes the existing per-Schnorr-placeholder size assumption — recorded when the plan was built from `TaprootCanSign::sighash_default` — as a single `Option<bool>` on the Plan. Returns `Some(true)` when every Schnorr placeholder is sized for a 64-byte signature (SIGHASH_DEFAULT), `Some(false)` when every one is sized for 65 bytes (any non-Default Taproot sighash flag), and `None` for non-Taproot plans or mixed plans that cannot be expressed by a single uniform sighash policy per BIP-174. Callers constructing a PSBT can use this to populate `PSBT_IN_SIGHASH_TYPE` consistently with the witness-size assumption baked into `Plan::satisfaction_weight`.
1 task
Contributor
Author
|
Fully AI generated - I need to ensure it didn't screw up before I take it out of draft. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a public accessor on
Planthat exposes the existing per-Schnorr-placeholder size assumption — recorded when the plan was built fromTaprootCanSign::sighash_default— as a singleOption<bool>.Some(true)— every Schnorr placeholder is sized for a 64-byte signature (theSIGHASH_DEFAULTencoding).Some(false)— every Schnorr placeholder is sized for a 65-byte signature (any non-Default Taproot sighash flag).None— non-Taproot plans (signature size is invariant under the sighash flag for ECDSA), or mixed plans whose Schnorr placeholders have differing sizes — these cannot be expressed by a single uniform sighash policy per BIP-174.Motivation
Callers building a PSBT from a
Planneed to populatePSBT_IN_SIGHASH_TYPEconsistently with the plan's witness-size assumption — otherwise weight estimates drift from reality. The information already lives inside the plan (on every Schnorr placeholder'ssizefield); this just surfaces it as a single readable answer.Concretely:
bdk-txis reworking per-input sighash handling and needs to derive the PSBT sighash policy from the plan rather than carrying separate state on itsInputtype (see bitcoindevkit/bdk-tx#69 for the full design). Without this accessor it would have to walkPlan::witness_template()and infer the bool from placeholder sizes, which leaks internals.Test plan
cargo test --lib tap_sighash_default— new test covers Default-Taproot, non-Default-Taproot, and non-Taproot (wsh) plans.cargo test— full suite still passes (139 / 0 / 0).🤖 Generated with Claude Code