diff --git a/txscript/script.go b/txscript/script.go index 4a0d6686..4397f774 100644 --- a/txscript/script.go +++ b/txscript/script.go @@ -355,9 +355,9 @@ func calcSignatureHash(script []parsedOpcode, hashType SigHashType, tx *wire.Msg // The final hash is the double sha256 of both the serialized modified // transaction and the hash type (encoded as a 4-byte little-endian // value) appended. - var wbuf bytes.Buffer - txCopy.Serialize(&wbuf) - binary.Write(&wbuf, binary.LittleEndian, hashType) + wbuf := bytes.NewBuffer(make([]byte, 0, txCopy.SerializeSize()+4)) + txCopy.Serialize(wbuf) + binary.Write(wbuf, binary.LittleEndian, hashType) return chainhash.DoubleHashB(wbuf.Bytes()) }