From 8b64adc234cfbfd68394898f2eeea0199fdefdb6 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Thu, 4 Feb 2021 14:07:19 -0800 Subject: [PATCH] txscript: Optimze typeOfScript pay-to-pubkey This continues the process of converting the typeOfScript function to use a combination of raw script analysis and the new tokenizer instead of the face less efficient parsed opcodes, with the intent of significantly optimizing the function. In particular, it converts the detection of pay-to-pubkey scripts to use raw script analysis. --- txscript/standard.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/txscript/standard.go b/txscript/standard.go index 2722bc41..52a37478 100644 --- a/txscript/standard.go +++ b/txscript/standard.go @@ -471,6 +471,8 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass { } switch { + case isPubKeyScript(script): + return PubKeyTy case isScriptHashScript(script): return ScriptHashTy case isMultisigScript(scriptVersion, script): @@ -482,9 +484,7 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass { return NonStandardTy } - if isPubkey(pops) { - return PubKeyTy - } else if isPubkeyHash(pops) { + if isPubkeyHash(pops) { return PubKeyHashTy } else if isWitnessPubKeyHash(pops) { return WitnessV0PubKeyHashTy