fix 0 fee error
This commit is contained in:
parent
aa1158097d
commit
0f17927fde
|
@ -628,7 +628,7 @@ Transaction.prototype.getFee = function() {
|
||||||
if (!this._changeScript) {
|
if (!this._changeScript) {
|
||||||
return this._getUnspentValue();
|
return this._getUnspentValue();
|
||||||
}
|
}
|
||||||
return this._fee || this._estimateFee();
|
return _.isUndefined(this._fee) ? this._estimateFee() : this._fee;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -197,11 +197,17 @@ describe('Transaction', function() {
|
||||||
.from(simpleUtxoWith100000Satoshis)
|
.from(simpleUtxoWith100000Satoshis)
|
||||||
.to(toAddress, 50000)
|
.to(toAddress, 50000)
|
||||||
.change(changeAddress)
|
.change(changeAddress)
|
||||||
.sign(privateKey)
|
.fee(0)
|
||||||
|
.sign(privateKey);
|
||||||
|
|
||||||
|
transaction.getChangeOutput().satoshis.should.equal(50000);
|
||||||
|
|
||||||
|
transaction = transaction
|
||||||
.to(toAddress, 20000)
|
.to(toAddress, 20000)
|
||||||
.sign(privateKey);
|
.sign(privateKey);
|
||||||
|
|
||||||
transaction.outputs.length.should.equal(3);
|
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()
|
transaction.outputs[2].script.toString()
|
||||||
.should.equal(Script.fromAddress(changeAddress).toString());
|
.should.equal(Script.fromAddress(changeAddress).toString());
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue