Browse Source

Call the parent error of the fee errors FeeError for backwards compatibility.

patch-2
David de Kloet 10 years ago
parent
commit
b1e54101d3
  1. 8
      lib/errors/spec.js
  2. 6
      lib/transaction/transaction.js
  3. 6
      test/transaction/transaction.js

8
lib/errors/spec.js

@ -85,16 +85,16 @@ module.exports = [{
name: 'InvalidSatoshis', name: 'InvalidSatoshis',
message: 'Output satoshis are invalid', message: 'Output satoshis are invalid',
}, { }, {
name: 'Fee', name: 'FeeError',
message: 'Internal Error on Fee {0}', message: 'Internal Error on Fee {0}',
errors: [{ errors: [{
name: 'TooSmallError', name: 'TooSmall',
message: 'Fee is too small: {0}', message: 'Fee is too small: {0}',
}, { }, {
name: 'TooLargeError', name: 'TooLarge',
message: 'Fee is too large: {0}', message: 'Fee is too large: {0}',
}, { }, {
name: 'DifferentError', name: 'Different',
message: 'Unspent value is different from specified fee: {0}', message: 'Unspent value is different from specified fee: {0}',
}] }]
}, { }, {

6
lib/transaction/transaction.js

@ -203,16 +203,16 @@ Transaction.prototype.getSerializationError = function(opts) {
var isFullySigned = this.isFullySigned(); var isFullySigned = this.isFullySigned();
if (!opts.disableDifferentFees && feeIsDifferent) { if (!opts.disableDifferentFees && feeIsDifferent) {
return new errors.Transaction.Fee.DifferentError(feeIsDifferent); return new errors.Transaction.FeeError.Different(feeIsDifferent);
} }
if (!opts.disableLargeFees && feeIsTooLarge) { if (!opts.disableLargeFees && feeIsTooLarge) {
if (missingChange) { if (missingChange) {
return new errors.Transaction.ChangeAddressMissing('Fee is too large and no change address was provided'); 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) { if (!opts.disableSmallFees && feeIsTooSmall) {
return new errors.Transaction.Fee.TooSmallError(feeIsTooSmall); return new errors.Transaction.FeeError.TooSmall(feeIsTooSmall);
} }
if (!opts.disableDustOutputs && this._hasDustOutputs()) { if (!opts.disableDustOutputs && this._hasDustOutputs()) {
return new errors.Transaction.DustOutputs(); return new errors.Transaction.DustOutputs();

6
test/transaction/transaction.js

@ -266,7 +266,7 @@ describe('Transaction', function() {
.sign(privateKey); .sign(privateKey);
expect(function() { expect(function() {
return transaction.serialize(); 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() { it('on second call to sign, change is not recalculated', function() {
var transaction = new Transaction() var transaction = new Transaction()
@ -332,7 +332,7 @@ describe('Transaction', function() {
.to(toAddress, 40000000); .to(toAddress, 40000000);
expect(function() { expect(function() {
return transaction.serialize(); return transaction.serialize();
}).to.throw(errors.Transaction.Fee.TooLargeError); }).to.throw(errors.Transaction.FeeError.TooLarge);
}); });
it('fails if a dust output is created', function() { it('fails if a dust output is created', function() {
var transaction = new Transaction() var transaction = new Transaction()
@ -372,7 +372,7 @@ describe('Transaction', function() {
.sign(privateKey); .sign(privateKey);
expect(function() { expect(function() {
return transaction.serialize(); return transaction.serialize();
}).to.throw(errors.Transaction.Fee.DifferentError); }).to.throw(errors.Transaction.FeeError.Different);
}); });
describe('skipping checks', function() { describe('skipping checks', function() {
var buildSkipTest = function(builder, check) { var buildSkipTest = function(builder, check) {

Loading…
Cancel
Save