Browse Source

Merge pull request #1044 from trustatom-oss/master

Add check to _hasDustOutputs if output has OP_RETURN
patch-2
Esteban Ordano 10 years ago
parent
commit
8d642f3c7a
  1. 7
      lib/transaction/transaction.js
  2. 12
      test/transaction/transaction.js

7
lib/transaction/transaction.js

@ -151,9 +151,10 @@ Transaction.prototype._validateChange = function() {
Transaction.DUST_AMOUNT = 5460;
Transaction.prototype._hasDustOutputs = function() {
var output;
for (output in this.outputs) {
if (this.outputs[output].satoshis < Transaction.DUST_AMOUNT) {
var index, output;
for (index in this.outputs) {
output = this.outputs[index];
if (output.satoshis < Transaction.DUST_AMOUNT && !output.script.isDataOut()) {
return true;
}
}

12
test/transaction/transaction.js

@ -279,7 +279,7 @@ describe('Transaction', function() {
return transaction.serialize();
}).to.throw(errors.Transaction.FeeError);
});
it('fails if a dust transaction is created', function() {
it('fails if a dust output is created', function() {
var transaction = new Transaction()
.from(simpleUtxoWith1BTC)
.to(toAddress, 1)
@ -289,6 +289,16 @@ describe('Transaction', function() {
return transaction.serialize();
}).to.throw(errors.Transaction.DustOutputs);
});
it('doesn\'t fail if a dust output is an op_return', function() {
var transaction = new Transaction()
.from(simpleUtxoWith1BTC)
.addData('not dust!')
.change(changeAddress)
.sign(privateKey);
expect(function() {
return transaction.serialize();
}).to.not.throw(errors.Transaction.DustOutputs);
});
});
describe('to and from JSON', function() {

Loading…
Cancel
Save