Transaction: initialize to ZERO earlier
This commit is contained in:
parent
bc4297ce3c
commit
768f7e314c
1 changed files with 4 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue