From 3533b60e6b6d5cc1a65fdbac483a64e4f00539f9 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Tue, 11 Aug 2015 16:52:10 -0300 Subject: [PATCH] change fee rounding strategy --- lib/model/txproposal.js | 7 ++----- test/integration/server.js | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/model/txproposal.js b/lib/model/txproposal.js index 73b6c63..f541c79 100644 --- a/lib/model/txproposal.js +++ b/lib/model/txproposal.js @@ -188,12 +188,9 @@ TxProposal.prototype.getEstimatedSize = function() { }; TxProposal.prototype.estimateFee = function() { + var fee = this.feePerKb * this.getEstimatedSize() / 1000; - var size = this.getEstimatedSize(); - var fee = this.feePerKb * size / 1000; - - // Round up to nearest bit - this.fee = parseInt((Math.ceil(fee / 100) * 100).toFixed(0)); + this.fee = parseInt(fee.toFixed(0)); }; /** diff --git a/test/integration/server.js b/test/integration/server.js index 0584af0..7e7db29 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -2092,8 +2092,7 @@ describe('Wallet service', function() { balance.lockedAmount.should.equal(0); balance.availableAmount.should.equal(helpers.toSatoshi(9)); balance.totalBytesToSendMax.should.equal(2896); - var sizeInKB = balance.totalBytesToSendMax / 1000; - var fee = parseInt((Math.ceil(sizeInKB * 10000 / 100) * 100).toFixed(0)); + var fee = parseInt((balance.totalBytesToSendMax * 10000 / 1000).toFixed(0)); var max = balance.availableAmount - fee; var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', max / 1e8, null, TestData.copayers[0].privKey_1H_0); server.createTx(txOpts, function(err, tx) { @@ -2123,8 +2122,7 @@ describe('Wallet service', function() { balance.lockedAmount.should.equal(helpers.toSatoshi(4)); balance.availableAmount.should.equal(helpers.toSatoshi(5)); balance.totalBytesToSendMax.should.equal(1653); - var sizeInKB = balance.totalBytesToSendMax / 1000; - var fee = parseInt((Math.ceil(sizeInKB * 2000 / 100) * 100).toFixed(0)); + var fee = parseInt((balance.totalBytesToSendMax * 2000 / 1000).toFixed(0)); var max = balance.availableAmount - fee; var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', max / 1e8, null, TestData.copayers[0].privKey_1H_0, 2000); server.createTx(txOpts, function(err, tx) {