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 Roy Lee
parent cb4018a1d4
commit c52f41a5af

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