Browse Source

fix 0 fee error

patch-2
Manuel Araoz 10 years ago
parent
commit
0f17927fde
  1. 2
      lib/transaction/transaction.js
  2. 10
      test/transaction/transaction.js

2
lib/transaction/transaction.js

@ -628,7 +628,7 @@ Transaction.prototype.getFee = function() {
if (!this._changeScript) {
return this._getUnspentValue();
}
return this._fee || this._estimateFee();
return _.isUndefined(this._fee) ? this._estimateFee() : this._fee;
};
/**

10
test/transaction/transaction.js

@ -197,11 +197,17 @@ describe('Transaction', function() {
.from(simpleUtxoWith100000Satoshis)
.to(toAddress, 50000)
.change(changeAddress)
.sign(privateKey)
.fee(0)
.sign(privateKey);
transaction.getChangeOutput().satoshis.should.equal(50000);
transaction = transaction
.to(toAddress, 20000)
.sign(privateKey);
transaction.outputs.length.should.equal(3);
transaction.outputs[2].satoshis.should.equal(20000);
transaction.outputs[2].satoshis.should.equal(30000);
transaction.outputs[2].script.toString()
.should.equal(Script.fromAddress(changeAddress).toString());
});

Loading…
Cancel
Save