From bc11fa7493ea656b99ed2dcee4f676040ce2baef Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Mon, 26 May 2014 10:46:05 -0300 Subject: [PATCH 1/7] angularjs digest errors fixed --- index.html | 7 +++---- js/controllers/transactions.js | 23 +++++++++++------------ js/filters.js | 17 ++++++++++++----- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index 290ce3bba..e62994346 100644 --- a/index.html +++ b/index.html @@ -489,9 +489,8 @@

Last transactions

- + +
No transactions yet. @@ -511,7 +510,7 @@
-
+

{{vin.addr}}

{{vin.value}}
diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index b97659d89..ede169280 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copay.transactions').controller('TransactionsController', - function($scope, $rootScope, controllerUtils) { + function($scope, $rootScope, $timeout, controllerUtils) { $scope.title = 'Transactions'; $scope.loading = false; @@ -31,21 +31,21 @@ angular.module('copay.transactions').controller('TransactionsController', }; $scope.toogleLast = function () { - console.log('[toogleLast]'); - $scope.loading=true; + $scope.loading = true; $scope.lastShowed = !$scope.lastShowed; if ($scope.lastShowed) { $scope.getTransactions(function(txs){ - $scope.loading=false; - $scope.blockchain_txs = txs; - $rootScope.$digest(); + $timeout(function() { + $scope.loading = false; + $scope.blockchain_txs = txs; + $scope.$digest(); + }, 10); }); - } - else { - setTimeout(function(){ - $scope.loading=false; + } else { + $timeout(function(){ + $scope.loading = false; $rootScope.$digest(); - }); + }, 10); } }; @@ -90,7 +90,6 @@ angular.module('copay.transactions').controller('TransactionsController', $scope.getTransactions = function(cb) { var w =$rootScope.wallet; if (w) { - console.log('### Querying last transactions...'); //TODO var addresses = w.getAddressesStr(); if (addresses.length > 0) { diff --git a/js/filters.js b/js/filters.js index 258d22610..5954ea5d1 100644 --- a/js/filters.js +++ b/js/filters.js @@ -14,15 +14,22 @@ angular.module('copay.filters', []) return dic; } - var dic = inputs.reduce(reduce, {}); - return Object.keys(dic).map(function(key) { - return { addr: key, value: dic[key] }; - }); + var dic; + if (inputs) { + dic = inputs.reduce(reduce, {}); + return Object.keys(dic).map(function(key) { + return { addr: key, value: dic[key] }; + }); + } }; }) .filter('paged', function() { return function(elements) { - return elements.filter(Boolean); + if (elements) { + return elements.filter(Boolean); + } + + return false; }; }) .filter('limitAddress', function() { From 1e75f6e85cc698d7ad886e386290b655e3857376 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Mon, 26 May 2014 11:51:27 -0300 Subject: [PATCH 2/7] disable send form inputs while sending --- index.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 290ce3bba..355be854c 100644 --- a/index.html +++ b/index.html @@ -565,7 +565,8 @@ not valid
- +
@@ -605,7 +606,9 @@ {{notEnoughAmount}}
- +
BTC From 941d51648549000195c5e1eb45a9a8ea653bf504 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Mon, 26 May 2014 15:03:39 -0300 Subject: [PATCH 3/7] added password length checker --- index.html | 8 +++--- js/directives.js | 74 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index ca1239a4d..b2012aa34 100644 --- a/index.html +++ b/index.html @@ -192,8 +192,8 @@

Create a new wallet

- - + +
@@ -203,7 +203,7 @@

Join a Wallet in Creation

