|
|
@ -77,14 +77,9 @@ Storage.prototype.storeWalletAndUpdateCopayersLookup = function(wallet, cb) { |
|
|
|
return this.storeWallet(wallet, cb); |
|
|
|
}; |
|
|
|
|
|
|
|
Storage.prototype.fetchCopayerLookup = function(copayerId, cb) { |
|
|
|
Storage.prototype.fetchCopayerLookup2 = function(copayerId, cb) { |
|
|
|
this.db.collection(collections.WALLETS).findOne({ |
|
|
|
'copayers.id': copayerId |
|
|
|
}, { |
|
|
|
fields: { |
|
|
|
id: 1, |
|
|
|
copayers: 1, |
|
|
|
}, |
|
|
|
}, function(err, result) { |
|
|
|
if (err) return cb(err); |
|
|
|
if (!result) return cb(); |
|
|
@ -98,6 +93,28 @@ Storage.prototype.fetchCopayerLookup = function(copayerId, cb) { |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
Storage.prototype.fetchCopayerLookup = function(copayerId, cb) { |
|
|
|
this.db.collection(collections.WALLETS).find({}).toArray(function(err, result) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
result = _.find(result, function(w) { |
|
|
|
return _.any(w.copayers, { |
|
|
|
id: copayerId |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (!result) return cb(); |
|
|
|
var copayer = _.find(result.copayers, { |
|
|
|
id: copayerId |
|
|
|
}); |
|
|
|
return cb(null, { |
|
|
|
walletId: result.id, |
|
|
|
requestPubKey: copayer.requestPubKey, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
// TODO: should be done client-side
|
|
|
|
Storage.prototype._completeTxData = function(walletId, txs, cb) { |
|
|
|
var txList = [].concat(txs); |
|
|
|