From f455b53971aeec95f6d9be8b7b660721cb45c91d Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Thu, 28 Apr 2016 19:58:24 -0300 Subject: [PATCH 1/3] always add changeaddress if specified --- lib/model/txproposal.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/model/txproposal.js b/lib/model/txproposal.js index c3d1879..dd0b71d 100644 --- a/lib/model/txproposal.js +++ b/lib/model/txproposal.js @@ -164,10 +164,7 @@ TxProposal.prototype._buildTx = function() { t.fee(self.fee); - var totalInputs = _.sum(self.inputs, 'satoshis'); - var totalOutputs = _.sum(self.outputs, 'amount'); - - if (totalInputs - totalOutputs - self.fee > 0 && self.changeAddress) { + if (self.changeAddress) { t.change(self.changeAddress.address); } From 190ee3ef34baf5cb4f56e1dadd5f08d0317b7ef7 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Thu, 28 Apr 2016 20:00:02 -0300 Subject: [PATCH 2/3] improve log messages --- lib/server.js | 3 ++- test/integration/server.js | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/server.js b/lib/server.js index 255acd4..c26411d 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1593,7 +1593,8 @@ WalletService.prototype._selectTxInputs = function(txp, utxosToExclude, cb) { var err = self._checkTx(txp); if (!err) { - log.debug('Successfully built transaction. Total fees: ' + Utils.formatAmountInBtc(txp.fee) + ', total change: ' + Utils.formatAmountInBtc(_.sum(txp.inputs, 'satoshis') - txp.fee)); + var change = _.sum(txp.inputs, 'satoshis') - _.sum(txp.outputs, 'amount') - txp.fee; + log.debug('Successfully built transaction. Total fees: ' + Utils.formatAmountInBtc(txp.fee) + ', total change: ' + Utils.formatAmountInBtc(change)); } else { log.warn('Error building transaction', err); } diff --git a/test/integration/server.js b/test/integration/server.js index ffaef48..c6a051d 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -2132,7 +2132,6 @@ describe('Wallet service', function() { }); it('should use unconfirmed utxos only when no more confirmed utxos are available', function(done) { - // log.level = 'debug'; helpers.stubUtxos(server, wallet, [1.3, 'u0.5', 'u0.1', 1.2], function(utxos) { var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 2.55, TestData.copayers[0].privKey_1H_0, { message: 'some message' @@ -2355,7 +2354,6 @@ describe('Wallet service', function() { }); it('should fail to create a tx exceeding max size in kb', function(done) { - // log.level = 'debug'; var _oldDefault = Defaults.MAX_TX_SIZE_IN_KB; Defaults.MAX_TX_SIZE_IN_KB = 1; helpers.stubUtxos(server, wallet, _.range(1, 10, 0), function() { @@ -3399,7 +3397,6 @@ describe('Wallet service', function() { }); }); it('should account for fee when selecting smallest big utxo', function(done) { - // log.level = 'debug'; var _old = Defaults.UTXO_SELECTION_MAX_SINGLE_UTXO_FACTOR; Defaults.UTXO_SELECTION_MAX_SINGLE_UTXO_FACTOR = 2; // The 605 bits input cannot be selected even if it is > 2 * tx amount @@ -3564,7 +3561,6 @@ describe('Wallet service', function() { }); }); it('should select unconfirmed utxos if not enough confirmed utxos', function(done) { - // log.level = 'debug'; helpers.stubUtxos(server, wallet, ['u 1btc', '0.5btc'], function() { var txOpts = { outputs: [{ From 2289b2d9ed89b9275acef552db4978d0a067cfd2 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Fri, 29 Apr 2016 10:00:44 -0300 Subject: [PATCH 3/3] v1.7.0 --- package.json | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 766aeb2..b08574e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "bitcore-wallet-service", "description": "A service for Mutisig HD Bitcoin Wallets", "author": "BitPay Inc", - "version": "1.6.1", + "version": "1.7.0", "keywords": [ "bitcoin", "copay", @@ -65,18 +65,14 @@ "coveralls": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" }, "bitcoreNode": "./bitcorenode", - "contributors": [ - { - "name": "Braydon Fuller", - "email": "braydon@bitpay.com" - }, - { - "name": "Ivan Socolsky", - "email": "ivan@bitpay.com" - }, - { - "name": "Matias Alejo Garcia", - "email": "ematiu@gmail.com" - } - ] + "contributors": [{ + "name": "Braydon Fuller", + "email": "braydon@bitpay.com" + }, { + "name": "Ivan Socolsky", + "email": "ivan@bitpay.com" + }, { + "name": "Matias Alejo Garcia", + "email": "ematiu@gmail.com" + }] }