allow fee to be set to zero

This commit is contained in:
Wei Lu 2014-03-26 20:20:58 +08:00
parent 4d4388f6bf
commit 39c181dce6
2 changed files with 10 additions and 1 deletions

View file

@ -184,7 +184,7 @@ var Wallet = function (seed, options) {
totalInValue += output.value
if(totalInValue < value) continue;
var fee = fixedFee || estimateFeePadChangeOutput(tx)
var fee = fixedFee == undefined ? estimateFeePadChangeOutput(tx) : fixedFee
if(totalInValue < value + fee) continue;
var change = totalInValue - value - fee

View file

@ -434,6 +434,15 @@ describe('Wallet', function() {
assert.deepEqual(tx.ins[1].outpoint, { hash: fakeTxHash(2), index: 1 })
})
it('allows fee to be set to zero', function(){
value = 520000
var fee = 0
var tx = wallet.createTx(to, value, fee)
assert.equal(tx.ins.length, 1)
assert.deepEqual(tx.ins[0].outpoint, { hash: fakeTxHash(3), index: 0 })
})
it('ignores spent outputs', function(){
utxo.push(
{