Browse Source

Update dust amount

patch-2
eordano 10 years ago
parent
commit
405f4f43df
  1. 2
      docs/transaction.md
  2. 2
      lib/transaction/transaction.js
  3. 12
      test/transaction/transaction.js

2
docs/transaction.md

@ -161,7 +161,7 @@ These are the current default values in the bitcore library involved on these ch
* `Transaction.FEE_PER_KB`: `10000` (satoshis per kilobyte)
* `Transaction.FEE_SECURITY_MARGIN`: `15`
* `Transaction.DUST_AMOUNT`: `5460` (satoshis)
* `Transaction.DUST_AMOUNT`: `546` (satoshis)
## Fee calculation

2
lib/transaction/transaction.js

@ -63,7 +63,7 @@ var DEFAULT_NLOCKTIME = 0;
var DEFAULT_SEQNUMBER = 0xFFFFFFFF;
// Minimum amount for an output for it not to be considered a dust output
Transaction.DUST_AMOUNT = 5460;
Transaction.DUST_AMOUNT = 546;
// Margin of error to allow fees in the vecinity of the expected value but doesn't allow a big difference
Transaction.FEE_SECURITY_MARGIN = 15;

12
test/transaction/transaction.js

@ -322,13 +322,23 @@ describe('Transaction', function() {
it('fails if a dust output is created', function() {
var transaction = new Transaction()
.from(simpleUtxoWith1BTC)
.to(toAddress, 1)
.to(toAddress, 545)
.change(changeAddress)
.sign(privateKey);
expect(function() {
return transaction.serialize();
}).to.throw(errors.Transaction.DustOutputs);
});
it('doesn\'t fail if a dust output is not dust', function() {
var transaction = new Transaction()
.from(simpleUtxoWith1BTC)
.to(toAddress, 546)
.change(changeAddress)
.sign(privateKey);
expect(function() {
return transaction.serialize();
}).to.not.throw(errors.Transaction.DustOutputs);
});
it('doesn\'t fail if a dust output is an op_return', function() {
var transaction = new Transaction()
.from(simpleUtxoWith1BTC)

Loading…
Cancel
Save