From 75540b61169a7975944d8b5bc0e12dcbf50f838d Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Wed, 22 Apr 2015 10:17:14 +1000 Subject: [PATCH] bufferutils: remove equal, use Buffer.compare --- src/bufferutils.js | 11 ----------- src/transaction_builder.js | 4 ++-- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/bufferutils.js b/src/bufferutils.js index 773e502..9f1c85e 100644 --- a/src/bufferutils.js +++ b/src/bufferutils.js @@ -168,16 +168,6 @@ function varIntBuffer (i) { return buffer } -function equal (a, b) { - if (a.length !== b.length) return false - - for (var i = 0; i < a.length; ++i) { - if (a[i] !== b[i]) return false - } - - return true -} - function reverse (buffer) { var buffer2 = new Buffer(buffer) Array.prototype.reverse.call(buffer2) @@ -185,7 +175,6 @@ function reverse (buffer) { } module.exports = { - equal: equal, pushDataSize: pushDataSize, readPushDataInt: readPushDataInt, readUInt64LE: readUInt64LE, diff --git a/src/transaction_builder.js b/src/transaction_builder.js index a08af72..763cd1c 100644 --- a/src/transaction_builder.js +++ b/src/transaction_builder.js @@ -400,7 +400,7 @@ TransactionBuilder.prototype.sign = function (index, keyPair, redeemScript, hash // enforce in order signing of public keys assert(input.pubKeys.some(function (pubKey, i) { - if (!bufferutils.equal(kpPubKey, pubKey)) return false + if (kpPubKey.compare(pubKey) !== 0) return false assert(!input.signatures[i], 'Signature already exists') @@ -408,7 +408,7 @@ TransactionBuilder.prototype.sign = function (index, keyPair, redeemScript, hash input.signatures[i] = signature return true - }, this), 'key pair cannot sign for this input') + }), 'key pair cannot sign for this input') } module.exports = TransactionBuilder