diff --git a/src/transaction.js b/src/transaction.js index 90fd755..db28666 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -306,8 +306,6 @@ Transaction.prototype.hashForSignature = function (inIndex, prevOutScript, hashT Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, amount, hashType) { typeforce(types.tuple(types.UInt32, types.Buffer, types.Satoshi, types.UInt32), arguments) - var hashOutputs, hashPrevouts, hashSequence - var tbuffer, toffset function writeSlice (slice) { toffset += slice.copy(tbuffer, toffset) } function writeUInt32 (i) { toffset = tbuffer.writeUInt32LE(i, toffset) } @@ -315,6 +313,10 @@ Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, amoun function writeVarInt (i) { toffset += bufferutils.writeVarInt(tbuffer, i, toffset) } function writeVarSlice (slice) { writeVarInt(slice.length); writeSlice(slice) } + var hashOutputs = ZERO + var hashPrevouts = ZERO + var hashSequence = ZERO + if (!(hashType & Transaction.SIGHASH_ANYONECANPAY)) { tbuffer = new Buffer(36 * this.ins.length) toffset = 0 @@ -366,10 +368,6 @@ Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, amoun hashOutputs = bcrypto.hash256(tbuffer) } - hashPrevouts = hashPrevouts || ZERO - hashSequence = hashSequence || ZERO - hashOutputs = hashOutputs || ZERO - tbuffer = new Buffer(156 + varSliceSize(prevOutScript)) toffset = 0