|
|
@ -253,7 +253,7 @@ WalletService.prototype.getWallet = function(opts, cb) { |
|
|
|
|
|
|
|
self.storage.fetchWallet(self.walletId, function(err, wallet) { |
|
|
|
if (err) return cb(err); |
|
|
|
if (!wallet) return cb(new ClientError('Wallet not found')); |
|
|
|
if (!wallet) return cb(Errors.WALLET_NOT_FOUND); |
|
|
|
return cb(null, wallet); |
|
|
|
}); |
|
|
|
}; |
|
|
@ -285,7 +285,7 @@ WalletService.prototype.replaceTemporaryRequestKey = function(opts, cb) { |
|
|
|
self.storage.fetchWallet(self.walletId, function(err, wallet) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
if (!wallet) return cb(new ClientError('Wallet not found')); |
|
|
|
if (!wallet) return cb(Errors.WALLET_NOT_FOUND); |
|
|
|
var hash = WalletUtils.getCopayerHash(opts.name, opts.xPubKey, opts.requestPubKey); |
|
|
|
if (!self._verifySignature(hash, opts.copayerSignature, wallet.pubKey)) { |
|
|
|
return cb(new ClientError()); |
|
|
@ -397,7 +397,7 @@ WalletService.prototype.joinWallet = function(opts, cb) { |
|
|
|
self.storage.fetchWallet(opts.walletId, function(err, wallet) { |
|
|
|
|
|
|
|
if (err) return cb(err); |
|
|
|
if (!wallet) return cb(new ClientError('Wallet not found')); |
|
|
|
if (!wallet) return cb(Errors.WALLET_NOT_FOUND); |
|
|
|
|
|
|
|
var hash = WalletUtils.getCopayerHash(opts.name, opts.xPubKey, opts.requestPubKey); |
|
|
|
if (!self._verifySignature(hash, opts.copayerSignature, wallet.pubKey)) { |
|
|
@ -544,8 +544,7 @@ WalletService.prototype.createAddress = function(opts, 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')); |
|
|
|
if (!wallet.isComplete()) return cb(Errors.WALLET_NOT_COMPLETE); |
|
|
|
|
|
|
|
var address = wallet.createAddress(false); |
|
|
|
|
|
|
@ -977,8 +976,7 @@ WalletService.prototype.createTx = function(opts, 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')); |
|
|
|
if (!wallet.isComplete()) return cb(Errors.WALLET_NOT_COMPLETE); |
|
|
|
|
|
|
|
var copayer = wallet.getCopayer(self.copayerId); |
|
|
|
var hash; |
|
|
@ -1087,7 +1085,7 @@ WalletService.prototype.getTx = function(opts, cb) { |
|
|
|
|
|
|
|
self.storage.fetchTx(self.walletId, opts.txProposalId, function(err, txp) { |
|
|
|
if (err) return cb(err); |
|
|
|
if (!txp) return cb(new ClientError('Transaction proposal not found')); |
|
|
|
if (!txp) return cb(Errors.TX_NOT_FOUND); |
|
|
|
return cb(null, txp); |
|
|
|
}); |
|
|
|
}; |
|
|
@ -1665,7 +1663,7 @@ WalletService.prototype.scan = function(opts, 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')); |
|
|
|
if (!wallet.isComplete()) return cb(Errors.WALLET_NOT_COMPLETE); |
|
|
|
|
|
|
|
wallet.scanStatus = 'running'; |
|
|
|
self.storage.storeWallet(wallet, function(err) { |
|
|
@ -1724,7 +1722,7 @@ WalletService.prototype.startScan = function(opts, cb) { |
|
|
|
|
|
|
|
self.getWallet({}, function(err, wallet) { |
|
|
|
if (err) return cb(err); |
|
|
|
if (!wallet.isComplete()) return cb(new ClientError('Wallet is not complete')); |
|
|
|
if (!wallet.isComplete()) return cb(Errors.WALLET_NOT_COMPLETE); |
|
|
|
|
|
|
|
setTimeout(function() { |
|
|
|
self.scan(opts, scanFinished); |
|
|
|