check coin arg is valid

This commit is contained in:
Ivan Socolsky 2017-09-01 15:06:58 -03:00
parent 87ba10de84
commit 7bbc6aea82
No known key found for this signature in database
GPG Key ID: FAECE6A05FAA4F56
1 changed files with 6 additions and 1 deletions

View File

@ -1322,7 +1322,7 @@ WalletService.prototype._getActiveAddresses = function(cb) {
/**
* Get wallet balance.
* @param {Object} opts
* @param {string} [opts.coin = 'btc'] - Override wallet coin.
* @param {string} [opts.coin] - Override wallet coin (default wallet's coin).
* @param {Boolean} opts.twoStep[=false] - Optional - Use 2 step balance computation for improved performance
* @returns {Object} balance - Total amount & locked amount.
*/
@ -1331,6 +1331,11 @@ WalletService.prototype.getBalance = function(opts, cb) {
opts = opts || {};
if (opts.coin) {
if (!Utils.checkValueInCollection(opts.coin, Constants.COINS))
return cb(new ClientError('Invalid coin'));
}
if (!opts.twoStep)
return self._getBalanceOneStep(opts, cb);