Merge pull request #322 from isocolsky/fix/fee_rounding
Fix/fee rounding
This commit is contained in:
commit
c5fc6be856
|
@ -188,12 +188,9 @@ TxProposal.prototype.getEstimatedSize = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
TxProposal.prototype.estimateFee = function() {
|
TxProposal.prototype.estimateFee = function() {
|
||||||
|
var fee = this.feePerKb * this.getEstimatedSize() / 1000;
|
||||||
|
|
||||||
var size = this.getEstimatedSize();
|
this.fee = parseInt(fee.toFixed(0));
|
||||||
var fee = this.feePerKb * size / 1000;
|
|
||||||
|
|
||||||
// Round up to nearest bit
|
|
||||||
this.fee = parseInt((Math.ceil(fee / 100) * 100).toFixed(0));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "bitcore-wallet-service",
|
"name": "bitcore-wallet-service",
|
||||||
"description": "A service for Mutisig HD Bitcoin Wallets",
|
"description": "A service for Mutisig HD Bitcoin Wallets",
|
||||||
"author": "BitPay Inc",
|
"author": "BitPay Inc",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"bitcoin",
|
"bitcoin",
|
||||||
"copay",
|
"copay",
|
||||||
|
|
|
@ -2092,8 +2092,7 @@ describe('Wallet service', function() {
|
||||||
balance.lockedAmount.should.equal(0);
|
balance.lockedAmount.should.equal(0);
|
||||||
balance.availableAmount.should.equal(helpers.toSatoshi(9));
|
balance.availableAmount.should.equal(helpers.toSatoshi(9));
|
||||||
balance.totalBytesToSendMax.should.equal(2896);
|
balance.totalBytesToSendMax.should.equal(2896);
|
||||||
var sizeInKB = balance.totalBytesToSendMax / 1000;
|
var fee = parseInt((balance.totalBytesToSendMax * 10000 / 1000).toFixed(0));
|
||||||
var fee = parseInt((Math.ceil(sizeInKB * 10000 / 100) * 100).toFixed(0));
|
|
||||||
var max = balance.availableAmount - fee;
|
var max = balance.availableAmount - fee;
|
||||||
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', max / 1e8, null, TestData.copayers[0].privKey_1H_0);
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', max / 1e8, null, TestData.copayers[0].privKey_1H_0);
|
||||||
server.createTx(txOpts, function(err, tx) {
|
server.createTx(txOpts, function(err, tx) {
|
||||||
|
@ -2123,8 +2122,7 @@ describe('Wallet service', function() {
|
||||||
balance.lockedAmount.should.equal(helpers.toSatoshi(4));
|
balance.lockedAmount.should.equal(helpers.toSatoshi(4));
|
||||||
balance.availableAmount.should.equal(helpers.toSatoshi(5));
|
balance.availableAmount.should.equal(helpers.toSatoshi(5));
|
||||||
balance.totalBytesToSendMax.should.equal(1653);
|
balance.totalBytesToSendMax.should.equal(1653);
|
||||||
var sizeInKB = balance.totalBytesToSendMax / 1000;
|
var fee = parseInt((balance.totalBytesToSendMax * 2000 / 1000).toFixed(0));
|
||||||
var fee = parseInt((Math.ceil(sizeInKB * 2000 / 100) * 100).toFixed(0));
|
|
||||||
var max = balance.availableAmount - fee;
|
var max = balance.availableAmount - fee;
|
||||||
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', max / 1e8, null, TestData.copayers[0].privKey_1H_0, 2000);
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', max / 1e8, null, TestData.copayers[0].privKey_1H_0, 2000);
|
||||||
server.createTx(txOpts, function(err, tx) {
|
server.createTx(txOpts, function(err, tx) {
|
||||||
|
|
Loading…
Reference in New Issue