From 60f6300fbce4b15b42aae14e545891d4c8a8aa81 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Fri, 4 Mar 2016 17:53:16 -0300 Subject: [PATCH] rebased --- lib/server.js | 7 +++---- test/integration/server.js | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/server.js b/lib/server.js index 7d4e569..4240776 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1398,7 +1398,6 @@ WalletService.prototype._selectTxInputs2 = function(txp, utxosToExclude, cb) { }; function select(utxos) { - // TODO: fix for when fee is specified instead of feePerKb var txpAmount = txp.getTotalAmount(); var baseTxpSize = txp.getEstimatedSize(); var baseTxpFee = baseTxpSize * txp.feePerKb / 1000.; @@ -1408,11 +1407,11 @@ WalletService.prototype._selectTxInputs2 = function(txp, utxosToExclude, cb) { var totalValueInUtxos = _.sum(utxos, 'satoshis'); var netValueInUtxos = totalValueInUtxos - baseTxpFee - (utxos.length * feePerInput); if (totalValueInUtxos < txpAmount) { - log.debug('Total value in all utxos (' + formatAmount(totalValueInUtxos) + ') is insufficient to cover for txp amount (' + formatAmount(txpAmount) + ')'); // TODO + log.debug('Total value in all utxos (' + formatAmount(totalValueInUtxos) + ') is insufficient to cover for txp amount (' + formatAmount(txpAmount) + ')'); return Errors.INSUFFICIENT_FUNDS; } if (netValueInUtxos < txpAmount) { - log.debug('Value after fees in all utxos (' + formatAmount(netValueInUtxos) + ') is insufficient to cover for txp amount (' + formatAmount(txpAmount) + ')'); // TODO + log.debug('Value after fees in all utxos (' + formatAmount(netValueInUtxos) + ') is insufficient to cover for txp amount (' + formatAmount(txpAmount) + ')'); return Errors.INSUFFICIENT_FUNDS_FOR_FEE; } @@ -1462,7 +1461,7 @@ WalletService.prototype._selectTxInputs2 = function(txp, utxosToExclude, cb) { log.debug('Tx amount/input amount:' + formatRatio(amountVsUtxoRatio) + ' (min: ' + formatRatio(Defaults.UTXO_SELECTION_MIN_TX_AMOUNT_VS_UTXO_FACTOR) + ')'); if (txpSize / 1000. > Defaults.MAX_TX_SIZE_IN_KB) { - log.debug('Breaking because tx size (' + formatSize(txpSize) + ') is too big (max: ' + formatSize(Defaults.MAX_TX_SIZE_IN_KB * 1000.) + ')'); // TODO + log.debug('Breaking because tx size (' + formatSize(txpSize) + ') is too big (max: ' + formatSize(Defaults.MAX_TX_SIZE_IN_KB * 1000.) + ')'); error = Errors.TX_MAX_SIZE_EXCEEDED; return false; } diff --git a/test/integration/server.js b/test/integration/server.js index 507d10d..0b05fdb 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -2355,7 +2355,7 @@ describe('Wallet service', function() { }); it('should fail to create a tx exceeding max size in kb', function(done) { - log.level = 'debug'; + // 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() { @@ -3186,8 +3186,7 @@ describe('Wallet service', function() { toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', amount: 0.8 * 1e8, }], - message: 'some message', - customData: 'some custom data', + feePerKb: 100e2, }; server.createTx(txOpts, function(err, tx) { should.not.exist(err);