add WALLET_NOT_COMPLETE

This commit is contained in:
Ivan Socolsky 2015-08-05 10:44:09 -03:00
parent 03fe48209e
commit 76c545b110
3 changed files with 8 additions and 9 deletions

View File

@ -25,7 +25,7 @@ var errors = {
UPGRADE_NEEDED: 'Client app needs to be upgraded',
WALLET_ALREADY_EXISTS: 'Wallet already exists',
WALLET_FULL: 'Wallet full',
WALLET_NOT_COMPLETE: 'Replace only works on complete wallets',
WALLET_NOT_COMPLETE: 'Wallet is not complete',
WALLET_NOT_FOUND: 'Wallet not found',
};

View File

@ -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;
@ -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);

View File

@ -1547,7 +1547,8 @@ describe('Wallet service', function() {
server.createAddress({}, function(err, address) {
should.not.exist(address);
should.exist(err);
err.message.should.contain('not complete');
err.code.should.equal('WALLET_NOT_COMPLETE');
err.message.should.equal('Wallet is not complete');
done();
});
});
@ -1578,7 +1579,7 @@ describe('Wallet service', function() {
server.createTx(txOpts, function(err, tx) {
should.not.exist(tx);
should.exist(err);
err.message.should.contain('not complete');
err.code.should.equal('WALLET_NOT_COMPLETE');
done();
});
});