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) {
|
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 a new issue