From 5aa00f7ebafd3dfb67fb2865f5dfffd520913739 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 19 Apr 2019 15:26:10 -0700 Subject: [PATCH] txscript: Use optimized calcWitnessSignatureHashRaw w/o parsing --- txscript/script.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/txscript/script.go b/txscript/script.go index 4fab35152e..d4c14fed93 100644 --- a/txscript/script.go +++ b/txscript/script.go @@ -521,13 +521,12 @@ func calcWitnessSignatureHash(subScript []parsedOpcode, sigHashes *TxSigHashes, func CalcWitnessSigHash(script []byte, sigHashes *TxSigHashes, hType SigHashType, tx *wire.MsgTx, idx int, amt int64) ([]byte, error) { - parsedScript, err := parseScript(script) - if err != nil { - return nil, fmt.Errorf("cannot parse output script: %v", err) + const scriptVersion = 0 + if err := checkScriptParses(scriptVersion, script); err != nil { + return nil, err } - return calcWitnessSignatureHash(parsedScript, sigHashes, hType, tx, idx, - amt) + return calcWitnessSignatureHashRaw(script, sigHashes, hType, tx, idx, amt) } // shallowCopyTx creates a shallow copy of the transaction for use when