Browse Source

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

terminal
Craig Raw 3 years ago
parent
commit
1208baf00e
  1. 4
      src/main/java/com/sparrowwallet/sparrow/AppServices.java
  2. 2
      src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java
  3. 2
      src/main/java/com/sparrowwallet/sparrow/net/FeeRatesSource.java

4
src/main/java/com/sparrowwallet/sparrow/AppServices.java

@ -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);
} }

2
src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java

@ -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++) {

2
src/main/java/com/sparrowwallet/sparrow/net/FeeRatesSource.java

@ -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);
} }
}, },

Loading…
Cancel
Save