txscript: Use internal analysis methods for GetWitnessSigOpCount

This commit is contained in:
Conner Fromknecht 2021-02-05 01:58:59 -08:00 committed by Olaoluwa Osuntokun
parent 8b706344a1
commit 4b03b59391
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -832,15 +832,15 @@ func GetPreciseSigOpCount(scriptSig, scriptPubKey []byte, _ bool) int {
func GetWitnessSigOpCount(sigScript, pkScript []byte, witness wire.TxWitness) int { func GetWitnessSigOpCount(sigScript, pkScript []byte, witness wire.TxWitness) int {
// If this is a regular witness program, then we can proceed directly // If this is a regular witness program, then we can proceed directly
// to counting its signature operations without any further processing. // to counting its signature operations without any further processing.
if IsWitnessProgram(pkScript) { if isWitnessProgramScript(pkScript) {
return getWitnessSigOps(pkScript, witness) return getWitnessSigOps(pkScript, witness)
} }
// Next, we'll check the sigScript to see if this is a nested p2sh // Next, we'll check the sigScript to see if this is a nested p2sh
// witness program. This is a case wherein the sigScript is actually a // witness program. This is a case wherein the sigScript is actually a
// datapush of a p2wsh witness program. // datapush of a p2wsh witness program.
if IsPayToScriptHash(pkScript) && IsPushOnlyScript(sigScript) && if isScriptHashScript(pkScript) && IsPushOnlyScript(sigScript) &&
IsWitnessProgram(sigScript[1:]) { len(sigScript) > 0 && isWitnessProgramScript(sigScript[1:]) {
return getWitnessSigOps(sigScript[1:], witness) return getWitnessSigOps(sigScript[1:], witness)
} }