From f2f07471878253396ed2e9c292558618c5ed57ee Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Tue, 11 Aug 2015 17:09:34 +1000 Subject: [PATCH] Transaction: remove use of assert --- src/transaction.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/transaction.js b/src/transaction.js index 3a83193..5085f91 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -1,4 +1,3 @@ -var assert = require('assert') var bufferutils = require('./bufferutils') var crypto = require('./crypto') var typeforce = require('typeforce') @@ -20,7 +19,7 @@ Transaction.SIGHASH_NONE = 0x02 Transaction.SIGHASH_SINGLE = 0x03 Transaction.SIGHASH_ANYONECANPAY = 0x80 -Transaction.fromBuffer = function (buffer, __disableAssert) { +Transaction.fromBuffer = function (buffer, __disableExcess) { var offset = 0 function readSlice (n) { offset += n @@ -87,8 +86,8 @@ Transaction.fromBuffer = function (buffer, __disableAssert) { tx.locktime = readUInt32() - if (!__disableAssert) { - assert.equal(offset, buffer.length, 'Transaction has unexpected data') + if (!__disableExcess) { + if (offset !== buffer.length) throw new Error('Transaction has unexpected data') } return tx