|
|
@ -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); |
|
|
|