Browse Source

Merge pull request #478 from bitcoinjs/norev

remove use of buffer-reverse
hk-custom-address
Daniel Cousens 9 years ago
parent
commit
85a399d46b
  1. 2
      src/block.js
  2. 2
      src/transaction.js
  3. 3
      src/transaction_builder.js
  4. 4
      test/bitcoin.core.js
  5. 2
      test/integration/crypto.js
  6. 2
      test/transaction_builder.js

2
src/block.js

@ -70,7 +70,7 @@ Block.prototype.getHash = function () {
}
Block.prototype.getId = function () {
return Array.prototype.reverse.call(this.getHash()).toString('hex')
return [].reverse.call(this.getHash()).toString('hex')
}
Block.prototype.getUTCDate = function () {

2
src/transaction.js

@ -247,7 +247,7 @@ Transaction.prototype.getHash = function () {
Transaction.prototype.getId = function () {
// transaction hash's are displayed in reverse order
return Array.prototype.reverse.call(this.getHash()).toString('hex')
return [].reverse.call(this.getHash()).toString('hex')
}
Transaction.prototype.toBuffer = function () {

3
src/transaction_builder.js

@ -172,8 +172,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 = new Buffer(txHash, 'hex')
Array.prototype.reverse.call(txHash)
txHash = [].reverse.call(new Buffer(txHash, 'hex'))
// is it a Transaction object?
} else if (txHash instanceof Transaction) {

4
test/bitcoin.core.js

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

2
test/integration/crypto.js

@ -134,7 +134,7 @@ describe('bitcoinjs-lib (crypto)', function () {
assert(bitcoin.script.isPubKeyHashInput(scriptChunks), 'Expected pubKeyHash script')
var prevOutTxId = Array.prototype.reverse.call(new Buffer(transaction.ins[input.vout].hash)).toString('hex')
var prevOutTxId = [].reverse.call(new Buffer(transaction.ins[input.vout].hash)).toString('hex')
var prevVout = transaction.ins[input.vout].index
tasks.push(function (callback) {

2
test/transaction_builder.js

@ -91,7 +91,7 @@ describe('TransactionBuilder', function () {
var tx = new Transaction()
f.inputs.forEach(function (input) {
var txHash = Array.prototype.reverse.call(new Buffer(input.txId, 'hex'))
var txHash = [].reverse.call(new Buffer(input.txId, 'hex'))
tx.addInput(txHash, input.vout, undefined, bscript.fromASM(input.scriptSig))
})

Loading…
Cancel
Save