made some adjustments to copay for copay shell integration
This commit is contained in:
parent
40f8db0e91
commit
cd66a12ed3
8 changed files with 161 additions and 102 deletions
24
README.md
24
README.md
|
|
@ -26,23 +26,23 @@ cp config.template.js config.js
|
|||
|
||||
Open Copay:
|
||||
```
|
||||
node app.js
|
||||
npm start
|
||||
```
|
||||
|
||||
Then visit localhost:3000 in your browser.
|
||||
|
||||
To run on a different port:
|
||||
```
|
||||
PORT=3001 node app.js
|
||||
PORT=3001 npm start
|
||||
```
|
||||
|
||||
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
|
||||
PORT=3001 npm start
|
||||
PORT=3002 npm start
|
||||
PORT=3003 npm start
|
||||
PORT=3004 npm start
|
||||
PORT=3005 npm start
|
||||
```
|
||||
|
||||
To open n different instances just run:
|
||||
|
|
@ -135,13 +135,3 @@ Peer Authentication
|
|||
It is important to note that - except for private keys - *all data* in the wallet is shared with *all members of the wallet*.
|
||||
Private keys are never shared with anyone and are never sent over the network. There are no *private* messages between
|
||||
individual members of the wallet. All members of a wallet see everything that happens in that wallet.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
21
app.js
21
app.js
|
|
@ -1,12 +1,15 @@
|
|||
var express=require("express");
|
||||
var http=require("http");
|
||||
var express = require('express');
|
||||
var http = require('http');
|
||||
var app = express();
|
||||
|
||||
var app=express();
|
||||
app.start = function(port, callback) {
|
||||
|
||||
var port = process.env.PORT || 3000;
|
||||
app.set("port", port);
|
||||
app.use(express.static(__dirname));
|
||||
app.set('port', port);
|
||||
app.use(express.static(__dirname));
|
||||
|
||||
app.listen(port, function(){
|
||||
console.log("Listening at: http://localhost:" + port);
|
||||
});
|
||||
app.listen(port, function() {
|
||||
callback('http://localhost:' + port);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = app;
|
||||
|
|
|
|||
|
|
@ -726,7 +726,7 @@ on supported browsers please check <a href="http://www.webrtc.org/">http://www.w
|
|||
</script>
|
||||
|
||||
<script src="config.js"></script>
|
||||
|
||||
<script src="js/shell.js"></script>
|
||||
<script src="lib/angular/angular.min.js"></script>
|
||||
<script src="lib/moment/moment.js"></script>
|
||||
<script src="lib/angular-moment/angular-moment.js"></script>
|
||||
|
|
|
|||
|
|
@ -59,4 +59,3 @@ angular.module('copay.video', []);
|
|||
angular.module('copay.import', []);
|
||||
angular.module('copay.passphrase', []);
|
||||
angular.module('copay.settings', []);
|
||||
|
||||
|
|
|
|||
60
js/shell.js
Normal file
60
js/shell.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
** copay-shell integration
|
||||
*/
|
||||
(function() {
|
||||
/*
|
||||
** This is a monkey patch for when Copay is running from
|
||||
** within Copay-Shell (atom-shell). Since the renderer (the frontend)
|
||||
** receives context from Node.js, we get a `module.exports` contruct
|
||||
** available to us. Because of this, some libs (specifically Moment.js)
|
||||
** attempt to assume their CommonJS form and bind to this. This causes
|
||||
** there to be no references in the window to these libs, so let's trick
|
||||
** the renderer into thinking that we are _not_ in a CommonJS environment.
|
||||
*/
|
||||
if (typeof module !== 'undefined') module = { exports: null };
|
||||
|
||||
// are we running in copay shell?
|
||||
if (process && process.type === 'renderer') initCopayShellBindings();
|
||||
|
||||
function controller(name) {
|
||||
return angular.element(
|
||||
document.querySelectorAll(
|
||||
'[ng-controller="' + name + '"], [data-ng-controller="' + name + '"]'
|
||||
)
|
||||
).scope();
|
||||
};
|
||||
|
||||
function initCopayShellBindings() {
|
||||
|
||||
var ipc = require('ipc');
|
||||
|
||||
ipc.on('address:create', function(data) {
|
||||
location.href = '#/addresses';
|
||||
controller('AddressesController').newAddr();
|
||||
});
|
||||
|
||||
ipc.on('transactions:send', function(data) {
|
||||
location.href = '#/send';
|
||||
});
|
||||
|
||||
ipc.on('transactions:all', function(data) {
|
||||
location.href = '#/transactions';
|
||||
controller('TransactionsController').show();
|
||||
});
|
||||
|
||||
ipc.on('transactions:pending', function(data) {
|
||||
location.href = '#/transactions';
|
||||
controller('TransactionsController').show(true);
|
||||
});
|
||||
|
||||
ipc.on('backup:download', function(data) {
|
||||
|
||||
});
|
||||
|
||||
ipc.on('backup:email', function(data) {
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
@ -26,7 +26,6 @@ var DEFAULT_PORT = process.env.DEFAULT_PORT || 3000;
|
|||
for (var i=0; i<N; i++) {
|
||||
var port =(i+DEFAULT_PORT);
|
||||
console.log('Simulating copayer #'+(i+1)+' at http://localhost:'+port);
|
||||
var command = 'PORT='+port+' node app.js &'
|
||||
var command = 'PORT='+port+' npm start &'
|
||||
exec(command, puts);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@
|
|||
"bugs": {
|
||||
"url": "https://github.com/bitpay/copay/issues"
|
||||
},
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"test": "mocha"
|
||||
},
|
||||
"homepage": "https://github.com/bitpay/copay",
|
||||
|
|
|
|||
6
server.js
Normal file
6
server.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
var server = require('./app');
|
||||
var port = process.env.PORT || 3000;
|
||||
|
||||
server.start(port, function(loc){
|
||||
console.log('Listening at: ' + loc);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue