diff --git a/js/controllers/setup.js b/js/controllers/setup.js
index 1feaa1a77..a5fa11814 100644
--- a/js/controllers/setup.js
+++ b/js/controllers/setup.js
@@ -26,11 +26,12 @@ angular.module('copay.setup').controller('SetupController',
updateRCSelect(tc);
});
- $scope.create = function(totalCopayers, requiredCopayers) {
+ $scope.create = function(totalCopayers, requiredCopayers, walletName) {
$scope.loading = true;
var opts = {
requiredCopayers: requiredCopayers,
- totalCopayers: totalCopayers
+ totalCopayers: totalCopayers,
+ name: walletName,
};
var w = walletFactory.create(opts);
controllerUtils.setupUxHandlers(w);
diff --git a/js/controllers/signin.js b/js/controllers/signin.js
index 67db9c1a7..0a0c80070 100644
--- a/js/controllers/signin.js
+++ b/js/controllers/signin.js
@@ -3,8 +3,8 @@
angular.module('copay.signin').controller('SigninController',
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
$scope.loading = false;
- $scope.walletIds = walletFactory.getWalletIds();
- $scope.selectedWalletId = $scope.walletIds.length ? $scope.walletIds[0]:null;
+ $scope.wallets = walletFactory.getWallets();
+ $scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : null;
$scope.create = function() {
$location.path('setup');
@@ -12,14 +12,13 @@ angular.module('copay.signin').controller('SigninController',
$scope.open = function(walletId, opts) {
$scope.loading = true;
-
-console.log('[signin.js.23:walletId:]',walletId); //TODO
var w = walletFactory.open(walletId, opts);
controllerUtils.setupUxHandlers(w);
};
$scope.join = function(secret) {
- if (!secret || !secret.length) {
+ if (!secret || secret.length !==66 || !secret.match(/^[0-9a-f]*$/) ) {
+ $rootScope.flashMessage = { message: 'Bad secret secret string', type: 'error'};
return;
}
$scope.loading = true;
diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js
index 975a98314..95d0c0f98 100644
--- a/js/models/core/Wallet.js
+++ b/js/models/core/Wallet.js
@@ -25,6 +25,7 @@ function Wallet(opts) {
this.log('creating '+opts.requiredCopayers+' of '+opts.totalCopayers+' wallet');
this.id = opts.id || Wallet.getRandomId();
+ this.name = opts.name;
this.verbose = opts.verbose;
this.publicKeyRing.walletId = this.id;
this.txProposals.walletId = this.id;
@@ -137,6 +138,7 @@ Wallet.prototype._optsToObj = function () {
spendUnconfirmed: this.spendUnconfirmed,
requiredCopayers: this.requiredCopayers,
totalCopayers: this.totalCopayers,
+ name: this.name,
};
return obj;
@@ -172,6 +174,7 @@ Wallet.prototype.netStart = function() {
copayerId: myId,
signingKeyHex: self.privateKey.getSigningKey(),
};
+
net.start(startOpts, function() {
self.emit('created');
for (var i=0; i') ) : i.id;
+ });
+ return ret;
+};
WalletFactory.prototype.remove = function(walletId) {
// TODO remove wallet contents
diff --git a/js/models/network/WebRTC.js b/js/models/network/WebRTC.js
index a5569c52b..2f0aec30b 100644
--- a/js/models/network/WebRTC.js
+++ b/js/models/network/WebRTC.js
@@ -192,6 +192,7 @@ Network.prototype._onData = function(data, isInbound, peerId) {
Network.prototype._checkAnyPeer = function() {
if (!this.connectedPeers.length) {
console.log('EMIT openError: no more peers, not even you!');
+ this._cleanUp();
this.emit('openError');
}
}
@@ -251,8 +252,9 @@ Network.prototype._setupPeerHandlers = function(openCallback) {
});
p.on('error', function(err) {
- console.log('### PEER ERROR:', err);
- //self.disconnect(null, true); // force disconnect
+ if (!err.message.match(/Could\snot\sconnect\sto peer/)) {
+ console.log('### PEER ERROR:', err);
+ }
self._checkAnyPeer();
});
@@ -311,11 +313,12 @@ Network.prototype.start = function(opts, openCallback) {
if (this.started) return openCallback();
opts.connectedPeers = opts.connectedPeers || [];
- if (!this.copayerId)
+ if (!this.copayerId)
this.setCopayerId(opts.copayerId);
- if (!this.signingKey)
+ if (!this.signingKey)
this.setSigningKey(opts.signingKeyHex);
+ console.log('CREATING PEER INSTANCE:', this.peerId); //TODO
this.peer = new Peer(this.peerId, this.opts);
this._setupPeerHandlers(openCallback);
for (var i = 0; i