Transaction: initialize to ZERO earlier
This commit is contained in:
parent
20577d42f2
commit
bdf6a9d458
@ -306,8 +306,6 @@ Transaction.prototype.hashForSignature = function (inIndex, prevOutScript, hashT
|
|||||||
Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, amount, hashType) {
|
Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, amount, hashType) {
|
||||||
typeforce(types.tuple(types.UInt32, types.Buffer, types.Satoshi, types.UInt32), arguments)
|
typeforce(types.tuple(types.UInt32, types.Buffer, types.Satoshi, types.UInt32), arguments)
|
||||||
|
|
||||||
var hashOutputs, hashPrevouts, hashSequence
|
|
||||||
|
|
||||||
var tbuffer, toffset
|
var tbuffer, toffset
|
||||||
function writeSlice (slice) { toffset += slice.copy(tbuffer, toffset) }
|
function writeSlice (slice) { toffset += slice.copy(tbuffer, toffset) }
|
||||||
function writeUInt32 (i) { toffset = tbuffer.writeUInt32LE(i, 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 writeVarInt (i) { toffset += bufferutils.writeVarInt(tbuffer, i, toffset) }
|
||||||
function writeVarSlice (slice) { writeVarInt(slice.length); writeSlice(slice) }
|
function writeVarSlice (slice) { writeVarInt(slice.length); writeSlice(slice) }
|
||||||
|
|
||||||
|
var hashOutputs = ZERO
|
||||||
|
var hashPrevouts = ZERO
|
||||||
|
var hashSequence = ZERO
|
||||||
|
|
||||||
if (!(hashType & Transaction.SIGHASH_ANYONECANPAY)) {
|
if (!(hashType & Transaction.SIGHASH_ANYONECANPAY)) {
|
||||||
tbuffer = new Buffer(36 * this.ins.length)
|
tbuffer = new Buffer(36 * this.ins.length)
|
||||||
toffset = 0
|
toffset = 0
|
||||||
@ -366,10 +368,6 @@ Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, amoun
|
|||||||
hashOutputs = bcrypto.hash256(tbuffer)
|
hashOutputs = bcrypto.hash256(tbuffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
hashPrevouts = hashPrevouts || ZERO
|
|
||||||
hashSequence = hashSequence || ZERO
|
|
||||||
hashOutputs = hashOutputs || ZERO
|
|
||||||
|
|
||||||
tbuffer = new Buffer(156 + varSliceSize(prevOutScript))
|
tbuffer = new Buffer(156 + varSliceSize(prevOutScript))
|
||||||
toffset = 0
|
toffset = 0
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user