- +
@@ -294,7 +294,7 @@
Your Wallet Password (you don't need to share this) Required
- +
Wallet name Optional
diff --git a/js/directives.js b/js/directives.js index 606c5e9c9..822fdae85 100644 --- a/js/directives.js +++ b/js/directives.js @@ -105,7 +105,8 @@ angular.module('copay.directives') }); } } - }).directive('avatar', function($rootScope, controllerUtils) { + }) + .directive('avatar', function($rootScope, controllerUtils) { return { link: function(scope, element, attrs) { var peer = JSON.parse(attrs.peer) @@ -118,4 +119,75 @@ angular.module('copay.directives') } } } + }) + .directive('checkStrength', function() { + return { + replace: false, + restrict: 'EACM', + scope: { model: '=checkStrength' }, + link: function(scope, element, attrs) { + var _grep = function(elems, callback, invert) { + var callbackInverse, + matches = [], + i = 0, + length = elems.length, + callbackExpect = !invert; + + // Go through the array, only saving the items + // that pass the validator function + for (; i < length; i++) { + callbackInverse = !callback(elems[i], i); + if (callbackInverse !== callbackExpect) { + matches.push(elems[i]); + } + } + + return matches; + }; + + var strength = { + colors: ['#c0392b', '#e74c3c', '#d35400', '#f39c12', '#27ae60'], + mesureStrength: function (p) { + var _force = 0; + var _regex = /[$-/:-?{-~!"^_`\[\]]/g; + var _lowerLetters = /[a-z]+/.test(p); + var _upperLetters = /[A-Z]+/.test(p); + var _numbers = /[0-9]+/.test(p); + var _symbols = _regex.test(p); + var _flags = [_lowerLetters, _upperLetters, _numbers, _symbols]; + var _passedMatches = _grep(_flags, function (el) { return el === true; }).length; + + _force += 2 * p.length + ((p.length >= 10) ? 1 : 0); + _force += _passedMatches * 10; + + // penality (short password) + _force = (p.length <= 6) ? Math.min(_force, 10) : _force; + + // penality (poor variety of characters) + _force = (_passedMatches == 1) ? Math.min(_force, 10) : _force; + _force = (_passedMatches == 2) ? Math.min(_force, 20) : _force; + _force = (_passedMatches == 3) ? Math.min(_force, 40) : _force; + return _force; + }, + getColor: function (s) { + var idx = 0; + + if (s <= 10) { idx = 0; } + else if (s <= 20) { idx = 1; } + else if (s <= 30) { idx = 2; } + else if (s <= 40) { idx = 3; } + else { idx = 4; } + + return { idx: idx + 1, col: this.colors[idx] }; + } + }; + + scope.$watch('model', function (newValue, oldValue) { + if (newValue && newValue !== '') { + var c = strength.getColor(strength.mesureStrength(newValue)); + element.css({ 'border-color': c.col }) + } + }); + } + }; }); From 826f9ad5f79036e06309587d34f6f6f28d87f599 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 27 May 2014 15:20:49 -0300 Subject: [PATCH 4/7] multi-copayer launch script --- launch.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 launch.js diff --git a/launch.js b/launch.js new file mode 100755 index 000000000..4d2ade4b3 --- /dev/null +++ b/launch.js @@ -0,0 +1,32 @@ +#! /usr/bin/node + +'use strict'; + + + +var sys = require('sys') +var exec = require('child_process').exec; +function puts(error, stdout, stderr) { sys.puts(stdout) } + +function isNumber(n) { + return !isNaN(parseInt(n)) && isFinite(n); +} + +var args = process.argv.slice(2); +var n_str = args[0]; +if (!isNumber(n_str)) { + console.log('Program requires one numeric argument'); + process.exit(1); +} + +var N = parseInt(n_str); +var DEFAULT_PORT = process.env.DEFAULT_PORT || 3000; + + +for (var i=0; i Date: Tue, 27 May 2014 15:22:06 -0300 Subject: [PATCH 5/7] improve doc --- launch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launch.js b/launch.js index 4d2ade4b3..aaf071b2e 100755 --- a/launch.js +++ b/launch.js @@ -15,7 +15,7 @@ function isNumber(n) { var args = process.argv.slice(2); var n_str = args[0]; if (!isNumber(n_str)) { - console.log('Program requires one numeric argument'); + console.log('Program requires one numeric argument for the amount of copayers'); process.exit(1); } From 0152cb45a855b0b25275f2d07f70548e01d672dd Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 27 May 2014 16:16:22 -0300 Subject: [PATCH 6/7] optimize address generation protocol --- js/models/core/Wallet.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 55bc54305..bef624db9 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -82,14 +82,9 @@ Wallet.prototype._handlePublicKeyRing = function(senderId, data, isInbound) { var hasChanged = pkr.merge(inPKR, true); if (hasChanged) { - this.connectToAll(); if (this.publicKeyRing.isComplete()) { this._lockIncomming(); } - this.log('### BROADCASTING PKR'); - - recipients = null; - this.sendPublicKeyRing(recipients); } this.emit('publicKeyRingUpdated'); this.store(); From 065864beab35a94209e588a0a3905269ff92b8b2 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 27 May 2014 17:05:43 -0300 Subject: [PATCH 7/7] fix wallet creation problem --- js/models/core/Wallet.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index bef624db9..f221378ad 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -77,11 +77,15 @@ console.log('[Wallet.js.58] connecting'); //TODO Wallet.prototype._handlePublicKeyRing = function(senderId, data, isInbound) { this.log('RECV PUBLICKEYRING:', data); - var recipients, pkr = this.publicKeyRing; var inPKR = copay.PublicKeyRing.fromObj(data.publicKeyRing); + var wasIncomplete = !this.publicKeyRing.isComplete(); + var hasChanged = this.publicKeyRing.merge(inPKR, true); - var hasChanged = pkr.merge(inPKR, true); if (hasChanged) { + if (wasIncomplete) { + this.sendPublicKeyRing(); + this.connectToAll(); + } if (this.publicKeyRing.isComplete()) { this._lockIncomming(); }