|
|
@ -91,6 +91,11 @@ WalletService.getInstanceWithAuth = function(opts, cb) { |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
WalletService.prototype._runLocked = function(cb, task) { |
|
|
|
$.checkState(this.walletId); |
|
|
|
this.lock.runLocked(this.walletId, cb, task); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Creates a new wallet. |
|
|
@ -193,7 +198,7 @@ WalletService.prototype.replaceTemporaryRequestKey = function(opts, cb) { |
|
|
|
if (opts.isTemporaryRequestKey) |
|
|
|
return cb(new ClientError('Bad arguments')); |
|
|
|
|
|
|
|
self.lock.runLocked(self.walletId, cb, function(cb) { |
|
|
|
self._runLocked(cb, function(cb) { |
|
|
|
self.storage.fetchWallet(self.walletId, function(err, wallet) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
@ -301,7 +306,8 @@ WalletService.prototype.joinWallet = function(opts, cb) { |
|
|
|
if (_.isEmpty(opts.name)) |
|
|
|
return cb(new ClientError('Invalid copayer name')); |
|
|
|
|
|
|
|
self.lock.runLocked(opts.walletId, cb, function(cb) { |
|
|
|
self.walletId = opts.walletId; |
|
|
|
self._runLocked(cb, function(cb) { |
|
|
|
self.storage.fetchWallet(opts.walletId, function(err, wallet) { |
|
|
|
|
|
|
|
if (err) return cb(err); |
|
|
@ -360,7 +366,7 @@ WalletService.prototype.joinWallet = function(opts, cb) { |
|
|
|
WalletService.prototype.createAddress = function(opts, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
self.lock.runLocked(self.walletId, cb, function(cb) { |
|
|
|
self._runLocked(cb, function(cb) { |
|
|
|
self.getWallet({}, function(err, wallet) { |
|
|
|
if (err) return cb(err); |
|
|
|
if (!wallet.isComplete()) |
|
|
@ -615,7 +621,7 @@ WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
if (!Utils.checkRequired(opts, ['toAddress', 'amount', 'proposalSignature'])) |
|
|
|
return cb(new ClientError('Required argument missing')); |
|
|
|
|
|
|
|
self.lock.runLocked(self.walletId, cb, function(cb) { |
|
|
|
self._runLocked(cb, function(cb) { |
|
|
|
self.getWallet({}, function(err, wallet) { |
|
|
|
if (err) return cb(err); |
|
|
|
if (!wallet.isComplete()) return cb(new ClientError('Wallet is not complete')); |
|
|
@ -705,7 +711,7 @@ WalletService.prototype.getTx = function(opts, cb) { |
|
|
|
WalletService.prototype.removeWallet = function(opts, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
self.lock.runLocked(self.walletId, cb, function(cb) { |
|
|
|
self._runLocked(cb, function(cb) { |
|
|
|
self.storage.removeWallet(self.walletId, cb); |
|
|
|
}); |
|
|
|
}; |
|
|
@ -723,7 +729,7 @@ WalletService.prototype.removePendingTx = function(opts, cb) { |
|
|
|
if (!Utils.checkRequired(opts, ['txProposalId'])) |
|
|
|
return cb(new ClientError('Required argument missing')); |
|
|
|
|
|
|
|
self.lock.runLocked(self.walletId, cb, function(cb) { |
|
|
|
self._runLocked(cb, function(cb) { |
|
|
|
|
|
|
|
self.getTx({ |
|
|
|
txProposalId: opts.txProposalId, |
|
|
@ -1181,7 +1187,7 @@ WalletService.prototype.scan = function(opts, cb) { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
self.lock.runLocked(self.walletId, cb, function(cb) { |
|
|
|
self._runLocked(cb, function(cb) { |
|
|
|
self.getWallet({}, function(err, wallet) { |
|
|
|
if (err) return cb(err); |
|
|
|
if (!wallet.isComplete()) return cb(new ClientError('Wallet is not complete')); |
|
|
|