From 6190348200d4942c41ea18746aeb54ad557b53c0 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Tue, 14 Jun 2016 12:22:26 -0300 Subject: [PATCH 1/2] minor refactor in output validation --- lib/server.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/server.js b/lib/server.js index 4fdd829..865dc3a 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1681,6 +1681,8 @@ WalletService.prototype._canCreateTx = function(cb) { }; WalletService.prototype._validateOutputs = function(opts, wallet, cb) { + var dustThreshold = Math.max(Defaults.MIN_OUTPUT_AMOUNT, Bitcore.Transaction.DUST_AMOUNT); + for (var i = 0; i < opts.outputs.length; i++) { var output = opts.outputs[i]; output.valid = false; @@ -1702,7 +1704,7 @@ WalletService.prototype._validateOutputs = function(opts, wallet, cb) { if (!_.isNumber(output.amount) || _.isNaN(output.amount) || output.amount <= 0) { return new ClientError('Invalid amount'); } - if (output.amount < Bitcore.Transaction.DUST_AMOUNT) { + if (output.amount < dustThreshold) { return Errors.DUST_AMOUNT; } @@ -1903,15 +1905,6 @@ WalletService.prototype._validateAndSanitizeTxOpts = function(wallet, opts, cb) return next(); }); }, - function(next) { - var dustThreshold = Math.max(Defaults.MIN_OUTPUT_AMOUNT, Bitcore.Transaction.DUST_AMOUNT); - if (_.any(opts.outputs, function(output) { - return output.amount < dustThreshold; - })) { - return next(Errors.DUST_AMOUNT); - } - next(); - }, function(next) { if (opts.validateOutputs === false) return next(); var validationError = self._validateOutputs(opts, wallet, next); From 15a2d5199250cd665dbf876a5c2acdbb3c77ce8f Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Tue, 14 Jun 2016 12:26:37 -0300 Subject: [PATCH 2/2] relax timeoff constraints --- lib/common/defaults.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/common/defaults.js b/lib/common/defaults.js index beb4b9f..ca3c5d6 100644 --- a/lib/common/defaults.js +++ b/lib/common/defaults.js @@ -10,14 +10,14 @@ Defaults.MAX_TX_SIZE_IN_KB = 100; Defaults.MAX_KEYS = 100; -// Time after which a Tx proposal can be erased by any copayer. in seconds -Defaults.DELETE_LOCKTIME = 1 * 3600; +// Time after which a tx proposal can be erased by any copayer. in seconds +Defaults.DELETE_LOCKTIME = 600; // Allowed consecutive txp rejections before backoff is applied. Defaults.BACKOFF_OFFSET = 10; -// Time a copayer need to wait to create a new TX after her tx previous proposal we rejected. in seconds. -Defaults.BACKOFF_TIME = 1 * 3600; +// Time a copayer need to wait to create a new tx after her previous proposal was rejected. in seconds. +Defaults.BACKOFF_TIME = 600; Defaults.MAX_MAIN_ADDRESS_GAP = 20;