Browse Source

Merge pull request #531 from isocolsky/ref/various

Minor refactor
activeAddress
Matias Alejo Garcia 9 years ago
committed by GitHub
parent
commit
b26fa865d1
  1. 8
      lib/common/defaults.js
  2. 13
      lib/server.js

8
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;

13
lib/server.js

@ -1696,6 +1696,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;
@ -1717,7 +1719,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;
}
@ -1918,15 +1920,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);

Loading…
Cancel
Save