checks network match when joining a wallet
This commit is contained in:
parent
c5a3049b9d
commit
4ae3748414
5 changed files with 26 additions and 5 deletions
|
|
@ -248,7 +248,7 @@ PublicKeyRing.prototype._checkInPKR = function(inPKR, ignoreId) {
|
|||
}
|
||||
|
||||
if (this.network.name !== inPKR.network.name) {
|
||||
throw new Error('inPKR network mismatch. Should be '+this.network.name +
|
||||
throw new Error('Network mismatch. Should be '+this.network.name +
|
||||
' and found '+inPKR.network.name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,15 @@ Wallet.prototype._handlePublicKeyRing = function(senderId, data, isInbound) {
|
|||
|
||||
var inPKR = copay.PublicKeyRing.fromObj(data.publicKeyRing);
|
||||
var wasIncomplete = !this.publicKeyRing.isComplete();
|
||||
var hasChanged = this.publicKeyRing.merge(inPKR, true);
|
||||
var hasChanged;
|
||||
|
||||
try{
|
||||
hasChanged = this.publicKeyRing.merge(inPKR, true);
|
||||
} catch (e){
|
||||
console.log('## WALLET ERROR', e); //TODO
|
||||
this.emit('connectionError', e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasChanged) {
|
||||
if (wasIncomplete) {
|
||||
|
|
@ -381,7 +389,8 @@ Wallet.prototype.sendWalletId = function(recipients) {
|
|||
this.network.send(recipients, {
|
||||
type: 'walletId',
|
||||
walletId: this.id,
|
||||
opts: this._optsToObj()
|
||||
opts: this._optsToObj(),
|
||||
networkName: this.getNetworkName(),
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -220,6 +220,12 @@ WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphras
|
|||
});
|
||||
self.network.on('data', function(sender, data) {
|
||||
if (data.type ==='walletId') {
|
||||
|
||||
console.log('[WalletFactory.js.223]', data.networkName, self.networkName); //TODO
|
||||
if (data.networkName !== self.networkName ){
|
||||
return cb('badNetwork');
|
||||
}
|
||||
|
||||
data.opts.privateKey = privateKey;
|
||||
data.opts.nickname = nickname;
|
||||
data.opts.passphrase = passphrase;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue