-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge whirlpool 1.x client using decentralized soroban
- Loading branch information
Showing
34 changed files
with
1,007 additions
and
877 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/com/sparrowwallet/sparrow/net/HttpProxySupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.sparrowwallet.sparrow.net; | ||
|
||
import com.google.common.net.HostAndPort; | ||
import com.samourai.http.client.IHttpProxySupplier; | ||
import com.samourai.wallet.httpClient.HttpProxy; | ||
import com.samourai.wallet.httpClient.HttpProxyProtocol; | ||
import com.samourai.wallet.httpClient.HttpUsage; | ||
|
||
import java.util.Optional; | ||
|
||
public class HttpProxySupplier implements IHttpProxySupplier { | ||
private HostAndPort torProxy; | ||
private HttpProxy httpProxy; | ||
|
||
public HttpProxySupplier(HostAndPort torProxy) { | ||
this.torProxy = torProxy; | ||
this.httpProxy = computeHttpProxy(torProxy); | ||
} | ||
|
||
private HttpProxy computeHttpProxy(HostAndPort hostAndPort) { | ||
if (hostAndPort == null) { | ||
return null; | ||
} | ||
|
||
return new HttpProxy(HttpProxyProtocol.SOCKS, hostAndPort.getHost(), hostAndPort.getPort()); | ||
} | ||
|
||
public HostAndPort getTorProxy() { | ||
return torProxy; | ||
} | ||
|
||
// shouldnt call directly but use httpClientService.setTorProxy() | ||
public void _setTorProxy(HostAndPort hostAndPort) { | ||
// set proxy | ||
this.torProxy = hostAndPort; | ||
this.httpProxy = computeHttpProxy(hostAndPort); | ||
} | ||
|
||
@Override | ||
public Optional<HttpProxy> getHttpProxy(HttpUsage httpUsage) { | ||
return Optional.ofNullable(httpProxy); | ||
} | ||
|
||
@Override | ||
public void changeIdentity() { | ||
HostAndPort torProxy = getTorProxy(); | ||
if(torProxy != null) { | ||
TorUtils.changeIdentity(torProxy); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.