From b1e54101d35b0d4faba38582c8f590c2f1974bb2 Mon Sep 17 00:00:00 2001 From: David de Kloet Date: Sun, 10 May 2015 00:38:56 +0200 Subject: [PATCH] Call the parent error of the fee errors FeeError for backwards compatibility. --- lib/errors/spec.js | 8 ++++---- lib/transaction/transaction.js | 6 +++--- test/transaction/transaction.js | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/errors/spec.js b/lib/errors/spec.js index 03eabc4..dd46d6f 100644 --- a/lib/errors/spec.js +++ b/lib/errors/spec.js @@ -85,16 +85,16 @@ module.exports = [{ name: 'InvalidSatoshis', message: 'Output satoshis are invalid', }, { - name: 'Fee', + name: 'FeeError', message: 'Internal Error on Fee {0}', errors: [{ - name: 'TooSmallError', + name: 'TooSmall', message: 'Fee is too small: {0}', }, { - name: 'TooLargeError', + name: 'TooLarge', message: 'Fee is too large: {0}', }, { - name: 'DifferentError', + name: 'Different', message: 'Unspent value is different from specified fee: {0}', }] }, { diff --git a/lib/transaction/transaction.js b/lib/transaction/transaction.js index 9890cf9..47c8ff5 100644 --- a/lib/transaction/transaction.js +++ b/lib/transaction/transaction.js @@ -203,16 +203,16 @@ Transaction.prototype.getSerializationError = function(opts) { var isFullySigned = this.isFullySigned(); if (!opts.disableDifferentFees && feeIsDifferent) { - return new errors.Transaction.Fee.DifferentError(feeIsDifferent); + return new errors.Transaction.FeeError.Different(feeIsDifferent); } if (!opts.disableLargeFees && feeIsTooLarge) { if (missingChange) { return new errors.Transaction.ChangeAddressMissing('Fee is too large and no change address was provided'); } - return new errors.Transaction.Fee.TooLargeError(feeIsTooLarge); + return new errors.Transaction.FeeError.TooLarge(feeIsTooLarge); } if (!opts.disableSmallFees && feeIsTooSmall) { - return new errors.Transaction.Fee.TooSmallError(feeIsTooSmall); + return new errors.Transaction.FeeError.TooSmall(feeIsTooSmall); } if (!opts.disableDustOutputs && this._hasDustOutputs()) { return new errors.Transaction.DustOutputs(); diff --git a/test/transaction/transaction.js b/test/transaction/transaction.js index 18c8e71..dd38f8f 100644 --- a/test/transaction/transaction.js +++ b/test/transaction/transaction.js @@ -266,7 +266,7 @@ describe('Transaction', function() { .sign(privateKey); expect(function() { return transaction.serialize(); - }).to.throw(errors.Transaction.Fee.TooSmallError); + }).to.throw(errors.Transaction.FeeError.TooSmall); }); it('on second call to sign, change is not recalculated', function() { var transaction = new Transaction() @@ -332,7 +332,7 @@ describe('Transaction', function() { .to(toAddress, 40000000); expect(function() { return transaction.serialize(); - }).to.throw(errors.Transaction.Fee.TooLargeError); + }).to.throw(errors.Transaction.FeeError.TooLarge); }); it('fails if a dust output is created', function() { var transaction = new Transaction() @@ -372,7 +372,7 @@ describe('Transaction', function() { .sign(privateKey); expect(function() { return transaction.serialize(); - }).to.throw(errors.Transaction.Fee.DifferentError); + }).to.throw(errors.Transaction.FeeError.Different); }); describe('skipping checks', function() { var buildSkipTest = function(builder, check) {