txscript: Use optimized calcWitnessSignatureHashRaw w/o parsing

This commit is contained in:
Conner Fromknecht 2019-04-19 15:26:10 -07:00 committed by Olaoluwa Osuntokun
parent ed9e17a043
commit e00fec1557
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -521,13 +521,12 @@ func calcWitnessSignatureHash(subScript []parsedOpcode, sigHashes *TxSigHashes,
func CalcWitnessSigHash(script []byte, sigHashes *TxSigHashes, hType SigHashType, func CalcWitnessSigHash(script []byte, sigHashes *TxSigHashes, hType SigHashType,
tx *wire.MsgTx, idx int, amt int64) ([]byte, error) { tx *wire.MsgTx, idx int, amt int64) ([]byte, error) {
parsedScript, err := parseScript(script) const scriptVersion = 0
if err != nil { if err := checkScriptParses(scriptVersion, script); err != nil {
return nil, fmt.Errorf("cannot parse output script: %v", err) return nil, err
} }
return calcWitnessSignatureHash(parsedScript, sigHashes, hType, tx, idx, return calcWitnessSignatureHashRaw(script, sigHashes, hType, tx, idx, amt)
amt)
} }
// shallowCopyTx creates a shallow copy of the transaction for use when // shallowCopyTx creates a shallow copy of the transaction for use when