txscript: Use removeOpcodeRaw for CODESEP in calcSigHash
This commit is contained in:
parent
1e3b85cd60
commit
25206b9565
1 changed files with 2 additions and 12 deletions
|
@ -683,24 +683,14 @@ func calcSignatureHashRaw(sigScript []byte, hashType SigHashType, tx *wire.MsgTx
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove all instances of OP_CODESEPARATOR from the script.
|
// Remove all instances of OP_CODESEPARATOR from the script.
|
||||||
filteredScript := make([]byte, 0, len(sigScript))
|
sigScript = removeOpcodeRaw(sigScript, OP_CODESEPARATOR)
|
||||||
const scriptVersion = 0
|
|
||||||
tokenizer := MakeScriptTokenizer(scriptVersion, sigScript)
|
|
||||||
var prevOffset int32
|
|
||||||
for tokenizer.Next() {
|
|
||||||
if tokenizer.Opcode() != OP_CODESEPARATOR {
|
|
||||||
filteredScript = append(filteredScript,
|
|
||||||
sigScript[prevOffset:tokenizer.ByteIndex()]...)
|
|
||||||
}
|
|
||||||
prevOffset = tokenizer.ByteIndex()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make a shallow copy of the transaction, zeroing out the script for
|
// Make a shallow copy of the transaction, zeroing out the script for
|
||||||
// all inputs that are not currently being processed.
|
// all inputs that are not currently being processed.
|
||||||
txCopy := shallowCopyTx(tx)
|
txCopy := shallowCopyTx(tx)
|
||||||
for i := range txCopy.TxIn {
|
for i := range txCopy.TxIn {
|
||||||
if i == idx {
|
if i == idx {
|
||||||
txCopy.TxIn[idx].SignatureScript = filteredScript
|
txCopy.TxIn[idx].SignatureScript = sigScript
|
||||||
} else {
|
} else {
|
||||||
txCopy.TxIn[i].SignatureScript = nil
|
txCopy.TxIn[i].SignatureScript = nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue