@@ -35,11 +35,11 @@ Transaction.SIGHASH_ANYONECANPAY = 0x80
3535Transaction . ADVANCED_TRANSACTION_MARKER = 0x00
3636Transaction . ADVANCED_TRANSACTION_FLAG = 0x01
3737
38- var EMPTY_SCRIPT = new Buffer ( 0 )
38+ var EMPTY_SCRIPT = Buffer . allocUnsafe ( 0 )
3939var EMPTY_WITNESS = [ ]
40- var ZERO = new Buffer ( '0000000000000000000000000000000000000000000000000000000000000000' , 'hex' )
41- var ONE = new Buffer ( '0000000000000000000000000000000000000000000000000000000000000001' , 'hex' )
42- var VALUE_UINT64_MAX = new Buffer ( 'ffffffffffffffff' , 'hex' )
40+ var ZERO = Buffer . from ( '0000000000000000000000000000000000000000000000000000000000000000' , 'hex' )
41+ var ONE = Buffer . from ( '0000000000000000000000000000000000000000000000000000000000000001' , 'hex' )
42+ var VALUE_UINT64_MAX = Buffer . from ( 'ffffffffffffffff' , 'hex' )
4343var BLANK_OUTPUT = {
4444 script : EMPTY_SCRIPT ,
4545 valueBuffer : VALUE_UINT64_MAX
@@ -298,7 +298,7 @@ Transaction.prototype.hashForSignature = function (inIndex, prevOutScript, hashT
298298 }
299299
300300 // serialize and hash
301- var buffer = new Buffer ( txTmp . __byteLength ( false ) + 4 )
301+ var buffer = Buffer . allocUnsafe ( txTmp . __byteLength ( false ) + 4 )
302302 buffer . writeInt32LE ( hashType , buffer . length - 4 )
303303 txTmp . __toBuffer ( buffer , 0 , false )
304304
@@ -323,7 +323,7 @@ Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, value
323323 var hashSequence = ZERO
324324
325325 if ( ! ( hashType & Transaction . SIGHASH_ANYONECANPAY ) ) {
326- tbuffer = new Buffer ( 36 * this . ins . length )
326+ tbuffer = Buffer . allocUnsafe ( 36 * this . ins . length )
327327 toffset = 0
328328
329329 this . ins . forEach ( function ( txIn ) {
@@ -337,7 +337,7 @@ Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, value
337337 if ( ! ( hashType & Transaction . SIGHASH_ANYONECANPAY ) &&
338338 ( hashType & 0x1f ) !== Transaction . SIGHASH_SINGLE &&
339339 ( hashType & 0x1f ) !== Transaction . SIGHASH_NONE ) {
340- tbuffer = new Buffer ( 4 * this . ins . length )
340+ tbuffer = Buffer . allocUnsafe ( 4 * this . ins . length )
341341 toffset = 0
342342
343343 this . ins . forEach ( function ( txIn ) {
@@ -353,7 +353,7 @@ Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, value
353353 return sum + 8 + varSliceSize ( output . script )
354354 } , 0 )
355355
356- tbuffer = new Buffer ( txOutsSize )
356+ tbuffer = Buffer . allocUnsafe ( txOutsSize )
357357 toffset = 0
358358
359359 this . outs . forEach ( function ( out ) {
@@ -365,15 +365,15 @@ Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, value
365365 } else if ( ( hashType & 0x1f ) === Transaction . SIGHASH_SINGLE && inIndex < this . outs . length ) {
366366 var output = this . outs [ inIndex ]
367367
368- tbuffer = new Buffer ( 8 + varSliceSize ( output . script ) )
368+ tbuffer = Buffer . allocUnsafe ( 8 + varSliceSize ( output . script ) )
369369 toffset = 0
370370 writeUInt64 ( output . value )
371371 writeVarSlice ( output . script )
372372
373373 hashOutputs = bcrypto . hash256 ( tbuffer )
374374 }
375375
376- tbuffer = new Buffer ( 156 + varSliceSize ( prevOutScript ) )
376+ tbuffer = Buffer . allocUnsafe ( 156 + varSliceSize ( prevOutScript ) )
377377 toffset = 0
378378
379379 var input = this . ins [ inIndex ]
@@ -405,7 +405,7 @@ Transaction.prototype.toBuffer = function (buffer, initialOffset) {
405405}
406406
407407Transaction . prototype . __toBuffer = function ( buffer , initialOffset , __allowWitness ) {
408- if ( ! buffer ) buffer = new Buffer ( this . __byteLength ( __allowWitness ) )
408+ if ( ! buffer ) buffer = Buffer . allocUnsafe ( this . __byteLength ( __allowWitness ) )
409409
410410 var offset = initialOffset || 0
411411 function writeSlice ( slice ) { offset += slice . copy ( buffer , offset ) }
0 commit comments