mirror of https://github.com/BTCPrivate/copay.git
fix import / logs
This commit is contained in:
parent
436aeda1c3
commit
49205a76a0
|
@ -18,18 +18,10 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
|
|||
var password = $scope.password;
|
||||
updateStatus('Importing profile - Setting things up...');
|
||||
|
||||
identityService.importProfile(str,password, function(err){
|
||||
})
|
||||
copay.Identity.importFromEncryptedFullJson(str, password, {
|
||||
pluginManager: pluginManager,
|
||||
network: config.network,
|
||||
networkName: config.networkName,
|
||||
walletDefaults: config.wallet,
|
||||
passphraseConfig: config.passphraseConfig,
|
||||
}, function(err, iden) {
|
||||
identityService.importProfile(str,password, function(err, iden) {
|
||||
$scope.loading = false;
|
||||
if (err) {
|
||||
$scope.loading = false;
|
||||
|
||||
copay.logger.warn(err);
|
||||
if ((err.toString() || '').match('BADSTR')) {
|
||||
$scope.error = 'Bad password or corrupt profile file';
|
||||
} else if ((err.toString() || '').match('EEXISTS')) {
|
||||
|
@ -37,12 +29,8 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
|
|||
} else {
|
||||
$scope.error = 'Unknown error';
|
||||
}
|
||||
$scope.$digest();
|
||||
|
||||
} else {
|
||||
var firstWallet = iden.getLastFocusedWallet();
|
||||
root.bind($scope, iden, firstWallet);
|
||||
}
|
||||
$rootScope.$digest();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ Identity.create = function(opts, cb) {
|
|||
*
|
||||
* After opening a profile, and setting its wallet event handlers,
|
||||
* the client must run .netStart on each
|
||||
* wallet (or call Identity.netStart())
|
||||
* (probably on iden's newWallet handler
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @param {Object} opts.storage
|
||||
|
@ -322,7 +322,6 @@ Identity.prototype.close = function() {
|
|||
};
|
||||
|
||||
|
||||
// TODO: Add feedback function
|
||||
Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
||||
var self = this;
|
||||
preconditions.checkArgument(cb);
|
||||
|
@ -336,28 +335,30 @@ Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
|||
|
||||
var w = importFunction(obj, readOpts);
|
||||
if (!w) return cb(new Error('Could not decrypt'));
|
||||
log.debug('Wallet decryped:' + w.getName());
|
||||
log.debug('Wallet decrypted:' + w.getName());
|
||||
|
||||
self._checkVersion(w.version);
|
||||
log.debug('Updating Indexes for wallet:' + w.getName());
|
||||
w.updateIndexes(function(err) {
|
||||
log.debug('Adding wallet to profile:' + w.getName());
|
||||
self.bindWallet(w);
|
||||
self.updateFocusedTimestamp(w.getId());
|
||||
|
||||
var writeOpts = _.extend({
|
||||
noWallets: true
|
||||
}, opts);
|
||||
|
||||
self.storeWallet(w, function(err) {
|
||||
if (err) return cb(err);
|
||||
self.store(writeOpts, function(err) {
|
||||
return cb(err, w);
|
||||
});
|
||||
});
|
||||
self.storeWallet(w, cb);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Identity.prototype.importMultipleWalletsFromObj = function(objs, opts) {
|
||||
var self = this;
|
||||
opts = opts || {};
|
||||
|
||||
async.eachSeries(objs, function(walletData, cb) {
|
||||
if (!walletData)
|
||||
return cb();
|
||||
self.importWalletFromObj(walletData, opts, cb);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Wallet} wallet
|
||||
* @param {Function} cb
|
||||
|
@ -414,30 +415,11 @@ Identity.importFromFullJson = function(str, password, opts, cb) {
|
|||
iden.store(opts, function(err) {
|
||||
if (err) return cb(err); //profile already exists
|
||||
|
||||
opts.failIfExists = false;
|
||||
async.map(json.wallets, function(walletData, cb) {
|
||||
|
||||
if (!walletData)
|
||||
return cb();
|
||||
|
||||
iden.importWalletFromObj(walletData, opts, function(err, w) {
|
||||
if (err) return cb(err);
|
||||
log.debug('Wallet ' + w.getId() + ' imported');
|
||||
cb();
|
||||
});
|
||||
}, function(err, results) {
|
||||
if (err) return cb(err);
|
||||
|
||||
iden.store(opts, function(err) {
|
||||
return cb(err, iden);
|
||||
});
|
||||
});
|
||||
|
||||
return cb(null, iden, json.wallets);
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @desc binds a wallet's events and emits 'newWallet'
|
||||
* @param {string} walletId Wallet id to be binded
|
||||
|
|
|
@ -220,8 +220,7 @@ Insight.prototype.subscribe = function(addresses) {
|
|||
if (!self.subscribed[address]) {
|
||||
var handler = handlerFor(self, address);
|
||||
self.subscribed[address] = handler;
|
||||
log.debug('Subscribe to: ', address);
|
||||
|
||||
// log.debug('Subscribe to: ', address);
|
||||
s.emit('subscribe', address);
|
||||
s.on(address, handler);
|
||||
}
|
||||
|
|
|
@ -497,8 +497,6 @@ PublicKeyRing.prototype.getCosigner = function(pubKey) {
|
|||
PublicKeyRing.prototype.buildAddressCache = function() {
|
||||
var ret = [];
|
||||
var self = this;
|
||||
|
||||
log.info('Rebuilding Address Cache...this will take a while');
|
||||
_.each(this.indexes, function(index) {
|
||||
for (var i = 0; i < index.receiveIndex; i++) {
|
||||
self._getAddress(i, false, index.copayerIndex);
|
||||
|
@ -507,7 +505,6 @@ PublicKeyRing.prototype.buildAddressCache = function() {
|
|||
self._getAddress(i, true, index.copayerIndex);
|
||||
}
|
||||
});
|
||||
log.info('...done!');
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1986,7 +1986,7 @@ Wallet.prototype.subscribeToAddresses = function() {
|
|||
|
||||
var addresses = this.getAddresses();
|
||||
this.blockchain.subscribe(addresses);
|
||||
log.debug('Subscribed to ' + addresses.length + ' addresses');
|
||||
log.debug('Wallet:' + this.getName() + ' Subscribed to:' + addresses.length + ' addresses');
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -310,10 +310,10 @@ angular.module('copayApp.services')
|
|||
networkName: config.networkName,
|
||||
walletDefaults: config.wallet,
|
||||
passphraseConfig: config.passphraseConfig,
|
||||
}, function(err, iden) {
|
||||
}, function(err, iden, walletObjs) {
|
||||
if (err) return cb(err);
|
||||
root.bind(iden);
|
||||
iden.openWallets();
|
||||
iden.importMultipleWalletsFromObj(walletObjs);
|
||||
return cb();
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue