Merge pull request #623 from matiu/feature/livenet2

Feature/livenet2
This commit is contained in:
Gustavo Maximiliano Cortez 2014-06-09 18:10:51 -03:00
commit 43806a5825
6 changed files with 38 additions and 7 deletions

View file

@ -175,6 +175,11 @@ Wallet.prototype._handleDisconnect = function(peerID) {
this.emit('disconnect', peerID);
};
Wallet.prototype.getNetworkName = function() {
return this.publicKeyRing.network.name;
};
Wallet.prototype._optsToObj = function() {
var obj = {
id: this.id,

View file

@ -23,10 +23,10 @@ function WalletFactory(config, version) {
this.network = new Network(config.network);
this.blockchain = new Blockchain(config.blockchain);
this.networkName = config.networkName;
this.verbose = config.verbose;
this.networkName = config.networkName;
this.verbose = config.verbose;
this.walletDefaults = config.wallet;
this.version = version;
this.version = version;
}
WalletFactory.prototype.log = function(){
@ -139,6 +139,20 @@ WalletFactory.prototype._checkVersion = function(inVersion) {
}
};
WalletFactory.prototype._checkNetwork = function(inNetworkName) {
if( this.networkName !== inNetworkName ) {
throw new Error('This Wallet is configured for '
+ inNetworkName
+ ' while currently Copay is configured for: '
+ this.networkName
+ '. Check your settings.'
);
}
};
WalletFactory.prototype.open = function(walletId, opts) {
opts = opts || {};
opts.id = walletId;
@ -148,6 +162,7 @@ WalletFactory.prototype.open = function(walletId, opts) {
var w = this.read(walletId);
if (w) {
this._checkVersion(w.version);
this._checkNetwork(w.getNetworkName());
w.store();
}
return w;
@ -172,8 +187,7 @@ WalletFactory.prototype.decodeSecret = function(secret) {
} catch (e) {
return false;
}
}
};
WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphrase, cb) {
var self = this;