From 39c181dce639ba714cb5b706a9bfb6a35f0cb81e Mon Sep 17 00:00:00 2001 From: Wei Lu Date: Wed, 26 Mar 2014 20:20:58 +0800 Subject: [PATCH] allow fee to be set to zero --- src/wallet.js | 2 +- test/wallet.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wallet.js b/src/wallet.js index a89cd75..15af8f8 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -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 diff --git a/test/wallet.js b/test/wallet.js index fb5ba1e..9a179cd 100644 --- a/test/wallet.js +++ b/test/wallet.js @@ -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( {