Merge pull request #254 from cmgustavo/bug/join-wallet

Fixed join wallet from remote peer
This commit is contained in:
Matias Alejo Garcia 2014-05-01 18:37:49 -03:00
commit 5b09440828
4 changed files with 12 additions and 12 deletions

View File

@ -31,22 +31,19 @@ angular.module('copay.signin').controller('SigninController',
walletFactory.network.on('badSecret', function() {
});
walletFactory.joinCreateSession($scope.connectionId, $scope.nickname, function(err,w) {
var passphrase = Passphrase.getBase64($scope.joinPassword);
walletFactory.joinCreateSession($scope.connectionId, $scope.nickname, passphrase, function(err,w) {
$scope.loading = false;
if (err || !w || !$scope.joinPassword) {
if (err || !w) {
if (err === 'joinError')
$rootScope.flashMessage = { message: 'Can not find peer'};
else if (err === 'badSecret')
$rootScope.flashMessage = { message: 'Bad secret secret string', type: 'error'};
else if (!$scope.joinPassword)
$rootScope.flashMessage = { message: 'Enter your wallet password', type: 'error' };
else
$rootScope.flashMessage = { message: 'Unknown error', type: 'error'};
controllerUtils.onErrorDigest();
} else {
var passphrase = Passphrase.getBase64($scope.joinPassword);
w.storage._setPassphrase(passphrase);
controllerUtils.startNetwork(w);
}
});

View File

@ -2,7 +2,7 @@
function Passphrase(config) {
config = config || {};
this.salt = config.storageSalt;
this.salt = config.storageSalt || 'mjuBtGybi/4=';
this.iterations = config.iterations || 1000;
};

View File

@ -153,7 +153,7 @@ WalletFactory.prototype.remove = function(walletId) {
};
WalletFactory.prototype.joinCreateSession = function(secret, nickname, cb) {
WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphrase, cb) {
var self = this;
var s;
@ -162,7 +162,7 @@ WalletFactory.prototype.joinCreateSession = function(secret, nickname, cb) {
} catch (e) {
return cb('badSecret');
}
//Create our PrivateK
var privateKey = new PrivateKey({ networkName: this.networkName });
this.log('\t### PrivateKey Initialized');
@ -180,6 +180,7 @@ WalletFactory.prototype.joinCreateSession = function(secret, nickname, cb) {
if (data.type ==='walletId') {
data.opts.privateKey = privateKey;
data.opts.nickname = nickname;
data.opts.passphrase = passphrase;
var w = self.open(data.walletId, data.opts);
w.firstCopayerId = s.pubKey;
return cb(null, w);

View File

@ -47,9 +47,11 @@ Storage.prototype._read = function(k) {
var ret;
try {
ret = localStorage.getItem(k);
ret = this._decrypt(ret);
ret = ret.toString(CryptoJS.enc.Utf8);
ret = JSON.parse(ret);
if (ret){
ret = this._decrypt(ret);
ret = ret.toString(CryptoJS.enc.Utf8);
ret = JSON.parse(ret);
}
} catch (e) {
console.log('Error while decrypting: '+e);
throw e;