txscript: Optimize typeOfScript pay-to-pubkey-hash.

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, it converts the detection of pay-to-pubkey-hash scripts
to use raw script analysis.
This commit is contained in:
Dave Collins 2019-03-13 01:11:45 -05:00 committed by Olaoluwa Osuntokun
parent 1133ea0bb3
commit 13f646243d
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -464,6 +464,8 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass {
switch {
case isPubKeyScript(script):
return PubKeyTy
case isPubKeyHashScript(script):
return PubKeyHashTy
case isScriptHashScript(script):
return ScriptHashTy
case isMultisigScript(scriptVersion, script):
@ -475,9 +477,7 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass {
return NonStandardTy
}
if isPubkeyHash(pops) {
return PubKeyHashTy
} else if isWitnessPubKeyHash(pops) {
if isWitnessPubKeyHash(pops) {
return WitnessV0PubKeyHashTy
} else if isWitnessScriptHash(pops) {
return WitnessV0ScriptHashTy