This commit is contained in:
Matias Alejo Garcia 2014-09-15 14:25:09 -03:00
commit 64072f83bc

View file

@ -53,7 +53,6 @@ function WalletFactory(config, version, pluginManager) {
this.storage = new this.Storage(storageOpts);
<<<<<<< HEAD
this.networks = {
'livenet': new this.Network(config.network.livenet),
'testnet': new this.Network(config.network.testnet),
@ -63,11 +62,7 @@ function WalletFactory(config, version, pluginManager) {
'testnet': new this.Blockchain(config.network.testnet),
};
this.walletDefaults = config.wallet;
=======
this.networkName = config.networkName;
this.walletDefaults = config.wallet || {};
>>>>>>> ALL TEST PASSING!!!
this.walletDefaults = config.walle || {};
this.version = version;
};
@ -100,7 +95,7 @@ WalletFactory.prototype.fromObj = function(obj, skipFields) {
obj.opts.reconnectDelay = this.walletDefaults.reconnectDelay;
// this is only used if private key or public key ring is skipped
obj.opts.networkName = this.networkName;
obj.opts.networkName = networkName;
skipFields = skipFields || [];
skipFields.forEach(function(k) {
@ -420,29 +415,28 @@ WalletFactory.prototype.joinCreateSession = function(opts, cb) {
});
joinNetwork.start(opts, function() {
joinNetwork.greet(decodedSecret.pubKey, opts.secretNumber);
joinNetwork.on('data', function(sender, data) {
if (data.type === 'walletId' && data.opts) {
if (data.networkName !== decodedSecret.networkName) {
return cb('badNetwork');
}
joinNetwork.greet(decodedSecret.pubKey, opts.secretNumber);
joinNetwork.on('data', function(sender, data) {
if (data.type === 'walletId' && data.opts) {
if (data.networkName !== decodedSecret.networkName) {
return cb('badNetwork');
}
data.opts.privateKey = privateKey;
data.opts.nickname = nickname;
data.opts.passphrase = passphrase;
data.opts.id = data.walletId;
self.create(data.opts, function(err, w) {
if (!err & w) {
w.sendWalletReady(s.pubKey);
} else {
if (!err) err = 'walletFull';
}
return cb(err, w);
});
});
});
};
data.opts.privateKey = privateKey;
data.opts.nickname = nickname;
data.opts.passphrase = passphrase;
data.opts.id = data.walletId;
self.create(data.opts, function(err, w) {
if (!err & w) {
w.sendWalletReady(s.pubKey);
} else {
if (!err) err = 'walletFull';
}
return cb(err, w);
});
}
});
});
};
module.exports = WalletFactory;