diff --git a/index.html b/index.html
index fb9330988..e554b4fde 100644
--- a/index.html
+++ b/index.html
@@ -66,12 +66,11 @@
Open a Existing Wallet
-
-
+
diff --git a/js/config.js b/js/config.js
index 61e45f54b..9d2bf0553 100644
--- a/js/config.js
+++ b/js/config.js
@@ -5,7 +5,7 @@ var config = {
network: {
apiKey: 'lwjd5qra8257b9',
maxPeers: 3,
- debug: 0,
+ debug: 3,
},
wallet: {
requiredCopayers: 2,
@@ -15,7 +15,7 @@ var config = {
host: 'localhost',
port: 3001
},
- verbose: 0,
+ verbose: 1,
};
var log = function () {
diff --git a/js/controllers/signin.js b/js/controllers/signin.js
index 810b9229b..62fca1008 100644
--- a/js/controllers/signin.js
+++ b/js/controllers/signin.js
@@ -7,6 +7,8 @@ angular.module('copay.signin').controller('SigninController',
// $rootScope.peerId = peerData ? peerData.peerId : null;
$scope.loading = false;
+ $scope.selectedWalletId = false;
+
$scope.listWalletIds = function() {
return copay.Wallet.factory.getWalletIds();
};
@@ -23,12 +25,20 @@ angular.module('copay.signin').controller('SigninController',
$scope.open = function(walletId) {
$scope.loading = true;
- if (Network.openWallet(walletId)) {
+
+ Network.openWallet(walletId);
+
+ if ($rootScope.wallet && $rootScope.wallet.id) {
Network.init(function() {
$location.path('peer');
$rootScope.$digest();
});
}
+ else {
+ $scope.loading = false;
+ $rootScope.flashMessage = {type:'error', message: 'Wallet not found'};
+ $location.path('signin');
+ }
};
$scope.join = function(cid) {
diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js
index 50fe25d5e..beaf553cb 100644
--- a/js/controllers/transactions.js
+++ b/js/controllers/transactions.js
@@ -23,5 +23,5 @@ angular.module('copay.transactions').controller('TransactionsController',
}
];
- $scope.txsoutput = $rootScope.wallet.txProposals.txps;
+ $scope.txsoutput = $rootScope.wallet.getTxProposals();
});
diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js
index dd4a03e2a..f876ba3d0 100644
--- a/js/models/core/Wallet.js
+++ b/js/models/core/Wallet.js
@@ -63,11 +63,19 @@ Wallet.prototype.create = function(opts) {
Wallet.prototype._checkLoad = function(walletId) {
- return (
- this.storage.get(walletId, 'publicKeyRing') &&
+ var ret = this.storage.get(walletId, 'publicKeyRing') &&
this.storage.get(walletId, 'txProposals') &&
this.storage.get(walletId, 'privateKey')
- );
+ ;
+
+console.log('[Wallet.js.71]',
+ this.storage.get(walletId, 'publicKeyRing'),
+ this.storage.get(walletId, 'txProposals'),
+ this.storage.get(walletId, 'privateKey'));
+
+console.log('[Wallet.js.73:ret:]',walletId, ret); //TODO
+
+ return ret;
}
Wallet.prototype.load = function(walletId) {
@@ -138,6 +146,29 @@ Wallet.prototype.generateAddress = function() {
return addr;
};
+Wallet.prototype.getTxProposals = function() {
+ var ret = [];
+ this.txProposals.txps.forEach(function(txp) {
+ var i = {txp:txp};
+ i.signedByUs = txp.signedBy[this.privateKey.id]?true:false;
+ ret.push(i);
+ });
+
+ return ret;
+};
+
+
+Wallet.prototype.addSeenToTxProposals = function() {
+ var ret=false;
+ this.txProposals.txps.forEach(function(txp) {
+ if (!txp.seenBy[this.privateKey.id]) {
+ txp.seenBy[this.privateKey.id] = Date.now();
+ ret = true;
+ }
+ });
+ return ret;
+};
+
// // HERE? not sure
// Wallet.prototype.cleanPeers = function() {
// this.storage.remove('peerData');
diff --git a/js/services/network.js b/js/services/network.js
index edeedb728..a4e69dac7 100644
--- a/js/services/network.js
+++ b/js/services/network.js
@@ -114,8 +114,10 @@ angular.module('copay.network')
var recipients;
var inTxProposals = copay.TxProposals.fromObj(data.txProposals);
var mergeInfo = w.txProposals.merge(inTxProposals, true);
- if ( mergeInfo.merged && !data.isBroadcast) {
- log('### BROADCASTING txProposals');
+
+ var addSeen = w.addSeenToTxProposals();
+ if ((mergeInfo.merged && !data.isBroadcast) || addSeen) {
+ log('### BROADCASTING txProposals. ' );
recipients = null;
shouldSend = true;
}