Skip to content

Commit 8ef8fbd

Browse files
committed
Merge branch 'develop'
2 parents ff8af28 + 96ee4d0 commit 8ef8fbd

File tree

302 files changed

+55877
-202197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+55877
-202197
lines changed

android/app/build.gradle

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 28
29+
compileSdkVersion 29
3030

3131
sourceSets {
3232
main.java.srcDirs += 'src/main/kotlin'
@@ -50,6 +50,12 @@ android {
5050
release {
5151
// Signing with the debug keys for now, so `flutter run --release` works.
5252
signingConfig signingConfigs.debug
53+
resValue "string", "app_name", "Sentinelx"
54+
}
55+
debug {
56+
applicationIdSuffix ".debug"
57+
resValue "string", "app_name", "Sentinelx Staging"
58+
debuggable true
5359
}
5460
}
5561
splits {
@@ -69,7 +75,7 @@ android {
6975
}
7076
}
7177

72-
ext.abiCodes = ['armeabi-v7a':2, 'arm64-v8a':3]
78+
ext.abiCodes = ['armeabi-v7a': 2, 'arm64-v8a': 3]
7379

7480
import com.android.build.OutputFile
7581

@@ -112,24 +118,25 @@ dependencies {
112118
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
113119
implementation 'org.bouncycastle:bcprov-jdk15on:1.56'
114120
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
115-
implementation 'androidx.appcompat:appcompat:1.0.0'
116-
implementation 'org.apache.commons:commons-lang3:3.3.2'
121+
implementation 'androidx.appcompat:appcompat:1.1.0'
122+
implementation 'org.apache.commons:commons-lang3:3.4'
117123
implementation 'com.lambdaworks:scrypt:1.4.0'
118124
implementation 'commons-codec:commons-codec:1.10'
119-
implementation 'com.google.guava:guava:24.1-jre'
120-
implementation 'com.google.code.gson:gson:2.8.5'
125+
implementation 'com.google.guava:guava:28.2-jre'
126+
implementation 'com.google.code.gson:gson:2.8.6'
121127
implementation 'com.google.protobuf:protobuf-java:3.8.0'
122-
implementation 'com.squareup.okhttp3:okhttp:3.13.1'
123-
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
124-
implementation('com.google.zxing:core:3.3.0') {
125-
transitive = true
128+
implementation 'com.squareup.okhttp3:okhttp:4.4.0'
129+
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
130+
implementation('com.google.zxing:core:3.4.0') {
131+
126132
}
127-
implementation(project(path: ':tor')) {
128-
transitive = false
133+
implementation(project(':torservice')) {
134+
exclude module: 'org.slf4j'
135+
exclude group:'org.slf4j'
129136
}
130-
implementation 'org.torproject:tor-android-binary:0.3.5.8-rc-v2'
137+
implementation 'org.torproject:tor-android-binary:0.4.2.5'
131138
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
132-
testImplementation 'junit:junit:4.12'
133-
androidTestImplementation 'androidx.test:runner:1.1.0'
134-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
139+
testImplementation 'junit:junit:4.13'
140+
androidTestImplementation 'androidx.test:runner:1.2.0'
141+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
135142
}

android/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
In most cases you can leave this as-is, but you if you want to provide
99
additional functionality it is fine to subclass or reimplement
1010
FlutterApplication and put your custom class here.
11+
12+
usesCleartextTraffic is enabled in order to use onion urls
1113
-->
1214
<application
1315
android:name="io.flutter.app.FlutterApplication"
1416
android:icon="@mipmap/ic_launcher"
15-
android:label="Sentinel x"
17+
android:label="@string/app_name"
1618
android:usesCleartextTraffic="true"
1719
tools:ignore="GoogleAppIndexingWarning">
1820
<activity

android/app/src/main/kotlin/com/invertedx/sentinelx/api/ApiService.kt

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
package com.invertedx.sentinelx.api
22

33
import android.content.Context
4+
import android.preference.PreferenceManager
45
import android.util.Log
56
import com.invertedx.sentinelx.BuildConfig
67
import com.invertedx.sentinelx.SentinelxApp
78
import com.invertedx.sentinelx.i
89
import com.invertedx.sentinelx.tor.TorManager
910
import com.invertedx.sentinelx.utils.LoggingInterceptor
11+
import com.invertedx.sentinelx.utils.SentinalPrefs
1012
import io.reactivex.Observable
1113
import okhttp3.FormBody
1214
import okhttp3.OkHttpClient
1315
import okhttp3.Request
1416
import okhttp3.RequestBody
1517
import java.util.concurrent.TimeUnit
18+
import javax.net.ssl.HostnameVerifier
1619
import javax.net.ssl.SSLContext
1720
import javax.net.ssl.TrustManager
1821
import javax.net.ssl.X509TrustManager
@@ -35,7 +38,7 @@ class ApiService(private val applicationContext: Context) {
3538

3639
fun getTxAndXPUBData(XpubOrAddress: String): Observable<String> {
3740
val baseAddress = getBaseUrl()
38-
val url = if (SentinelxApp.accessToken.isNotEmpty()) "${baseAddress}multiaddr?active=$XpubOrAddress&at=${SentinelxApp.accessToken}" else "${baseAddress}multiaddr?active=$XpubOrAddress"
41+
val url = if (SentinelxApp.accessToken.isNotEmpty()) "${baseAddress}multiaddr?active=$XpubOrAddress&at=${SentinelxApp.accessToken}" else "${baseAddress}multiaddr?active=$XpubOrAddress"
3942

4043
Log.i("API", "CALL url -> $url")
4144
return Observable.fromCallable {
@@ -44,7 +47,7 @@ class ApiService(private val applicationContext: Context) {
4447
.build()
4548
val response = client.newCall(request).execute()
4649
try {
47-
val content = response.body()!!.string()
50+
val content = response.body!!.string()
4851
Log.i("API", "response -> $content")
4952
return@fromCallable content
5053
} catch (ex: Exception) {
@@ -61,12 +64,11 @@ class ApiService(private val applicationContext: Context) {
6164
*/
6265
makeClient()
6366

64-
i("DOJO URL SentinelxApp.dojoUrl")
6567
if (SentinelxApp.dojoUrl.isNotBlank()) {
6668
return SentinelxApp.dojoUrl
6769
}
6870

69-
return if (TorManager.getInstance(this.applicationContext).isConnected) {
71+
return if (TorManager.getInstance(this.applicationContext)?.isConnected!!) {
7072
if (SentinelxApp.isTestNet()) SAMOURAI_API2_TESTNET_TOR_DIST else SAMOURAI_API2_TOR_DIST
7173
} else {
7274
if (SentinelxApp.isTestNet()) SAMOURAI_API_TESTNET else SAMOURAI_API
@@ -75,7 +77,7 @@ class ApiService(private val applicationContext: Context) {
7577

7678
fun getTx(txid: String): Observable<String> {
7779
val baseAddress = getBaseUrl()
78-
val baseUrl = if (SentinelxApp.accessToken.isNotEmpty()) "${baseAddress}tx/$txid/?fees=trues&at=${SentinelxApp.accessToken}" else "${baseAddress}tx/$txid/?fees=trues"
80+
val baseUrl = if (SentinelxApp.accessToken.isNotEmpty()) "${baseAddress}tx/$txid/?fees=trues&at=${SentinelxApp.accessToken}" else "${baseAddress}tx/$txid/?fees=trues"
7981

8082
return Observable.fromCallable {
8183

@@ -85,7 +87,7 @@ class ApiService(private val applicationContext: Context) {
8587

8688
val response = client.newCall(request).execute()
8789
try {
88-
val content = response.body()!!.string()
90+
val content = response.body!!.string()
8991
Log.i("API", "response -> $content")
9092
return@fromCallable content
9193
} catch (ex: Exception) {
@@ -107,7 +109,7 @@ class ApiService(private val applicationContext: Context) {
107109

108110
val response = client.newCall(request).execute()
109111
try {
110-
return@fromCallable response.body()!!.string()
112+
return@fromCallable response.body!!.string()
111113
} catch (ex: Exception) {
112114
throw ex
113115
}
@@ -120,7 +122,7 @@ class ApiService(private val applicationContext: Context) {
120122
makeClient()
121123

122124
val baseAddress = getBaseUrl()
123-
val baseUrl = if (SentinelxApp.accessToken.isNotEmpty()) "${baseAddress}unspent?active=$xpubOrAddress&at=${SentinelxApp.accessToken}" else "${baseAddress}unspent?active=$xpubOrAddress";
125+
val baseUrl = if (SentinelxApp.accessToken.isNotEmpty()) "${baseAddress}unspent?active=$xpubOrAddress&at=${SentinelxApp.accessToken}" else "${baseAddress}unspent?active=$xpubOrAddress";
124126

125127
return Observable.fromCallable {
126128

@@ -130,7 +132,7 @@ class ApiService(private val applicationContext: Context) {
130132

131133
val response = client.newCall(request).execute()
132134
try {
133-
val content = response.body()!!.string()
135+
val content = response.body!!.string()
134136
return@fromCallable content
135137
} catch (ex: Exception) {
136138
throw ex;
@@ -140,6 +142,9 @@ class ApiService(private val applicationContext: Context) {
140142
}
141143

142144
fun addHDAccount(xpub: String, bip: String): Observable<String> {
145+
146+
makeClient()
147+
143148
val baseAddress = getBaseUrl()
144149
val baseUrl = if (SentinelxApp.accessToken.isNotEmpty()) "${baseAddress}xpub?at=${SentinelxApp.accessToken.trim()}" else "${baseAddress}xpub";
145150

@@ -157,25 +162,34 @@ class ApiService(private val applicationContext: Context) {
157162
.url(baseUrl)
158163
.method("POST", requestBody)
159164
.build()
165+
166+
client.connectTimeoutMillis
160167
val response = client.newCall(request).execute()
161-
val content = response.body()!!.string()
168+
val content = response.body!!.string()
162169
Log.i("API", "response -> $content")
163170
return@fromCallable content
164171

165172
}
166173
}
167174

168-
private fun makeClient() {
175+
176+
fun makeClient() {
169177
val builder = OkHttpClient.Builder()
170178
if (BuildConfig.DEBUG) {
171179
builder.addInterceptor(LoggingInterceptor())
172180
}
173-
if ((TorManager.getInstance(this.applicationContext).isConnected)) {
181+
if ((TorManager.getInstance(this.applicationContext)?.isConnected!!)) {
174182
getHostNameVerifier(builder)
175-
builder.proxy(TorManager.getInstance(this.applicationContext).proxy)
183+
builder.proxy(TorManager.getInstance(this.applicationContext)?.getProxy())
184+
}
185+
val prefs = SentinalPrefs(applicationContext)
186+
187+
var timeout = 90L;
188+
if (prefs.timeout != null) {
189+
timeout = prefs.timeout!!.toLong();
176190
}
177-
builder.connectTimeout(60, TimeUnit.SECONDS) // connect timeout
178-
builder.readTimeout(60, TimeUnit.SECONDS)
191+
builder.connectTimeout(timeout, TimeUnit.SECONDS) // connect timeout
192+
builder.readTimeout(timeout, TimeUnit.SECONDS)
179193
client = builder.build()
180194
}
181195

@@ -202,7 +216,7 @@ class ApiService(private val applicationContext: Context) {
202216

203217

204218
clientBuilder.sslSocketFactory(sslSocketFactory, trustAllCerts[0] as X509TrustManager)
205-
clientBuilder.hostnameVerifier { hostname, session -> true }
219+
clientBuilder.hostnameVerifier(HostnameVerifier { _, _ -> true })
206220

207221
}
208222

0 commit comments

Comments
 (0)