Skip to content

Commit

Permalink
Add ElectrumX server settings
Browse files Browse the repository at this point in the history
  • Loading branch information
QuickMythril committed Feb 7, 2024
1 parent 9e001df commit 821046d
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 6 deletions.
33 changes: 32 additions & 1 deletion src/main/java/org/qortal/crosschain/Bitcoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import org.qortal.crosschain.ChainableServer.ConnectionType;
import org.qortal.settings.Settings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;

public class Bitcoin extends Bitcoiny {
Expand Down Expand Up @@ -43,7 +45,7 @@ public NetworkParameters getParams() {

@Override
public Collection<ElectrumX.Server> getServers() {
return Arrays.asList(
List<ElectrumX.Server> defaultServers = Arrays.asList(
// Servers chosen on NO BASIS WHATSOEVER from various sources!
// Status verified at https://1209k.com/bitcoin-eye/ele.php?chain=btc
new Server("104.198.149.61", Server.ConnectionType.SSL, 50002),
Expand Down Expand Up @@ -104,6 +106,35 @@ public Collection<ElectrumX.Server> getServers() {
new Server("vmd63185.contaboserver.net", Server.ConnectionType.SSL, 50002),
new Server("xtrum.com", Server.ConnectionType.SSL, 50002)
);

List<ElectrumX.Server> availableServers = new ArrayList<>();
Boolean useDefault = Settings.getInstance().getUseBitcoinDefaults();
if (useDefault == true) {
availableServers.addAll(defaultServers);
}

String[] settingsList = Settings.getInstance().getBitcoinServers();
if (settingsList != null) {
List<ElectrumX.Server> customServers = new ArrayList<>();
for (String setting : settingsList) {
String[] colonParts = setting.split(":");
if (colonParts.length == 2) {
String[] commaParts = colonParts[1].split(",");
if (commaParts.length == 2) {
String hostname = colonParts[0];
int port = Integer.parseInt(commaParts[0].trim());
String typeString = commaParts[1].trim().toUpperCase();
Server.ConnectionType type = Server.ConnectionType.SSL;
if (typeString.equals("TCP")) {
type = Server.ConnectionType.TCP;
}
customServers.add(new Server(hostname, type, port));
}
}
}
availableServers.addAll(customServers);
}
return availableServers;
}

@Override
Expand Down
33 changes: 32 additions & 1 deletion src/main/java/org/qortal/crosschain/Digibyte.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import org.qortal.crosschain.ChainableServer.ConnectionType;
import org.qortal.settings.Settings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;

public class Digibyte extends Bitcoiny {
Expand Down Expand Up @@ -42,14 +44,43 @@ public NetworkParameters getParams() {

@Override
public Collection<Server> getServers() {
return Arrays.asList(
List<ElectrumX.Server> defaultServers = Arrays.asList(
// Servers chosen on NO BASIS WHATSOEVER from various sources!
// Status verified at https://1209k.com/bitcoin-eye/ele.php?chain=dgb
new Server("electrum.qortal.link", Server.ConnectionType.SSL, 55002),
new Server("electrum1.cipig.net", Server.ConnectionType.SSL, 20059),
new Server("electrum2.cipig.net", Server.ConnectionType.SSL, 20059),
new Server("electrum3.cipig.net", Server.ConnectionType.SSL, 20059)
);

List<ElectrumX.Server> availableServers = new ArrayList<>();
Boolean useDefault = Settings.getInstance().getUseDigibyteDefaults();
if (useDefault == true) {
availableServers.addAll(defaultServers);
}

String[] settingsList = Settings.getInstance().getDigibyteServers();
if (settingsList != null) {
List<ElectrumX.Server> customServers = new ArrayList<>();
for (String setting : settingsList) {
String[] colonParts = setting.split(":");
if (colonParts.length == 2) {
String[] commaParts = colonParts[1].split(",");
if (commaParts.length == 2) {
String hostname = colonParts[0];
int port = Integer.parseInt(commaParts[0].trim());
String typeString = commaParts[1].trim().toUpperCase();
Server.ConnectionType type = Server.ConnectionType.SSL;
if (typeString.equals("TCP")) {
type = Server.ConnectionType.TCP;
}
customServers.add(new Server(hostname, type, port));
}
}
}
availableServers.addAll(customServers);
}
return availableServers;
}

@Override
Expand Down
33 changes: 32 additions & 1 deletion src/main/java/org/qortal/crosschain/Dogecoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import org.qortal.crosschain.ChainableServer.ConnectionType;
import org.qortal.settings.Settings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;

public class Dogecoin extends Bitcoiny {
Expand Down Expand Up @@ -42,7 +44,7 @@ public NetworkParameters getParams() {

@Override
public Collection<Server> getServers() {
return Arrays.asList(
List<ElectrumX.Server> defaultServers = Arrays.asList(
// Servers chosen on NO BASIS WHATSOEVER from various sources!
// Status verified at https://1209k.com/bitcoin-eye/ele.php?chain=doge
new Server("dogecoin.stackwallet.com", Server.ConnectionType.SSL, 50022),
Expand All @@ -51,6 +53,35 @@ public Collection<Server> getServers() {
new Server("electrum2.cipig.net", Server.ConnectionType.SSL, 20060),
new Server("electrum3.cipig.net", Server.ConnectionType.SSL, 20060)
);

List<ElectrumX.Server> availableServers = new ArrayList<>();
Boolean useDefault = Settings.getInstance().getUseDogecoinDefaults();
if (useDefault == true) {
availableServers.addAll(defaultServers);
}

String[] settingsList = Settings.getInstance().getDogecoinServers();
if (settingsList != null) {
List<ElectrumX.Server> customServers = new ArrayList<>();
for (String setting : settingsList) {
String[] colonParts = setting.split(":");
if (colonParts.length == 2) {
String[] commaParts = colonParts[1].split(",");
if (commaParts.length == 2) {
String hostname = colonParts[0];
int port = Integer.parseInt(commaParts[0].trim());
String typeString = commaParts[1].trim().toUpperCase();
Server.ConnectionType type = Server.ConnectionType.SSL;
if (typeString.equals("TCP")) {
type = Server.ConnectionType.TCP;
}
customServers.add(new Server(hostname, type, port));
}
}
}
availableServers.addAll(customServers);
}
return availableServers;
}

@Override
Expand Down
33 changes: 32 additions & 1 deletion src/main/java/org/qortal/crosschain/Litecoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import org.qortal.crosschain.ChainableServer.ConnectionType;
import org.qortal.settings.Settings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;

public class Litecoin extends Bitcoiny {
Expand Down Expand Up @@ -42,7 +44,7 @@ public NetworkParameters getParams() {

@Override
public Collection<ElectrumX.Server> getServers() {
return Arrays.asList(
List<ElectrumX.Server> defaultServers = Arrays.asList(
// Servers chosen on NO BASIS WHATSOEVER from various sources!
// Status verified at https://1209k.com/bitcoin-eye/ele.php?chain=ltc
new Server("backup.electrum-ltc.org", Server.ConnectionType.SSL, 443),
Expand All @@ -54,6 +56,35 @@ public Collection<ElectrumX.Server> getServers() {
new Server("electrum3.cipig.net", Server.ConnectionType.SSL, 20063),
new Server("ltc.rentonrisk.com", Server.ConnectionType.SSL, 50002)
);

List<ElectrumX.Server> availableServers = new ArrayList<>();
Boolean useDefault = Settings.getInstance().getUseLitecoinDefaults();
if (useDefault == true) {
availableServers.addAll(defaultServers);
}

String[] settingsList = Settings.getInstance().getLitecoinServers();
if (settingsList != null) {
List<ElectrumX.Server> customServers = new ArrayList<>();
for (String setting : settingsList) {
String[] colonParts = setting.split(":");
if (colonParts.length == 2) {
String[] commaParts = colonParts[1].split(",");
if (commaParts.length == 2) {
String hostname = colonParts[0];
int port = Integer.parseInt(commaParts[0].trim());
String typeString = commaParts[1].trim().toUpperCase();
Server.ConnectionType type = Server.ConnectionType.SSL;
if (typeString.equals("TCP")) {
type = Server.ConnectionType.TCP;
}
customServers.add(new Server(hostname, type, port));
}
}
}
availableServers.addAll(customServers);
}
return availableServers;
}

@Override
Expand Down
31 changes: 30 additions & 1 deletion src/main/java/org/qortal/crosschain/PirateChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,39 @@ public NetworkParameters getParams() {

@Override
public Collection<Server> getServers() {
return Arrays.asList(
List<Server> defaultServers = Arrays.asList(
// Servers chosen on NO BASIS WHATSOEVER from various sources!
new Server("lightd.pirate.black", Server.ConnectionType.SSL, 443)
);

List<Server> availableServers = new ArrayList<>();
Boolean useDefault = Settings.getInstance().getUsePirateChainDefaults();
if (useDefault == true) {
availableServers.addAll(defaultServers);
}

String[] settingsList = Settings.getInstance().getPirateChainServers();
if (settingsList != null) {
List<Server> customServers = new ArrayList<>();
for (String setting : settingsList) {
String[] colonParts = setting.split(":");
if (colonParts.length == 2) {
String[] commaParts = colonParts[1].split(",");
if (commaParts.length == 2) {
String hostname = colonParts[0];
int port = Integer.parseInt(commaParts[0].trim());
String typeString = commaParts[1].trim().toUpperCase();
Server.ConnectionType type = Server.ConnectionType.SSL;
if (typeString.equals("TCP")) {
type = Server.ConnectionType.TCP;
}
customServers.add(new Server(hostname, type, port));
}
}
}
availableServers.addAll(customServers);
}
return availableServers;
}

@Override
Expand Down
33 changes: 32 additions & 1 deletion src/main/java/org/qortal/crosschain/Ravencoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import org.qortal.crosschain.ChainableServer.ConnectionType;
import org.qortal.settings.Settings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;

public class Ravencoin extends Bitcoiny {
Expand Down Expand Up @@ -42,7 +44,7 @@ public NetworkParameters getParams() {

@Override
public Collection<Server> getServers() {
return Arrays.asList(
List<ElectrumX.Server> defaultServers = Arrays.asList(
// Servers chosen on NO BASIS WHATSOEVER from various sources!
// Status verified at https://1209k.com/bitcoin-eye/ele.php?chain=rvn
new Server("electrum.qortal.link", Server.ConnectionType.SSL, 56002),
Expand All @@ -52,6 +54,35 @@ public Collection<Server> getServers() {
new Server("rvn-dashboard.com", Server.ConnectionType.SSL, 50002),
new Server("rvn4lyfe.com", Server.ConnectionType.SSL, 50002)
);

List<ElectrumX.Server> availableServers = new ArrayList<>();
Boolean useDefault = Settings.getInstance().getUseRavencoinDefaults();
if (useDefault == true) {
availableServers.addAll(defaultServers);
}

String[] settingsList = Settings.getInstance().getRavencoinServers();
if (settingsList != null) {
List<ElectrumX.Server> customServers = new ArrayList<>();
for (String setting : settingsList) {
String[] colonParts = setting.split(":");
if (colonParts.length == 2) {
String[] commaParts = colonParts[1].split(",");
if (commaParts.length == 2) {
String hostname = colonParts[0];
int port = Integer.parseInt(commaParts[0].trim());
String typeString = commaParts[1].trim().toUpperCase();
Server.ConnectionType type = Server.ConnectionType.SSL;
if (typeString.equals("TCP")) {
type = Server.ConnectionType.TCP;
}
customServers.add(new Server(hostname, type, port));
}
}
}
availableServers.addAll(customServers);
}
return availableServers;
}

@Override
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/org/qortal/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,23 @@ public class Settings {
private DigibyteNet digibyteNet = DigibyteNet.MAIN;
private RavencoinNet ravencoinNet = RavencoinNet.MAIN;
private PirateChainNet pirateChainNet = PirateChainNet.MAIN;

// List of ElectrumX servers to attempt connections with
private String[] bitcoinServers = null;
private String[] litecoinServers = null;
private String[] dogecoinServers = null;
private String[] digibyteServers = null;
private String[] ravencoinServers = null;
private String[] pirateChainServers = null;

// Whether to connect with the default ElectrumX servers
private Boolean useBitcoinDefaults = true;
private Boolean useLitecoinDefaults = true;
private Boolean useDogecoinDefaults = true;
private Boolean useDigibyteDefaults = true;
private Boolean useRavencoinDefaults = true;
private Boolean usePirateChainDefaults = true;

// Also crosschain-related:
/** Whether to show SysTray pop-up notifications when trade-bot entries change state */
private boolean tradebotSystrayEnabled = false;
Expand Down Expand Up @@ -857,6 +874,44 @@ public PirateChainNet getPirateChainNet() {
return this.pirateChainNet;
}

public String[] getBitcoinServers() {
return this.bitcoinServers;
}
public String[] getLitecoinServers() {
return this.litecoinServers;
}
public String[] getDogecoinServers() {
return this.dogecoinServers;
}
public String[] getDigibyteServers() {
return this.digibyteServers;
}
public String[] getRavencoinServers() {
return this.ravencoinServers;
}
public String[] getPirateChainServers() {
return this.pirateChainServers;
}

public Boolean getUseBitcoinDefaults() {
return this.useBitcoinDefaults;
}
public Boolean getUseLitecoinDefaults() {
return this.useLitecoinDefaults;
}
public Boolean getUseDogecoinDefaults() {
return this.useDogecoinDefaults;
}
public Boolean getUseDigibyteDefaults() {
return this.useDigibyteDefaults;
}
public Boolean getUseRavencoinDefaults() {
return this.useRavencoinDefaults;
}
public Boolean getUsePirateChainDefaults() {
return this.usePirateChainDefaults;
}

public int getMaxTradeOfferAttempts() {
return this.maxTradeOfferAttempts;
}
Expand Down

0 comments on commit 821046d

Please sign in to comment.