Browse Source

add WALLET_NOT_COMPLETE

activeAddress
Ivan Socolsky 10 years ago
parent
commit
76c545b110
  1. 2
      lib/errors/errordefinitions.js
  2. 10
      lib/server.js
  3. 5
      test/integration/server.js

2
lib/errors/errordefinitions.js

@ -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',
};

10
lib/server.js

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

5
test/integration/server.js

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

Loading…
Cancel
Save