txscript: Optimize typeOfScript multisig.

This continues the process of converting the typeOfScript function to
use a combination of raw script analysis and the new tokenizer instead
of the far less efficient parsed opcodes.

In particular, for this commit, since the ability to detect multisig
scripts via the new tokenizer is now available, the function is simply
updated to make use of it.
This commit is contained in:
Dave Collins 2019-03-13 01:11:36 -05:00 committed by Olaoluwa Osuntokun
parent 671b5fefef
commit 71bf51e82c
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -509,6 +509,8 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass {
switch { switch {
case isScriptHashScript(script): case isScriptHashScript(script):
return ScriptHashTy return ScriptHashTy
case isMultisigScript(scriptVersion, script):
return MultiSigTy
} }
pops, err := parseScript(script) pops, err := parseScript(script)
@ -524,8 +526,6 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass {
return WitnessV0PubKeyHashTy return WitnessV0PubKeyHashTy
} else if isWitnessScriptHash(pops) { } else if isWitnessScriptHash(pops) {
return WitnessV0ScriptHashTy return WitnessV0ScriptHashTy
} else if isMultiSig(pops) {
return MultiSigTy
} else if isNullData(pops) { } else if isNullData(pops) {
return NullDataTy return NullDataTy
} }