txscript/pkscript: Use finalOpcodeData to extract redeem script

This commit is contained in:
Conner Fromknecht 2019-04-19 19:31:33 -07:00 committed by Olaoluwa Osuntokun
parent 69f3a39c1c
commit 7533672993
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -211,11 +211,12 @@ func computeNonWitnessPkScript(sigScript []byte) (PkScript, error) {
// The redeem script will always be the last data push of the // The redeem script will always be the last data push of the
// signature script, so we'll parse the script into opcodes to // signature script, so we'll parse the script into opcodes to
// obtain it. // obtain it.
parsedOpcodes, err := parseScript(sigScript) const scriptVersion = 0
err := checkScriptParses(scriptVersion, sigScript)
if err != nil { if err != nil {
return PkScript{}, err return PkScript{}, err
} }
redeemScript := parsedOpcodes[len(parsedOpcodes)-1].data redeemScript := finalOpcodeData(scriptVersion, sigScript)
scriptHash := hash160(redeemScript) scriptHash := hash160(redeemScript)
script, err := payToScriptHashScript(scriptHash) script, err := payToScriptHashScript(scriptHash)