|
|
@ -463,7 +463,7 @@ WalletService.prototype.getWalletFromIdentifier = function(opts, cb) { |
|
|
|
bc.getTransaction(opts.identifier, function(err, tx) { |
|
|
|
if (err || !tx) return nextCoinNetwork(false); |
|
|
|
var outputs = _.first(self._normalizeTxHistory(tx)).outputs; |
|
|
|
var toAddresses = _.pluck(outputs, 'address'); |
|
|
|
var toAddresses = _.map(outputs, 'address'); |
|
|
|
async.detect(toAddresses, function(addressStr, nextAddress) { |
|
|
|
self.storage.fetchAddressByCoin(coinNetwork.coin, addressStr, function(err, address) { |
|
|
|
if (err || !address) return nextAddress(false); |
|
|
@ -873,7 +873,7 @@ WalletService.prototype.savePreferences = function(opts, cb) { |
|
|
|
}, |
|
|
|
}]; |
|
|
|
|
|
|
|
opts = _.pick(opts, _.pluck(preferences, 'name')); |
|
|
|
opts = _.pick(opts, _.map(preferences, 'name')); |
|
|
|
try { |
|
|
|
_.each(preferences, function(preference) { |
|
|
|
var value = opts[preference.name]; |
|
|
@ -1131,7 +1131,7 @@ WalletService.prototype._getUtxosForCurrentWallet = function(opts, cb) { |
|
|
|
}); |
|
|
|
}, |
|
|
|
function(next) { |
|
|
|
addressStrs = _.pluck(allAddresses, 'address'); |
|
|
|
addressStrs = _.map(allAddresses, 'address'); |
|
|
|
if (!opts.coin) return next(); |
|
|
|
|
|
|
|
coin = opts.coin; |
|
|
@ -1155,7 +1155,7 @@ WalletService.prototype._getUtxosForCurrentWallet = function(opts, cb) { |
|
|
|
self.getPendingTxs({}, function(err, txps) { |
|
|
|
if (err) return next(err); |
|
|
|
|
|
|
|
var lockedInputs = _.map(_.flatten(_.pluck(txps, 'inputs')), utxoKey); |
|
|
|
var lockedInputs = _.map(_.flatten(_.map(txps, 'inputs')), utxoKey); |
|
|
|
_.each(lockedInputs, function(input) { |
|
|
|
if (utxoIndex[input]) { |
|
|
|
utxoIndex[input].locked = true; |
|
|
@ -1175,7 +1175,7 @@ WalletService.prototype._getUtxosForCurrentWallet = function(opts, cb) { |
|
|
|
limit: 100 |
|
|
|
}, function(err, txs) { |
|
|
|
if (err) return next(err); |
|
|
|
var spentInputs = _.map(_.flatten(_.pluck(txs, 'inputs')), utxoKey); |
|
|
|
var spentInputs = _.map(_.flatten(_.map(txs, 'inputs')), utxoKey); |
|
|
|
_.each(spentInputs, function(input) { |
|
|
|
if (utxoIndex[input]) { |
|
|
|
utxoIndex[input].spent = true; |
|
|
@ -1293,7 +1293,7 @@ WalletService.prototype._getBalanceOneStep = function(opts, cb) { |
|
|
|
self.storage.cleanActiveAddresses(self.walletId, next); |
|
|
|
}, |
|
|
|
function(next) { |
|
|
|
var active = _.pluck(balance.byAddress, 'address') |
|
|
|
var active = _.map(balance.byAddress, 'address') |
|
|
|
self.storage.storeActiveAddresses(self.walletId, active, next); |
|
|
|
}, |
|
|
|
], function(err) { |
|
|
@ -1322,8 +1322,8 @@ WalletService.prototype._getActiveAddresses = function(cb) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
var now = Math.floor(Date.now() / 1000); |
|
|
|
var recent = _.pluck(_.filter(allAddresses, function(address) { |
|
|
|
return address.createdOn > (now - 24 * 3600); |
|
|
|
var recent = _.map(_.filter(allAddresses, function(address) { |
|
|
|
return address.createdOn > (now - Defaults.TWO_STEP_CREATION_HOURS * 3600); |
|
|
|
}), 'address'); |
|
|
|
|
|
|
|
var result = _.union(active, recent); |
|
|
@ -1424,7 +1424,7 @@ WalletService.prototype.getSendMaxInfo = function(opts, cb) { |
|
|
|
if (!_.any(feeLevels, { |
|
|
|
name: opts.feeLevel |
|
|
|
})) |
|
|
|
return cb(new ClientError('Invalid fee level. Valid values are ' + _.pluck(feeLevels, 'name').join(', '))); |
|
|
|
return cb(new ClientError('Invalid fee level. Valid values are ' + _.map(feeLevels, 'name').join(', '))); |
|
|
|
} |
|
|
|
|
|
|
|
if (_.isNumber(opts.feePerKb)) { |
|
|
@ -1567,7 +1567,7 @@ WalletService.prototype.getFeeLevels = function(opts, cb) { |
|
|
|
var feeLevels = Defaults.FEE_LEVELS[opts.coin]; |
|
|
|
|
|
|
|
function samplePoints() { |
|
|
|
var definedPoints = _.uniq(_.pluck(feeLevels, 'nbBlocks')); |
|
|
|
var definedPoints = _.uniq(_.map(feeLevels, 'nbBlocks')); |
|
|
|
return _.uniq(_.flatten(_.map(definedPoints, function(p) { |
|
|
|
return _.range(p, p + Defaults.FEE_LEVELS_FALLBACK + 1); |
|
|
|
}))); |
|
|
@ -1986,7 +1986,7 @@ WalletService.prototype._validateAndSanitizeTxOpts = function(wallet, opts, cb) |
|
|
|
if (!_.any(feeLevels, { |
|
|
|
name: opts.feeLevel |
|
|
|
})) |
|
|
|
return next(new ClientError('Invalid fee level. Valid values are ' + _.pluck(feeLevels, 'name').join(', '))); |
|
|
|
return next(new ClientError('Invalid fee level. Valid values are ' + _.map(feeLevels, 'name').join(', '))); |
|
|
|
} |
|
|
|
|
|
|
|
if (_.isNumber(opts.feePerKb)) { |
|
|
@ -2642,7 +2642,7 @@ WalletService.prototype.rejectTx = function(opts, cb) { |
|
|
|
}, |
|
|
|
function(next) { |
|
|
|
if (txp.status == 'rejected') { |
|
|
|
var rejectedBy = _.pluck(_.filter(txp.actions, { |
|
|
|
var rejectedBy = _.map(_.filter(txp.actions, { |
|
|
|
type: 'reject' |
|
|
|
}), 'copayerId'); |
|
|
|
|
|
|
@ -3005,7 +3005,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) { |
|
|
|
function(next) { |
|
|
|
if (txs) return next(); |
|
|
|
|
|
|
|
var addressStrs = _.pluck(addresses, 'address'); |
|
|
|
var addressStrs = _.map(addresses, 'address'); |
|
|
|
var bc = self._getBlockchainExplorer(wallet.coin, wallet.network); |
|
|
|
if (!bc) return next(new Error('Could not get blockchain explorer instance')); |
|
|
|
bc.getTransactions(addressStrs, from, to, function(err, rawTxs, total) { |
|
|
|