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

This commit is contained in:
David de Kloet 2015-05-21 09:01:08 +02:00 committed by Braydon Fuller
parent ac2fbe2777
commit 3ace170ac5
2 changed files with 13 additions and 1 deletions

View File

@ -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;
}

View File

@ -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() {