Merge pull request #397 from bitcoinjs/buftools
bufferutils: remove equal, use Buffer.compare
This commit is contained in:
commit
0265c9bb5f
4 changed files with 3 additions and 32 deletions
|
@ -2,8 +2,7 @@ language: node_js
|
|||
before_install:
|
||||
- "npm install npm -g"
|
||||
node_js:
|
||||
- "0.11"
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
env:
|
||||
- TEST_SUITE=coveralls
|
||||
- TEST_SUITE=integration
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
var assert = require('assert')
|
||||
var bufferutils = require('./bufferutils')
|
||||
var ops = require('./opcodes')
|
||||
var scripts = require('./scripts')
|
||||
|
||||
|
@ -400,7 +399,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 +407,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
|
||||
|
|
|
@ -88,22 +88,6 @@ describe('bufferutils', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('equal', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
describe('for ' + f.hexVI, function () {
|
||||
fixtures.valid.forEach(function (f2) {
|
||||
it('equates the string comparison: ' + f.hexVI + ' === ' + f2.hexVI, function () {
|
||||
var a = new Buffer(f.hexVI, 'hex')
|
||||
var b = new Buffer(f2.hexVI, 'hex')
|
||||
var expected = f.hexVI === f2.hexVI
|
||||
|
||||
assert.equal(bufferutils.equal(a, b), expected)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('reverse', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('reverses ' + f.hex64 + ' correctly', function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue