From 31b0755ad88bf627bc90bf32388ade33c2b2b9e0 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Sun, 20 Apr 2014 16:01:23 -0300 Subject: [PATCH 1/5] change default to use public PeerJS server ...so that when people run things, it works the first time without having to change the config. --- js/config.template.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/config.template.js b/js/config.template.js index e49763637..eb8cdcbb8 100644 --- a/js/config.template.js +++ b/js/config.template.js @@ -3,12 +3,12 @@ var config = { networkName: 'testnet', network: { -// key: 'lwjd5qra8257b9', + key: 'lwjd5qra8257b9', //Copay API key for public PeerJS server // This is for running local peerJs with params: ./peerjs -p 10009 -k 'sdfjhwefh' - key: 'sdfjhwefh', - host: 'localhost', - port: 10009, - path: '/', + //key: 'sdfjhwefh', + //host: 'localhost', + //port: 10009, + //path: '/', maxPeers: 3, debug: 3, }, From 4ea7a2c78543ce8ae48ef469ea61490fb95bfa05 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Sun, 20 Apr 2014 16:06:56 -0300 Subject: [PATCH 2/5] make things easier to install mv config to root directory, and improve README --- .gitignore | 2 +- README.md | 16 ++++++++++++++++ js/config.template.js => config.template.js | 0 index.html | 3 ++- 4 files changed, 19 insertions(+), 2 deletions(-) rename js/config.template.js => config.template.js (100%) diff --git a/.gitignore b/.gitignore index af45d2c34..cd2274086 100644 --- a/.gitignore +++ b/.gitignore @@ -40,4 +40,4 @@ lib/* !lib/socket.io.js js/copayBundle.js -js/config.js +config.js diff --git a/README.md b/README.md index d7b8db5cf..2e7ea10b4 100644 --- a/README.md +++ b/README.md @@ -1 +1,17 @@ Copay +===== + +Installation: + +Copy config.template.js to config.js and edit to suit your needs. (Defaults to +public PeerJS and Insight servers) + +Then execute these commands: + +``` +npm install +bower install +grunt --target=dev shell +``` + +Then open index.html in your browser. diff --git a/js/config.template.js b/config.template.js similarity index 100% rename from js/config.template.js rename to config.template.js diff --git a/index.html b/index.html index b9f10e7ce..63039e996 100644 --- a/index.html +++ b/index.html @@ -392,6 +392,8 @@ missing

go back...

+ + @@ -406,7 +408,6 @@ missing - From 49dbbe8fa92f1dbff99f9fe85810e9b32e77937d Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Sun, 20 Apr 2014 16:46:03 -0300 Subject: [PATCH 3/5] add simplest possible express server to host files ...this is much better for development, so you can run many different servers that have different HTML 5 local storages for testing purposes. --- README.md | 16 ++++++++++++++-- app.js | 12 ++++++++++++ package.json | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 app.js diff --git a/README.md b/README.md index 2e7ea10b4..5b68e1dcd 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,23 @@ Copy config.template.js to config.js and edit to suit your needs. (Defaults to public PeerJS and Insight servers) Then execute these commands: - ``` npm install bower install grunt --target=dev shell +node app.js ``` -Then open index.html in your browser. +To run on a different port: +``` +PORT=3001 node app.js +``` + +To open up five different instances to test 3-of-5 multisig with yourself, then run this in 5 different terminals: +``` +PORT=3001 node app.js +PORT=3002 node app.js +PORT=3003 node app.js +PORT=3004 node app.js +PORT=3005 node app.js +``` diff --git a/app.js b/app.js new file mode 100644 index 000000000..543f33e01 --- /dev/null +++ b/app.js @@ -0,0 +1,12 @@ +var express=require("express"); +var http=require("http"); + +var app=express(); + +var port = process.env.PORT || 3000; +app.set("port", port); +app.use(express.static(__dirname)); + +app.listen(port, function(){ + console.log("Listening at: http://localhost:" + port); +}); diff --git a/package.json b/package.json index 99b94e0ee..3e3eb6eb7 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ }, "homepage": "https://github.com/bitpay/copay", "devDependencies": { + "express": "4.0.0", "grunt-contrib-watch": "~0.5.3", "grunt-mocha-test": "~0.8.2", "grunt-shell": "~0.6.4", From fe0cccd8019418d9e0b739859bd13ec887bb18d0 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sun, 20 Apr 2014 17:16:21 -0300 Subject: [PATCH 4/5] better sync for peers --- js/controllers/signin.js | 2 -- js/models/core/PrivateKey.js | 2 ++ js/models/core/Wallet.js | 7 +++++-- js/services/controllerUtils.js | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/js/controllers/signin.js b/js/controllers/signin.js index ac079ca29..3558762a9 100644 --- a/js/controllers/signin.js +++ b/js/controllers/signin.js @@ -20,7 +20,6 @@ angular.module('copay.signin').controller('SigninController', console.log('[signin.js.23:walletId:]',walletId); //TODO var w = walletFactory.open(walletId, opts); controllerUtils.setupUxHandlers(w); - w.netStart(); }; $scope.join = function(secret) { @@ -34,7 +33,6 @@ console.log('[signin.js.23:walletId:]',walletId); //TODO walletFactory.joinCreateSession(secret, function(w) { console.log('[signin.js.33] joinCreateSession RETURN', w); //TODO controllerUtils.setupUxHandlers(w); - w.setupNetHandlers(); }); }; diff --git a/js/models/core/PrivateKey.js b/js/models/core/PrivateKey.js index bf8cfa9de..66102e8db 100644 --- a/js/models/core/PrivateKey.js +++ b/js/models/core/PrivateKey.js @@ -32,6 +32,8 @@ PrivateKey.fromObj = function(obj) { }; PrivateKey.prototype.toObj = function() { + +console.log('[PrivateKey.js.35] TODO TODO: PRIV: ', this.getExtendedPrivateKeyString()); //TODO return { extendedPrivateKeyString: this.getExtendedPrivateKeyString(), networkName: this.network.name, diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 881d55589..7b0efd813 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -106,9 +106,11 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) { } this.log('[Wallet.js.98]' , data.type); //TODO switch(data.type) { + // This handler is repeaded on WalletFactory (#join). TODO + case 'walletId': + this.sendWalletReady(senderId); + break; case 'walletReady': - -console.log('[Wallet.js.109] RECV WALLETREADY'); //TODO this.sendPublicKeyRing(senderId); this.sendTxProposals(senderId); break; @@ -189,6 +191,7 @@ console.log('[Wallet.js.177] NET START: emit CREATED'); //TODO if (otherPeerId !== myPeerId) { net.connectTo(otherPeerId); } + self.emit('refresh'); } }, startOpts); }; diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index 371e367ae..80d0f6c5c 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -34,7 +34,6 @@ console.log('[controllerUtils.js.30:created:] RECV '); //TODO $rootScope.wallet.getBalance(function(balance) { $rootScope.totalBalance = balance; - $rootScope.$digest(); }); }); w.on('refresh', function() { @@ -43,6 +42,8 @@ console.log('[controllerUtils.js.30:created:] RECV '); //TODO }); w.on('openError', root.onErrorDigest); w.on('close', root.onErrorDigest); + +console.log('[controllerUtils.js.45] CALLING NETSTART FROM setupUxHandlers'); //TODO w.netStart(); console.log('[controllerUtils.js.45] setupUxHandlers END'); //TODO }; From ef88951cf60be8d2b84aa4e1e1a6e4465db7bba5 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Sun, 20 Apr 2014 17:26:54 -0300 Subject: [PATCH 5/5] fix typos ... add space for formatting clarity --- index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 63039e996..d38963011 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@
-
Wallet ID:{{$root.wallet.id}}
+
Wallet ID: {{$root.wallet.id}}

{{totalBalance}} BTC

0 BTC

@@ -271,7 +271,7 @@ missing

Address 1 1231 BTC

-

Adress 2 1231 BTC

+

Address 2 1231 BTC

@@ -281,7 +281,7 @@ missing

Address 1 1231 BTC

-

Adress 2 1231 BTC

+

Address 2 1231 BTC

@@ -291,7 +291,7 @@ missing

Address 1 1231 BTC

-

Adress 2 1231 BTC

+

Address 2 1231 BTC