diff --git a/lib/errors/spec.js b/lib/errors/spec.js index c7adece..03eabc4 100644 --- a/lib/errors/spec.js +++ b/lib/errors/spec.js @@ -85,14 +85,18 @@ module.exports = [{ name: 'InvalidSatoshis', message: 'Output satoshis are invalid', }, { - name: 'SmallFeeError', - message: 'Fee is too small: {0}', - }, { - name: 'LargeFeeError', - message: 'Fee is too large: {0}', - }, { - name: 'DifferentFeeError', - message: 'Unspent value is different from specified fee: {0}', + name: 'Fee', + message: 'Internal Error on Fee {0}', + errors: [{ + name: 'TooSmallError', + message: 'Fee is too small: {0}', + }, { + name: 'TooLargeError', + message: 'Fee is too large: {0}', + }, { + name: 'DifferentError', + message: 'Unspent value is different from specified fee: {0}', + }] }, { name: 'ChangeAddressMissing', message: 'Change address is missing' diff --git a/lib/transaction/transaction.js b/lib/transaction/transaction.js index 8729557..9890cf9 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.DifferentFeeError(feeIsDifferent); + return new errors.Transaction.Fee.DifferentError(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.LargeFeeError(feeIsTooLarge); + return new errors.Transaction.Fee.TooLargeError(feeIsTooLarge); } if (!opts.disableSmallFees && feeIsTooSmall) { - return new errors.Transaction.SmallFeeError(feeIsTooSmall); + return new errors.Transaction.Fee.TooSmallError(feeIsTooSmall); } if (!opts.disableDustOutputs && this._hasDustOutputs()) { return new errors.Transaction.DustOutputs(); diff --git a/test/transaction/transaction.js b/test/transaction/transaction.js index cf8ff21..18c8e71 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.SmallFeeError); + }).to.throw(errors.Transaction.Fee.TooSmallError); }); 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.LargeFeeError); + }).to.throw(errors.Transaction.Fee.TooLargeError); }); 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.DifferentFeeError); + }).to.throw(errors.Transaction.Fee.DifferentError); }); describe('skipping checks', function() { var buildSkipTest = function(builder, check) {