Skip to content

Commit

Permalink
txscript: Use optimized calcWitnessSignatureHashRaw w/o parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
cfromknecht committed Feb 5, 2021
1 parent bfc2a3e commit 5aa00f7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions txscript/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5aa00f7

Please sign in to comment.