use mempool.space onion address for fee rates if tor proxy enabled

This commit is contained in:
Craig Raw 2021-06-15 09:31:12 +02:00
parent 655a473cd5
commit 1208baf00e
3 changed files with 6 additions and 2 deletions

View file

@ -373,6 +373,10 @@ public class AppServices {
return Tor.getDefault() != null; return Tor.getDefault() != null;
} }
public static boolean isUsingProxy() {
return isTorRunning() || Config.get().isUseProxy();
}
public static Proxy getProxy() { public static Proxy getProxy() {
return getProxy(TOR_DEFAULT_PROXY_CIRCUIT_ID); return getProxy(TOR_DEFAULT_PROXY_CIRCUIT_ID);
} }

View file

@ -1328,7 +1328,7 @@ public class ElectrumServer {
return new Task<>() { return new Task<>() {
protected Sha256Hash call() throws ServerException { protected Sha256Hash call() throws ServerException {
//If Tor proxy is configured, try all external broadcast sources in random order before falling back to connected Electrum server //If Tor proxy is configured, try all external broadcast sources in random order before falling back to connected Electrum server
if(AppServices.getProxy() != null) { if(AppServices.isUsingProxy()) {
List<BroadcastSource> broadcastSources = Arrays.stream(BroadcastSource.values()).filter(src -> src.getSupportedNetworks().contains(Network.get())).collect(Collectors.toList()); List<BroadcastSource> broadcastSources = Arrays.stream(BroadcastSource.values()).filter(src -> src.getSupportedNetworks().contains(Network.get())).collect(Collectors.toList());
Sha256Hash txid = null; Sha256Hash txid = null;
for(int i = 1; !broadcastSources.isEmpty(); i++) { for(int i = 1; !broadcastSources.isEmpty(); i++) {

View file

@ -25,7 +25,7 @@ public enum FeeRatesSource {
MEMPOOL_SPACE("mempool.space") { MEMPOOL_SPACE("mempool.space") {
@Override @Override
public Map<Integer, Double> getBlockTargetFeeRates(Map<Integer, Double> defaultblockTargetFeeRates) { public Map<Integer, Double> getBlockTargetFeeRates(Map<Integer, Double> defaultblockTargetFeeRates) {
String url = "https://mempool.space/api/v1/fees/recommended"; String url = AppServices.isUsingProxy() ? "http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/api/v1/fees/recommended" : "https://mempool.space/api/v1/fees/recommended";
return getThreeTierFeeRates(defaultblockTargetFeeRates, url); return getThreeTierFeeRates(defaultblockTargetFeeRates, url);
} }
}, },