Permalink
Browse files

Merge branch 'master' of github.com:janoside/btc-rpc-explorer

  • Loading branch information...
janoside committed Nov 16, 2018
2 parents 5ef702b + bc04463 commit dd9e40ef28adf9cbcb24fd977301c3105e505367
Showing with 9 additions and 4 deletions.
  1. +6 −3 app/api/electrumApi.js
  2. +3 −1 app/config.js
@@ -13,7 +13,8 @@ function connectToServers() {
var promises = [];
for (var i = 0; i < config.electrumXServers.length; i++) {
promises.push(connectToServer(config.electrumXServers[i].host, config.electrumXServers[i].port));
var { host, port, protocol } = config.electrumXServers[i];
promises.push(connectToServer(host, port, protocol));
}
Promise.all(promises).then(function() {
@@ -48,11 +49,13 @@ function reconnectToServers() {
});
}
function connectToServer(host, port) {
function connectToServer(host, port, protocol) {
return new Promise(function(resolve, reject) {
console.log("Connecting to ElectrumX Server: " + host + ":" + port);
var electrumClient = new ElectrumClient(port, host, 'tls');
// default protocol is 'tcp' if port is 50001, which is the default unencrypted port for electrumx
var defaultProtocol = port === 50001 ? 'tcp' : 'tls';
var electrumClient = new ElectrumClient(port, host, protocol || defaultProtocol);
electrumClient.initElectrum({client:"btc-rpc-explorer-v1.1", version:"1.2"}).then(function(res) {
console.log("Connected to ElectrumX Server: " + host + ":" + port + ", versions: " + res);
@@ -74,7 +74,9 @@ module.exports = {
// https://uasf.saltylemon.org/electrum
electrumXServers:[
// {host: "electrum.example.com", port:50002}, ...
// set host & port of electrum servers to connect to
// protocol can be "tls" or "tcp", it defaults to "tcp" if port is 50001 and "tls" otherwise
// {host: "electrum.example.com", port:50002, protocol: "tls"}, ...
],
site: {

0 comments on commit dd9e40e

Please sign in to comment.