Skip to content

Commit

Permalink
cannot make any assumptions about pk script from witness
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 committed Nov 8, 2021
1 parent b9a34e5 commit 93b8570
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions txscript/pkscript.go
Expand Up @@ -238,26 +238,11 @@ func computeNonWitnessPkScript(sigScript []byte) (PkScript, error) {

// computeWitnessPkScript computes the script of an output by looking at the
// spending input's witness.
// IMPORTANT: With the addition of taproot, we can no longer say for certain
// what kind of script the witness is in most cases. The only case in which we
// can say for sure is when the witness data has an annex as the last push. In
// that case, we can identify the script type, but we lack the ability to
// reconstruct the script itself.
// IMPORTANT: With the addition of taproot, we can not say for certain
// what kind of script the witness is.
func computeWitnessPkScript(witness wire.TxWitness) (PkScript, error) {
var pkScript PkScript
switch {
// If the last push starts with the annex flag, this is a taproot spend.
// We can set the script class, but we can't say what the pubkey script
// looks like with just the witness data.
case isAnnexedWitness(witness):
pkScript.class = WitnessV1TaprootTy

// For any other witnesses, we can't say for certain what type it is or what
// the pubkey script will be.
default:
pkScript.class = WitnessUnknownTy
}

pkScript.class = WitnessUnknownTy
return pkScript, nil
}

Expand Down

0 comments on commit 93b8570

Please sign in to comment.