11var baddress = require ( './address' )
22var bcrypto = require ( './crypto' )
33var bscript = require ( './script' )
4- var bufferutils = require ( './bufferutils' )
4+ var bufferEquals = require ( 'buffer-equals' )
5+ var bufferReverse = require ( 'buffer-reverse/inplace' )
56var networks = require ( './networks' )
67var ops = require ( './opcodes' )
78
@@ -17,7 +18,7 @@ function fixMSSignatures (transaction, vin, pubKeys, signatures, prevOutScript,
1718
1819 return pubKeys . map ( function ( pubKey ) {
1920 // skip optionally provided pubKey
20- if ( skipPubKey && bufferutils . equal ( skipPubKey , pubKey ) ) return undefined
21+ if ( skipPubKey && bufferEquals ( skipPubKey , pubKey ) ) return undefined
2122
2223 var matched
2324 var keyPair2 = ECPair . fromPublicKeyBuffer ( pubKey )
@@ -173,7 +174,7 @@ TransactionBuilder.prototype.addInput = function (txHash, vout, sequence, prevOu
173174 if ( typeof txHash === 'string' ) {
174175 // transaction hashs's are displayed in reverse order, un-reverse it
175176 txHash = new Buffer ( txHash , 'hex' )
176- Array . prototype . reverse . call ( txHash )
177+ bufferReverse ( txHash )
177178
178179 // is it a Transaction object?
179180 } else if ( txHash instanceof Transaction ) {
@@ -346,7 +347,7 @@ TransactionBuilder.prototype.sign = function (index, keyPair, redeemScript, hash
346347 if ( canSign ) {
347348 // if redeemScript was provided, enforce consistency
348349 if ( redeemScript ) {
349- if ( ! bufferutils . equal ( input . redeemScript , redeemScript ) ) throw new Error ( 'Inconsistent redeemScript' )
350+ if ( ! bufferEquals ( input . redeemScript , redeemScript ) ) throw new Error ( 'Inconsistent redeemScript' )
350351 }
351352
352353 if ( input . hashType !== hashType ) throw new Error ( 'Inconsistent hashType' )
@@ -360,7 +361,7 @@ TransactionBuilder.prototype.sign = function (index, keyPair, redeemScript, hash
360361 if ( input . prevOutType !== 'scripthash' ) throw new Error ( 'PrevOutScript must be P2SH' )
361362
362363 var scriptHash = bscript . decompile ( input . prevOutScript ) [ 1 ]
363- if ( ! bufferutils . equal ( scriptHash , bcrypto . hash160 ( redeemScript ) ) ) throw new Error ( 'RedeemScript does not match ' + scriptHash . toString ( 'hex' ) )
364+ if ( ! bufferEquals ( scriptHash , bcrypto . hash160 ( redeemScript ) ) ) throw new Error ( 'RedeemScript does not match ' + scriptHash . toString ( 'hex' ) )
364365 }
365366
366367 var scriptType = bscript . classifyOutput ( redeemScript )
@@ -377,7 +378,7 @@ TransactionBuilder.prototype.sign = function (index, keyPair, redeemScript, hash
377378 var pkh1 = redeemScriptChunks [ 2 ]
378379 var pkh2 = bcrypto . hash160 ( keyPair . getPublicKeyBuffer ( ) )
379380
380- if ( ! bufferutils . equal ( pkh1 , pkh2 ) ) throw new Error ( 'privateKey cannot sign for this input' )
381+ if ( ! bufferEquals ( pkh1 , pkh2 ) ) throw new Error ( 'privateKey cannot sign for this input' )
381382 pubKeys = [ kpPubKey ]
382383
383384 break
@@ -427,7 +428,7 @@ TransactionBuilder.prototype.sign = function (index, keyPair, redeemScript, hash
427428
428429 // enforce in order signing of public keys
429430 var valid = input . pubKeys . some ( function ( pubKey , i ) {
430- if ( ! bufferutils . equal ( kpPubKey , pubKey ) ) return false
431+ if ( ! bufferEquals ( kpPubKey , pubKey ) ) return false
431432 if ( input . signatures [ i ] ) throw new Error ( 'Signature already exists' )
432433
433434 var signature = keyPair . sign ( signatureHash )
0 commit comments