basic stuff working
This commit is contained in:
parent
48dd8549ef
commit
4f359c05ca
2 changed files with 11 additions and 73 deletions
73
config.js
73
config.js
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
var defaultConfig = {
|
var defaultConfig = {
|
||||||
// DEFAULT network (livenet or testnet)
|
// DEFAULT network (livenet or testnet)
|
||||||
networkName: 'livenet',
|
networkName: 'testnet',
|
||||||
forceNetwork: false,
|
forceNetwork: false,
|
||||||
|
|
||||||
// DEFAULT unit: Bit
|
// DEFAULT unit: Bit
|
||||||
|
|
@ -15,71 +15,10 @@ var defaultConfig = {
|
||||||
minAmountSatoshi: 5400,
|
minAmountSatoshi: 5400,
|
||||||
},
|
},
|
||||||
|
|
||||||
// network layer (PeerJS) config
|
// network layer config
|
||||||
network: {
|
network: {
|
||||||
// Use this to run your own local PeerJS server
|
host: 'localhost',
|
||||||
// with params: ./peerjs -p 10009 -k '6d6d751ea61e26f2'
|
port: 3001
|
||||||
/*
|
|
||||||
key: '6d6d751ea61e26f2',
|
|
||||||
host: 'localhost',
|
|
||||||
port: 10009,
|
|
||||||
path: '/',
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Use this to connect to bitpay's PeerJS server
|
|
||||||
key: 'satoshirocks',
|
|
||||||
// host: '162.242.219.26',
|
|
||||||
// port: 10000,
|
|
||||||
// secure: false,
|
|
||||||
host: 'live.copay.io',
|
|
||||||
port: 9000,
|
|
||||||
secure: true,
|
|
||||||
path: '/',
|
|
||||||
|
|
||||||
// other PeerJS config
|
|
||||||
maxPeers: 15,
|
|
||||||
debug: 2,
|
|
||||||
|
|
||||||
// PeerJS internal config object
|
|
||||||
config: {
|
|
||||||
'iceServers': [
|
|
||||||
// Pass in STUN and TURN servers for maximum network compatibility
|
|
||||||
{
|
|
||||||
url: 'stun:162.242.219.26'
|
|
||||||
}, {
|
|
||||||
url: 'turn:162.242.219.26',
|
|
||||||
username: 'bitcore',
|
|
||||||
credential: 'bitcore',
|
|
||||||
}
|
|
||||||
// {
|
|
||||||
// url: 'stun:stun.l.google.com:19302'
|
|
||||||
// }, {
|
|
||||||
// url: 'stun:stun1.l.google.com:19302'
|
|
||||||
// }, {
|
|
||||||
// url: 'stun:stun2.l.google.com:19302'
|
|
||||||
// }, {
|
|
||||||
// url: 'stun:stun3.l.google.com:19302'
|
|
||||||
// }, {
|
|
||||||
// url: 'stun:stun4.l.google.com:19302'
|
|
||||||
// }, {
|
|
||||||
// url: 'stun:stunserver.org'
|
|
||||||
// }
|
|
||||||
// // Options fot TURN servers with p2p communications are not possible.
|
|
||||||
// {
|
|
||||||
// url: 'turn:numb.viagenie.ca',
|
|
||||||
// credential: 'muazkh',
|
|
||||||
// username: 'webrtc@live.com'
|
|
||||||
// }, {
|
|
||||||
// url: 'turn:192.158.29.39:3478?transport=udp',
|
|
||||||
// credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
|
|
||||||
// username: '28224511:1379330808'
|
|
||||||
// }, {
|
|
||||||
// url: 'turn:192.158.29.39:3478?transport=tcp',
|
|
||||||
// credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
|
|
||||||
// username: '28224511:1379330808'
|
|
||||||
// }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// wallet default config
|
// wallet default config
|
||||||
|
|
@ -96,14 +35,14 @@ path: '/',
|
||||||
// blockchain service API config
|
// blockchain service API config
|
||||||
blockchain: {
|
blockchain: {
|
||||||
schema: 'https',
|
schema: 'https',
|
||||||
host: 'insight.bitpay.com',
|
host: 'test-insight.bitpay.com',
|
||||||
port: 443,
|
port: 443,
|
||||||
retryDelay: 1000,
|
retryDelay: 1000,
|
||||||
},
|
},
|
||||||
// socket service API config
|
// socket service API config
|
||||||
socket: {
|
socket: {
|
||||||
schema: 'https',
|
schema: 'https',
|
||||||
host: 'insight.bitpay.com',
|
host: 'test-insight.bitpay.com',
|
||||||
port: 443,
|
port: 443,
|
||||||
reconnectDelay: 1000,
|
reconnectDelay: 1000,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -240,16 +240,14 @@ Network.prototype._checkAnyPeer = function(msg) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype._setupConnectionHandlers = function(toCopayerId) {
|
Network.prototype._setupConnectionHandlers = function() {
|
||||||
preconditions.checkState(this.socket);
|
preconditions.checkState(this.socket);
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var isInbound = toCopayerId ? false : true;
|
|
||||||
|
|
||||||
self.socket.on('connect', function() {
|
self.socket.on('connect', function() {
|
||||||
console.log('CONNECTED!');
|
alert('CONNECTED!');
|
||||||
self.socket.on('disconnect', function() {
|
self.socket.on('disconnect', function() {
|
||||||
console.log('DISCONNECTED');
|
alert('DISCONNECTED');
|
||||||
self.cleanUp();
|
self.cleanUp();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -297,6 +295,7 @@ Network.prototype.peerFromCopayer = function(hex) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.start = function(opts, openCallback) {
|
Network.prototype.start = function(opts, openCallback) {
|
||||||
|
alert('start');
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
if (this.started) return openCallback();
|
if (this.started) return openCallback();
|
||||||
|
|
@ -324,7 +323,7 @@ Network.prototype.start = function(opts, openCallback) {
|
||||||
this.socket.emit('subscribe', this.getKey().public.toString('hex'));
|
this.socket.emit('subscribe', this.getKey().public.toString('hex'));
|
||||||
this.socket.emit('sync');
|
this.socket.emit('sync');
|
||||||
this.started = true;
|
this.started = true;
|
||||||
this._setupConnectionHandlers(this.socket);
|
this._setupConnectionHandlers();
|
||||||
|
|
||||||
//this.emit('serverError', self.criticalError);
|
//this.emit('serverError', self.criticalError);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue