Browse Source

Ignore fee error when unspent output is actually negative, rather than already when the check for negative unspent output is disabled.

patch-2
David de Kloet 10 years ago
committed by Braydon Fuller
parent
commit
3ace170ac5
  1. 2
      lib/transaction/transaction.js
  2. 12
      test/transaction/transaction.js

2
lib/transaction/transaction.js

@ -205,7 +205,7 @@ Transaction.prototype._isInvalidSatoshis = function() {
};
Transaction.prototype._hasFeeError = function(opts) {
if (opts.disableMoreOutputThanInput) {
if (this._getUnspentValue() < 0) {
// The concept of a fee is meaningless when the unspent output value is negative.
return;
}

12
test/transaction/transaction.js

@ -397,6 +397,18 @@ describe('Transaction', function() {
return transaction.serialize();
}).to.throw(errors.Transaction.InvalidOutputAmountSum);
});
it('will throw fee error with disableMoreOutputThanInput enabled (but not triggered)', function() {
var transaction = new Transaction();
transaction.from(simpleUtxoWith1BTC);
transaction
.to(toAddress, 90000000)
.change(changeAddress)
.fee(10000000);
expect(function() {
return transaction.serialize({disableMoreOutputThanInput: true});
}).to.throw(errors.Transaction.FeeError.TooLarge);
});
describe('skipping checks', function() {
var buildSkipTest = function(builder, check, expectedError) {
return function() {

Loading…
Cancel
Save