Skip to content

Commit

Permalink
Added TOR endpoints proper support
Browse files Browse the repository at this point in the history
  • Loading branch information
itserg committed Apr 2, 2019
1 parent 0291157 commit 3270294
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
10 changes: 7 additions & 3 deletions mbw/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ android {
ColuBlockExplorerApiURLs = '{"https://coloredcoins.gear.mycelium.com/api/", "https://explorer.coloredcoins.org/api/"}'
RMCChangeAddress = "18c91fJmVg7btPjxpwrhgwd37GkVghq9me"

ElectrumServers = '{"tcp-tls://electrumx-aws.mycelium.com:9335", "tcp-tls://electrumx-aws-b.mycelium.com:9335", "cp-tls://electrumx-aws-c.mycelium.com:9335"}'
WapiServers='"[{\\\'cert-sha1\':\\\'14:83:CB:96:48:E0:7F:96:D0:C3:78:17:98:6F:E3:72:4C:34:E5:07\\\',\\\'url\\\':\\\'https://wapi.mycelium.com/wapi\\\'}]"'
ElectrumServers = '{"tcp-tls://electrumx-aws.mycelium.com:9335", "tcp-tls://electrumx-aws-b.mycelium.com:9335", "tcp-tls://electrumx-aws-c.mycelium.com:9335"}'
WapiServers='"[{\\\'cert-sha1\':\\\'14:83:CB:96:48:E0:7F:96:D0:C3:78:17:98:6F:E3:72:4C:34:E5:07\\\',\\\'url\\\':\\\'https://wapi.mycelium.com/\\\'},' +
'{\\\'cert-sha1\':\\\'C5:09:C8:37:84:53:65:EE:8E:22:89:32:8F:86:70:49:AD:0A:53:4D\\\',\\\'url\\\':\\\'https://vtuao7psnrsot4tb.onion/wapi\\\'},' +
'{\\\'cert-sha1\':\\\'65:1B:FF:6B:8C:7F:C8:1C:8E:14:77:1E:74:9C:F7:E5:46:42:BA:E0\\\',\\\'url\\\':\\\'https://mws20.mycelium.com/wapi\\\'}]"'

appIdSpvBch = [release: "com.mycelium.module.spvbch",
debug : "com.mycelium.module.spvbch.debug"]
Expand All @@ -242,7 +244,9 @@ android {
RMCChangeAddress = "mx92L6iuCfxQUz4cLNU4jJpfWbavVHgYj9"

ElectrumServers = '{"tcp-tls://electrumx-aws-test.mycelium.com:19335"}'
WapiServers='"[{\\\'cert-sha1\\\':\\\'14:83:CB:96:48:E0:7F:96:D0:C3:78:17:98:6F:E3:72:4C:34:E5:07\\\',\\\'url\\\':\\\'https://wapi.mycelium.com/wapitestnet\\\'}]"'
WapiServers='"[{\\\'cert-sha1\':\\\'E5:70:76:B2:67:3A:89:44:7A:48:14:81:DF:BD:A0:58:C8:82:72:4F\\\',\\\'url\\\':\\\'https://mws31.mycelium.com/wapitestnet\\\'},' +
'{\\\'cert-sha1\\\':\\\'ED:C2:82:16:65:8C:4E:E1:C7:F6:A2:2B:15:EC:30:F9:CD:48:F8:DB\\\',\\\'url\\\':\\\'https://mws30.mycelium.com/wapitestnet\\\'}, ' +
'{\\\'cert-sha1\\\':\\\'75:3E:8A:87:FA:95:9F:C6:1A:DB:2A:09:43:CE:52:74:27:B1:80:4B\\\',\\\'url\\\':\\\'https://ti4v3ipng2pqutby.onion/wapitestnet\\\'}]"'

appIdSpvBch = [release: "com.mycelium.module.spvbch.testnet",
debug : "com.mycelium.module.spvbch.testnet.debug"]
Expand Down
13 changes: 11 additions & 2 deletions mbw/src/main/java/com/mycelium/wallet/WalletConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.google.gson.annotations.SerializedName
import com.mrd.bitlib.model.NetworkParameters
import com.mycelium.net.HttpEndpoint
import com.mycelium.net.HttpsEndpoint
import com.mycelium.net.TorHttpsEndpoint
import com.mycelium.wapi.api.jsonrpc.TcpEndpoint
import retrofit2.Call
import retrofit2.Retrofit
Expand All @@ -29,12 +30,14 @@ interface MyceliumNodesApi {
class MyceliumNodesResponse(@SerializedName("BTC-testnet") val btcTestnet: BTCNetResponse,
@SerializedName("BTC-mainnet") val btcMainnet: BTCNetResponse)

const val ONION_DOMAIN = ".onion"

// BTCNetResponse is intended for parsing nodes.json file
class BTCNetResponse(val electrumx: ElectrumXResponse, @SerializedName("WAPI") val wapi: WapiSectionResponse)

class WapiSectionResponse(val primary : Array<HttpsUrlResponse>)

class ElectrumXResponse(val primary : Array<UrlResponse>, backup: Array<UrlResponse>)
class ElectrumXResponse(val primary : Array<UrlResponse>)

class UrlResponse(val url: String)

Expand Down Expand Up @@ -102,7 +105,13 @@ class WalletConfiguration(private val prefs: SharedPreferences,

fun getWapiEndpoints(): List<HttpEndpoint> {
var resp = gson.fromJson(wapiServers, Array<HttpsUrlResponse>::class.java)
return resp.map { HttpsEndpoint(it.url, it.cert) }
return resp.map {
if (it.url.contains(ONION_DOMAIN)) {
TorHttpsEndpoint(it.url, it.cert)
} else {
HttpsEndpoint(it.url, it.cert)
}
}
}

private var serverListChangedListener: ServerListChangedListener? = null
Expand Down

0 comments on commit 3270294

Please sign in to comment.