|
|
@ -32,6 +32,29 @@ Storage.prototype.storeWallet = function (wallet, cb) { |
|
|
|
this.db.put('wallet-' + wallet.id, wallet, cb); |
|
|
|
}; |
|
|
|
|
|
|
|
Storage.prototype.storeWalletAndUpdateCopayersLookup = function (wallet, cb) { |
|
|
|
var ops = []; |
|
|
|
ops.push({ type: 'put', key: 'wallet-' + wallet.id, value: wallet }); |
|
|
|
_.each(wallet.copayers, function (copayer) { |
|
|
|
var value = { |
|
|
|
walletId: wallet.id, |
|
|
|
signingPubKey: copayer.signingPubKey, |
|
|
|
}; |
|
|
|
ops.push({ type: 'put', key: 'copayer-' + copayer.id, value: value }); |
|
|
|
}); |
|
|
|
this.db.batch(ops, cb); |
|
|
|
}; |
|
|
|
|
|
|
|
Storage.prototype.fetchCopayerLookup = function (copayerId, cb) { |
|
|
|
this.db.get('copayer-' + copayerId, function (err, data) { |
|
|
|
if (err) { |
|
|
|
if (err.notFound) return cb(); |
|
|
|
return cb(err); |
|
|
|
} |
|
|
|
return cb(null, data); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
Storage.prototype.fetchTx = function (walletId, txProposalId, cb) { |
|
|
|
this.db.get('wallet-' + walletId + '-txp-' + txProposalId, function (err, data) { |
|
|
|
if (err) { |
|
|
|