allow feePerKb to be set to zero
This commit is contained in:
parent
68b08b638a
commit
8d2525dba1
2 changed files with 7 additions and 1 deletions
|
@ -382,7 +382,8 @@ Transaction.prototype.estimateFee = function(feePerKb){
|
||||||
var uncompressedInSize = 180
|
var uncompressedInSize = 180
|
||||||
var outSize = 34
|
var outSize = 34
|
||||||
var fixedPadding = 34
|
var fixedPadding = 34
|
||||||
var feePerKb = feePerKb || Transaction.feePerKb
|
|
||||||
|
if(feePerKb == undefined) feePerKb = Transaction.feePerKb
|
||||||
var size = this.ins.length * uncompressedInSize + this.outs.length * outSize + fixedPadding
|
var size = this.ins.length * uncompressedInSize + this.outs.length * outSize + fixedPadding
|
||||||
|
|
||||||
return feePerKb * Math.ceil(size / 1000)
|
return feePerKb * Math.ceil(size / 1000)
|
||||||
|
|
|
@ -194,6 +194,11 @@ describe('Transaction', function() {
|
||||||
var tx = Transaction.deserialize(fixtureTx2Hex)
|
var tx = Transaction.deserialize(fixtureTx2Hex)
|
||||||
assert.equal(tx.estimateFee(10000), 10000)
|
assert.equal(tx.estimateFee(10000), 10000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('allow feePerKb to be set to 0', function(){
|
||||||
|
var tx = Transaction.deserialize(fixtureTx2Hex)
|
||||||
|
assert.equal(tx.estimateFee(0), 0)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue