Browse Source

remove use of buffer-reverse

hk-custom-address
Daniel Cousens 9 years ago
parent
commit
5c1c4589c0
  1. 3
      src/block.js
  2. 3
      src/transaction.js
  3. 3
      src/transaction_builder.js
  4. 5
      test/bitcoin.core.js
  5. 3
      test/integration/crypto.js
  6. 3
      test/transaction_builder.js

3
src/block.js

@ -1,6 +1,5 @@
var bufferutils = require('./bufferutils')
var bcrypto = require('./crypto')
var bufferReverse = require('buffer-reverse')
var Transaction = require('./transaction')
@ -71,7 +70,7 @@ Block.prototype.getHash = function () {
}
Block.prototype.getId = function () {
return bufferReverse(this.getHash()).toString('hex')
return Array.prototype.reverse.call(this.getHash()).toString('hex')
}
Block.prototype.getUTCDate = function () {

3
src/transaction.js

@ -1,6 +1,5 @@
var bcrypto = require('./crypto')
var bscript = require('./script')
var bufferReverse = require('buffer-reverse')
var bufferutils = require('./bufferutils')
var opcodes = require('./opcodes')
var typeforce = require('typeforce')
@ -248,7 +247,7 @@ Transaction.prototype.getHash = function () {
Transaction.prototype.getId = function () {
// transaction hash's are displayed in reverse order
return bufferReverse(this.getHash()).toString('hex')
return Array.prototype.reverse.call(this.getHash()).toString('hex')
}
Transaction.prototype.toBuffer = function () {

3
src/transaction_builder.js

@ -2,7 +2,6 @@ var baddress = require('./address')
var bcrypto = require('./crypto')
var bscript = require('./script')
var bufferEquals = require('buffer-equals')
var bufferReverse = require('buffer-reverse/inplace')
var networks = require('./networks')
var ops = require('./opcodes')
@ -174,7 +173,7 @@ TransactionBuilder.prototype.addInput = function (txHash, vout, sequence, prevOu
if (typeof txHash === 'string') {
// transaction hashs's are displayed in reverse order, un-reverse it
txHash = new Buffer(txHash, 'hex')
bufferReverse(txHash)
Array.prototype.reverse.call(txHash)
// is it a Transaction object?
} else if (txHash instanceof Transaction) {

5
test/bitcoin.core.js

@ -3,7 +3,6 @@
var assert = require('assert')
var base58 = require('bs58')
var bitcoin = require('../')
var bufferReverse = require('buffer-reverse')
var base58_encode_decode = require('./fixtures/core/base58_encode_decode.json')
var base58_keys_invalid = require('./fixtures/core/base58_keys_invalid.json')
@ -151,7 +150,7 @@ describe('Bitcoin-core', function () {
var input = inputs[i]
// reverse because test data is reversed
var prevOutHash = bufferReverse(new Buffer(input[0], 'hex'))
var prevOutHash = Array.prototype.reverse.call(new Buffer(input[0], 'hex'))
var prevOutIndex = input[1]
assert.deepEqual(txIn.hash, prevOutHash)
@ -204,7 +203,7 @@ describe('Bitcoin-core', function () {
var hashType = f[3]
// reverse because test data is reversed
var expectedHash = bufferReverse(new Buffer(f[4], 'hex'))
var expectedHash = Array.prototype.reverse.call(new Buffer(f[4], 'hex'))
var hashTypes = []
if ((hashType & 0x1f) === bitcoin.Transaction.SIGHASH_NONE) hashTypes.push('SIGHASH_NONE')

3
test/integration/crypto.js

@ -5,7 +5,6 @@ var async = require('async')
var bigi = require('bigi')
var bitcoin = require('../../')
var blockchain = require('./_blockchain')
var bufferReverse = require('buffer-reverse')
var crypto = require('crypto')
var ecurve = require('ecurve')
@ -135,7 +134,7 @@ describe('bitcoinjs-lib (crypto)', function () {
assert(bitcoin.script.isPubKeyHashInput(scriptChunks), 'Expected pubKeyHash script')
var prevOutTxId = bufferReverse(transaction.ins[input.vout].hash).toString('hex')
var prevOutTxId = Array.prototype.reverse.call(new Buffer(transaction.ins[input.vout].hash)).toString('hex')
var prevVout = transaction.ins[input.vout].index
tasks.push(function (callback) {

3
test/transaction_builder.js

@ -3,7 +3,6 @@
var assert = require('assert')
var baddress = require('../src/address')
var bscript = require('../src/script')
var bufferReverse = require('buffer-reverse')
var ops = require('../src/opcodes')
var BigInteger = require('bigi')
@ -92,7 +91,7 @@ describe('TransactionBuilder', function () {
var tx = new Transaction()
f.inputs.forEach(function (input) {
var txHash = bufferReverse(new Buffer(input.txId, 'hex'))
var txHash = Array.prototype.reverse.call(new Buffer(input.txId, 'hex'))
tx.addInput(txHash, input.vout, undefined, bscript.fromASM(input.scriptSig))
})

Loading…
Cancel
Save