mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #772 from matiu/feature/defaultsToSSLandLivenet
SSL and livenet config by default
This commit is contained in:
commit
1af298b5f1
12
config.js
12
config.js
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
var defaultConfig = {
|
||||
// DEFAULT network (livenet or testnet)
|
||||
networkName: 'testnet',
|
||||
networkName: 'livenet',
|
||||
|
||||
// DEFAULT unit: Bit
|
||||
unitName: 'bits',
|
||||
|
@ -96,14 +96,16 @@ var defaultConfig = {
|
|||
|
||||
// blockchain service API config
|
||||
blockchain: {
|
||||
host: 'test.insight.is',
|
||||
port: 80,
|
||||
schema: 'https',
|
||||
host: 'insight.bitpay.com',
|
||||
port: 443,
|
||||
retryDelay: 1000,
|
||||
},
|
||||
// socket service API config
|
||||
socket: {
|
||||
host: 'test.insight.is',
|
||||
port: 80,
|
||||
schema: 'https',
|
||||
host: 'insight.bitpay.com',
|
||||
port: 443,
|
||||
// will duplicate itself after each try
|
||||
reconnectDelay: 500,
|
||||
},
|
||||
|
|
|
@ -849,6 +849,9 @@
|
|||
<input type="text" ng-model="insightHost" class="form-control" name="insight-host">
|
||||
<label for="insight-port">Port</label>
|
||||
<input type="number" ng-model="insightPort" class="form-control" name="insight-port">
|
||||
<input id="insight-secure" type="checkbox" ng-model="insightSecure" class="form-control">
|
||||
<label for="insight-secure">Use SSL</label>
|
||||
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>PeerJS server</legend>
|
||||
|
|
|
@ -7,6 +7,7 @@ angular.module('copayApp.controllers').controller('SettingsController',
|
|||
$scope.networkName = config.networkName;
|
||||
$scope.insightHost = config.blockchain.host;
|
||||
$scope.insightPort = config.blockchain.port;
|
||||
$scope.insightSecure = config.blockchain.schema === 'https';
|
||||
$scope.networkKey = config.network.key;
|
||||
$scope.networkHost = config.network.host;
|
||||
$scope.networkPort = config.network.port;
|
||||
|
@ -39,9 +40,15 @@ angular.module('copayApp.controllers').controller('SettingsController',
|
|||
}
|
||||
|
||||
$scope.$watch('networkName', function(net) {
|
||||
$scope.insightHost = net === 'testnet' ? 'test.insight.is' : 'live.insight.is';
|
||||
$scope.insightHost = net === 'testnet' ? 'test-insight.bitpay.com' : 'insight.bitpay.com';
|
||||
});
|
||||
|
||||
|
||||
$scope.$watch('insightSecure', function(ssl) {
|
||||
$scope.insightPort = ssl ? 443 : 80;
|
||||
});
|
||||
|
||||
|
||||
$scope.save = function() {
|
||||
var network = config.network;
|
||||
network.key = $scope.networkKey;
|
||||
|
@ -53,11 +60,13 @@ angular.module('copayApp.controllers').controller('SettingsController',
|
|||
networkName: $scope.networkName,
|
||||
blockchain: {
|
||||
host: $scope.insightHost,
|
||||
port: $scope.insightPort
|
||||
port: $scope.insightPort,
|
||||
schema: $scope.insightSecure ? 'https' : 'http',
|
||||
},
|
||||
socket: {
|
||||
host: $scope.insightHost,
|
||||
port: $scope.insightPort
|
||||
port: $scope.insightPort,
|
||||
schema: $scope.insightSecure ? 'https' : 'http',
|
||||
},
|
||||
network: network,
|
||||
disableVideo: $scope.disableVideo,
|
||||
|
|
|
@ -12,7 +12,7 @@ function Insight(opts) {
|
|||
opts = opts || {};
|
||||
this.host = opts.host || 'localhost';
|
||||
this.port = opts.port || '3001';
|
||||
this.scheme = opts.scheme || 'http';
|
||||
this.schema = opts.schema || 'http';
|
||||
this.retryDelay = opts.retryDelay || 5000;
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,21 @@ function removeRepeatedElements(ar) {
|
|||
return r;
|
||||
}
|
||||
|
||||
|
||||
Insight.prototype._getOptions = function(method, path, data) {
|
||||
return {
|
||||
host: this.host,
|
||||
port: this.port,
|
||||
schema: this.schema,
|
||||
method: method,
|
||||
path: path,
|
||||
data: data,
|
||||
headers: {
|
||||
'Access-Control-Request-Headers': ''
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Insight.prototype.getTransactions = function(addresses, cb) {
|
||||
var self = this;
|
||||
|
||||
|
@ -71,17 +86,7 @@ Insight.prototype.getTransactions = function(addresses, cb) {
|
|||
var txs = [];
|
||||
|
||||
_asyncForEach(addresses, function(addr, callback) {
|
||||
var options = {
|
||||
host: self.host,
|
||||
port: self.port,
|
||||
scheme: self.scheme,
|
||||
method: 'GET',
|
||||
path: '/api/addr/' + addr,
|
||||
headers: {
|
||||
'Access-Control-Request-Headers': ''
|
||||
}
|
||||
};
|
||||
|
||||
var options = self._getOptions('GET', '/api/addr/' + addr);
|
||||
self._request(options, function(err, res) {
|
||||
var txids_tmp = res.transactions;
|
||||
for (var i = 0; i < txids_tmp.length; i++) {
|
||||
|
@ -92,16 +97,7 @@ Insight.prototype.getTransactions = function(addresses, cb) {
|
|||
}, function() {
|
||||
var clean_txids = removeRepeatedElements(txids);
|
||||
_asyncForEach(clean_txids, function(txid, callback2) {
|
||||
var options = {
|
||||
host: self.host,
|
||||
port: self.port,
|
||||
scheme: self.scheme,
|
||||
method: 'GET',
|
||||
path: '/api/tx/' + txid,
|
||||
headers: {
|
||||
'Access-Control-Request-Headers': ''
|
||||
}
|
||||
};
|
||||
var options = self._getOptions('GET', '/api/tx/' + txid);
|
||||
self._request(options, function(err, res) {
|
||||
txs.push(res);
|
||||
callback2();
|
||||
|
@ -117,17 +113,7 @@ Insight.prototype.getUnspent = function(addresses, cb) {
|
|||
|
||||
var all = [];
|
||||
|
||||
var options = {
|
||||
host: this.host,
|
||||
port: this.port,
|
||||
scheme: this.scheme,
|
||||
method: 'POST',
|
||||
data: 'addrs=' + addresses.join(','),
|
||||
path: '/api/addrs/utxo',
|
||||
headers: {
|
||||
'Access-Control-Request-Headers': ''
|
||||
}
|
||||
};
|
||||
var options = this._getOptions('POST', '/api/addrs/utxo', 'addrs=' + addresses.join(','));
|
||||
|
||||
var self = this;
|
||||
this._request(options, function(err, res) {
|
||||
|
@ -146,16 +132,7 @@ Insight.prototype.getUnspent = function(addresses, cb) {
|
|||
Insight.prototype.sendRawTransaction = function(rawtx, cb) {
|
||||
if (!rawtx) throw new Error('rawtx must be set');
|
||||
|
||||
var options = {
|
||||
host: this.host,
|
||||
port: this.port,
|
||||
method: 'POST',
|
||||
path: '/api/tx/send',
|
||||
data: 'rawtx=' + rawtx,
|
||||
headers: {
|
||||
'Access-Control-Request-Headers': ''
|
||||
}
|
||||
};
|
||||
var options = this._getOptions('POST', '/api/tx/send', 'rawtx=' + rawtx);
|
||||
this._request(options, function(err, res) {
|
||||
if (err) return cb();
|
||||
|
||||
|
@ -244,9 +221,7 @@ Insight.prototype._requestNode = function(options, callback) {
|
|||
|
||||
Insight.prototype._requestBrowser = function(options, callback) {
|
||||
var request = new XMLHttpRequest();
|
||||
|
||||
// TODO: Normalize URL
|
||||
var url = 'http://' + options.host;
|
||||
var url = (options.schema || 'http') + '://' + options.host;
|
||||
|
||||
if (options.port !== 80) {
|
||||
url = url + ':' + options.port;
|
||||
|
|
|
@ -3,11 +3,14 @@
|
|||
angular.module('copayApp.services').factory('Socket',
|
||||
function($rootScope) {
|
||||
var listeners = [];
|
||||
var url = 'http://' + config.socket.host + ':' + config.socket.port;
|
||||
var socket = io(url, {
|
||||
var url = (config.socket.schema || 'http') + '://' + config.socket.host + ':' + config.socket.port;
|
||||
var opts = {
|
||||
'reconnection': true,
|
||||
'reconnectionDelay': config.socket.reconnectDelay || 500,
|
||||
});
|
||||
'secure': config.socket.schema === 'https' ? true : false,
|
||||
};
|
||||
|
||||
var socket = io(url, opts);
|
||||
|
||||
return {
|
||||
on: function(event, callback) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "copay",
|
||||
"version": "0.1.1",
|
||||
"version": "0.2.0",
|
||||
"description": "A multisignature wallet",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
Loading…
Reference in New Issue