From d80863da921d21dcea851605ca8d74b621bb339e Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Thu, 4 Feb 2021 15:15:45 -0800 Subject: [PATCH] txscript: Optimize typeOfScript for null data scripts This continues the process of converting the typeOfScript function to use a combination of raw script analysize and the tokenizer instead of parsed opcode, with the intent of significanty optimizing the function. In particular, it converts the detection of null data scripts to use raw script analysis. --- txscript/standard.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/txscript/standard.go b/txscript/standard.go index ff382537..bae2b0c5 100644 --- a/txscript/standard.go +++ b/txscript/standard.go @@ -458,6 +458,8 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass { return ScriptHashTy case isMultisigScript(scriptVersion, script): return MultiSigTy + case isNullDataScript(scriptVersion, script): + return NullDataTy } pops, err := parseScript(script) @@ -469,9 +471,8 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass { return WitnessV0PubKeyHashTy } else if isWitnessScriptHash(pops) { return WitnessV0ScriptHashTy - } else if isNullData(pops) { - return NullDataTy } + return NonStandardTy }