fix 0 fee error

This commit is contained in:
Manuel Araoz 2015-02-10 18:29:14 -03:00
parent aa1158097d
commit 0f17927fde
2 changed files with 9 additions and 3 deletions

View File

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

View File

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