diff --git a/.travis.yml b/.travis.yml index 365e843..a5394ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,15 @@ sudo: false language: node_js node_js: - - "0.12" - "4" - "5" - "6" + - "7" matrix: include: - - node_js: "6" + - node_js: "7" env: TEST_SUITE=standard - - node_js: "6" + - node_js: "7" env: TEST_SUITE=coverage env: - TEST_SUITE=integration diff --git a/package.json b/package.json index 95f7f33..3db0a20 100644 --- a/package.json +++ b/package.json @@ -54,8 +54,7 @@ "bigi": "^1.4.0", "bip66": "^1.1.0", "bitcoin-ops": "^1.3.0", - "bs58check": "^1.0.5", - "buffer-reverse": "^1.0.0", + "bs58check": "^2.0.0", "create-hash": "^1.1.0", "create-hmac": "^1.1.3", "ecurve": "^1.0.0", @@ -68,7 +67,7 @@ }, "devDependencies": { "async": "^2.0.1", - "bs58": "^3.0.0", + "bs58": "^4.0.0", "cb-http-client": "^0.2.0", "coinselect": "^3.1.1", "minimaldata": "^1.0.2", diff --git a/src/block.js b/src/block.js index ba383d5..f1d8b67 100644 --- a/src/block.js +++ b/src/block.js @@ -1,6 +1,5 @@ var bufferutils = require('./bufferutils') var bcrypto = require('./crypto') -var bufferReverse = require('buffer-reverse') var fastMerkleRoot = require('merkle-lib/fastRoot') var typeforce = require('typeforce') var types = require('./types') @@ -80,7 +79,7 @@ Block.prototype.getHash = function () { } Block.prototype.getId = function () { - return bufferReverse(this.getHash()).toString('hex') + return this.getHash().reverse().toString('hex') } Block.prototype.getUTCDate = function () { @@ -164,7 +163,7 @@ Block.prototype.checkMerkleRoot = function () { } Block.prototype.checkProofOfWork = function () { - var hash = bufferReverse(this.getHash()) + var hash = this.getHash().reverse() var target = Block.calculateTarget(this.bits) return hash.compare(target) <= 0 diff --git a/src/transaction.js b/src/transaction.js index 4a6aa81..dc184b8 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -1,7 +1,6 @@ var bcrypto = require('./crypto') var bscript = require('./script') var bufferutils = require('./bufferutils') -var bufferReverse = require('buffer-reverse') var opcodes = require('bitcoin-ops') var typeforce = require('typeforce') var types = require('./types') @@ -395,7 +394,7 @@ Transaction.prototype.getHash = function () { Transaction.prototype.getId = function () { // transaction hash's are displayed in reverse order - return bufferReverse(this.getHash()).toString('hex') + return this.getHash().reverse().toString('hex') } Transaction.prototype.toBuffer = function (buffer, initialOffset) { diff --git a/src/transaction_builder.js b/src/transaction_builder.js index b2b7f94..778f593 100644 --- a/src/transaction_builder.js +++ b/src/transaction_builder.js @@ -1,7 +1,6 @@ var baddress = require('./address') var bcrypto = require('./crypto') var bscript = require('./script') -var bufferReverse = require('buffer-reverse') var networks = require('./networks') var ops = require('bitcoin-ops') var typeforce = require('typeforce') @@ -299,7 +298,7 @@ TransactionBuilder.prototype.addInput = function (txHash, vout, sequence, prevOu // is it a hex string? if (typeof txHash === 'string') { // transaction hashs's are displayed in reverse order, un-reverse it - txHash = bufferReverse(new Buffer(txHash, 'hex')) + txHash = new Buffer(txHash, 'hex').reverse() // is it a Transaction object? } else if (txHash instanceof Transaction) { diff --git a/test/bitcoin.core.js b/test/bitcoin.core.js index f410e3f..b548643 100644 --- a/test/bitcoin.core.js +++ b/test/bitcoin.core.js @@ -22,7 +22,7 @@ describe('Bitcoin-core', function () { it('can decode ' + fb58, function () { var buffer = base58.decode(fb58) - var actual = new Buffer(buffer).toString('hex') + var actual = buffer.toString('hex') assert.strictEqual(actual, fhex) }) @@ -150,7 +150,7 @@ describe('Bitcoin-core', function () { var input = inputs[i] // reverse because test data is reversed - var prevOutHash = [].reverse.call(new Buffer(input[0], 'hex')) + var prevOutHash = new Buffer(input[0], 'hex').reverse() var prevOutIndex = input[1] assert.deepEqual(txIn.hash, prevOutHash) @@ -193,7 +193,7 @@ describe('Bitcoin-core', function () { var hash = transaction.hashForSignature(inIndex, script, hashType) // reverse because test data is reversed - assert.equal([].reverse.call(hash).toString('hex'), expectedHash) + assert.equal(hash.reverse().toString('hex'), expectedHash) }) }) }) diff --git a/test/integration/crypto.js b/test/integration/crypto.js index 4f28618..9239443 100644 --- a/test/integration/crypto.js +++ b/test/integration/crypto.js @@ -45,7 +45,7 @@ describe('bitcoinjs-lib (crypto)', function () { assert(bitcoin.script.pubKeyHash.input.check(scriptChunks), 'Expected pubKeyHash script') - var prevOutTxId = [].reverse.call(new Buffer(transaction.ins[input.vout].hash)).toString('hex') + var prevOutTxId = new Buffer(transaction.ins[input.vout].hash).reverse().toString('hex') var prevVout = transaction.ins[input.vout].index tasks.push(function (callback) { diff --git a/test/transaction_builder.js b/test/transaction_builder.js index 0be43b5..a33c075 100644 --- a/test/transaction_builder.js +++ b/test/transaction_builder.js @@ -95,7 +95,7 @@ describe('TransactionBuilder', function () { var tx = new Transaction() f.inputs.forEach(function (input) { - var txHash = [].reverse.call(new Buffer(input.txId, 'hex')) + var txHash = new Buffer(input.txId, 'hex').reverse() tx.addInput(txHash, input.vout, undefined, bscript.fromASM(input.scriptSig)) })