Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a746d3d
Merge pull request #53 from gruntsoftware/release/v4.4.1
kcw-grunt Mar 30, 2025
ba8ea45
Revert "Updated the APIManager"
kcw-grunt Mar 31, 2025
638ce3a
Reverted the Kotlin APIManager.
kcw-grunt Mar 31, 2025
5344a96
Add version and code to welcome screen
kcw-grunt Mar 31, 2025
ebc3bb9
reset padding
kcw-grunt Mar 31, 2025
03c68b8
Merge pull request #56 from gruntsoftware/feature/add-version-issue-108
kcw-grunt Apr 1, 2025
c770f01
Revert "Updated the APIManager"
kcw-grunt Mar 31, 2025
f8c1bd5
Reverted the Kotlin APIManager.
kcw-grunt Mar 31, 2025
ff58b57
fix: fix crash when FragmentSignal dismissed
andhikayuana Apr 4, 2025
d64ea93
fix: fix sync after wipe
andhikayuana Apr 7, 2025
277f387
Merge branch 'hotfix/api-manager-fix' of https://github.com/brainwall…
kcw-grunt Apr 7, 2025
9a8a20f
fix: fix wrong lifecycle to trigger callback at FragmentSignal
andhikayuana Apr 7, 2025
832fa36
Update issue templates
kcw-grunt Apr 8, 2025
b294cd6
updated core changes
kcw-grunt Apr 8, 2025
4ed8af3
Merge pull request #57 from gruntsoftware/hotfix/api-manager-fix
kcw-grunt Apr 8, 2025
089995a
Rename .java to .kt
andhikayuana Apr 11, 2025
7e85987
chore: refactor BRApiManager & APIClient
andhikayuana Apr 11, 2025
0aa41e7
chore: remove unused part at APIClient
andhikayuana Apr 14, 2025
0cc29cb
feat: wip new peer discovery
andhikayuana Apr 14, 2025
54d2d9e
feat: implement selected peer ip address from cache (fetched from API)
andhikayuana Apr 14, 2025
c6923b1
feat: implement selected peer ip address from cache (fetched from API)
andhikayuana Apr 14, 2025
ef4e6d2
feat: filter out peers with NODE_NETWORK, NODE_BLOOM
andhikayuana Apr 15, 2025
2336939
fix: race condition when clear shared prefs values after wipeAll
andhikayuana Apr 16, 2025
51a4d9a
Merge pull request #62 from gruntsoftware/hotfix/prefs-race-condition
kcw-grunt Apr 16, 2025
62afb9d
Merge pull request #61 from gruntsoftware/feat/new-peer-discovery
kcw-grunt Apr 16, 2025
391e319
Updating the core library
kcw-grunt Apr 16, 2025
836b6f0
Chore/revert pre peer discovery (Android) (#69)
andhikayuana Apr 25, 2025
3caa1a7
feat: remove unused activity (ImportActivity) at AndroidManifest.xml …
andhikayuana Apr 29, 2025
a324444
fix: fix crash IllegalStateException: cannot make a new request becau…
andhikayuana May 2, 2025
1f9c5d0
code bump
kcw-grunt May 2, 2025
7ca17d3
Feat/move tx fee (#74)
andhikayuana May 5, 2025
e7fb2b7
fix: fix dismiss allow state loss (#76)
andhikayuana May 7, 2025
3d8ef98
fix: fix typo at strings.xml (#75)
andhikayuana May 7, 2025
25be1a8
feat: new UI for receive and topup flow (moonpay integration) (#72)
andhikayuana May 12, 2025
18eda46
version and code bump
kcw-grunt May 12, 2025
dbb6a5f
Added support url (#81)
kcw-grunt May 19, 2025
c82a5e3
version and code bump
kcw-grunt May 19, 2025
2981ec6
Revert from eda0f532 & cherry pick (#86)
andhikayuana May 25, 2025
c161fed
build bump
kcw-grunt May 25, 2025
63d7494
chore: open bread activity first then open moonpay widget (#88)
andhikayuana May 26, 2025
f09eb28
Adjustment for circleci (#89)
andhikayuana May 29, 2025
47c69cd
fix: android: Footer version label is obfuscated (#92)
andhikayuana May 29, 2025
a9c4a63
fix: You saved it right screen reset button covers words (#93)
andhikayuana May 29, 2025
d8f08ad
tiny resizing (#94)
kcw-grunt May 29, 2025
ef93585
code and version bump
kcw-grunt May 29, 2025
174d612
change break (#97)
kcw-grunt May 30, 2025
a4521d7
build code number
andhikayuana May 31, 2025
6fec1e2
fix: [#137] fix: Reset fiat options in Buy / Receive modal (#99)
andhikayuana Jun 2, 2025
c8fdf8d
Chore/update device data (#100)
kcw-grunt Jun 2, 2025
3f646df
Add agent string obfuscation (#103)
kcw-grunt Jun 14, 2025
fdc57e7
version bump
kcw-grunt Jun 15, 2025
4ff63e4
Merge branch 'main' into release/v4.6.0
kcw-grunt Jun 15, 2025
91cc992
code bump
kcw-grunt Jun 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {
applicationId = "ltd.grunt.brainwallet"
minSdk = 29
targetSdk = 34
versionCode = 202506031
versionName = "v4.5.5"
versionCode = 202506191
versionName = "v4.6.0"

multiDexEnabled = true
base.archivesName.set("${defaultConfig.versionName}(${defaultConfig.versionCode})")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ interface LtcRepository {
remoteApiSource.getBuyQuote(params)

override suspend fun fetchMoonpaySignedUrl(params: Map<String, String>): String {
val agentString = Utils.getAgentString(context, "android/HttpURLConnection")
val externalTransactionID = Utils.getEncryptedAgentString(context)
val finalParams = params + mapOf(
"defaultCurrencyCode" to "ltc",
"externalTransactionId" to agentString,
"externalTransactionId" to externalTransactionID,
"currencyCode" to "ltc",
"themeId" to "main-v1.0.0",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ enum class ServiceItems(val key: String) {
WALLETSTART("start-date"),
AFDEVID("af-dev-id"),
CLIENTCODE("client-code"),
AGENTPUBKEY("agent-base64-pubkey")
}
114 changes: 101 additions & 13 deletions app/src/main/java/com/brainwallet/tools/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import android.app.Activity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.Build;
Expand All @@ -15,10 +13,21 @@
import android.view.inputmethod.InputMethodManager;

import com.brainwallet.tools.manager.AnalyticsManager;
import com.brainwallet.tools.sqlite.CurrencyDataSource;
import com.brainwallet.data.model.CurrencyEntity;
import com.brainwallet.presenter.entities.ServiceItems;

import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand All @@ -33,7 +42,6 @@
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Currency;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -168,21 +176,98 @@ public static void hideKeyboard(Context app) {
}

}

public static String getAgentString(Context app, String cfnetwork) {
int versionNumber = 0;

String deviceCode = Build.MANUFACTURER + "-|-" + Build.MODEL;
String appVersion = BRConstants.APP_VERSION_NAME_CODE;
return String.format(Locale.ENGLISH, "%s/%d %s Android/%s Device/%s", "Brainwallet",
appVersion, cfnetwork, Build.VERSION.RELEASE, deviceCode);
}
public static String getEncryptedAgentString(Context app) {
String deviceCode = Build.MANUFACTURER;
String deviceType = Build.DEVICE;
String deviceModel = Build.MODEL;
String appVersion = BRConstants.APP_VERSION_NAME_CODE;
String formattedAgentString = String.format(Locale.ENGLISH, "brainwallet-android,%s,%s-%s-%s",
appVersion, deviceCode,deviceType,deviceModel);

try {

// Convert base64 public key string to PublicKey object
byte[] keyBytes;
try {
String pubkey = Utils.fetchServiceItem(app, ServiceItems.AGENTPUBKEY).toString();
keyBytes = Base64.getDecoder().decode(pubkey);

// Decode the base64 to get the PEM string
byte[] pemBytes = Base64.getDecoder().decode(pubkey);
String pemString = new String(pemBytes, "UTF-8");

// Extract just the key data (remove PEM headers and whitespace)
String keyData = pemString
.replace("-----BEGIN PUBLIC KEY-----", "")
.replace("-----END PUBLIC KEY-----", "")
.replaceAll("\\s+", "");

// Decode the clean base64 key data
keyBytes = Base64.getDecoder().decode(keyData);
} catch (IllegalArgumentException e) {
Timber.d("Invalid base64 public key format: %s", e.toString());
return "ERROR-CANNOT-KEYBYTES-DO-CONVERSION";
}

KeyFactory keyFactory;
try {
keyFactory = KeyFactory.getInstance("RSA");
} catch (NoSuchAlgorithmException e) {
Timber.d("RSA algorithm not available: %s", e.toString());
return "ERROR-CANNOT-NOSUCHALGO";
}

if (app != null) {
// Generate PublicKey object
PublicKey publicKey;
try {
PackageInfo pInfo = app.getPackageManager().getPackageInfo(app.getPackageName(), 0);
versionNumber = pInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
Timber.e(e);
publicKey = keyFactory.generatePublic(new X509EncodedKeySpec(keyBytes));
} catch (InvalidKeySpecException e) {
Timber.d("Invalid public key specification: %s", e.toString());
return "ERROR-CANNOT-INVALID-PUBLIC-KEY-SPEC";
}

// Initialize cipher for encryption
Cipher cipher;
try {
cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
Timber.d("RSA cipher algorithm/padding not available: %s", e.toString());
return "ERROR-RSA-CIPHER-NA";
}

try {
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
} catch (InvalidKeyException e) {
Timber.d("Invalid public key for encryption: %s", e.toString());
return "ERROR-CANNOT-INVALID-PUBLIC-KEY-ENCRYPTION";
}

// Encrypt the agent string
byte[] encryptedBytes;
try {
encryptedBytes = cipher.doFinal(formattedAgentString.getBytes());
} catch (IllegalBlockSizeException e) {
Timber.d("Agent string too large for RSA encryption. Consider using hybrid encryption.: %s", e.toString());
return "ERROR-ILLEGAL-BLOCK-SIZE";
} catch (BadPaddingException e) {
Timber.d("Padding error during encryption: %s", e.toString());
return "ERROR-BAD-PADDING-EXCEPTION";
}

return Base64.getEncoder().encodeToString(encryptedBytes);

} catch (Exception e) {
// Catch any unexpected exceptions
Timber.d("Unexpected error during encryption: %s", e.toString());
return "ERROR-UNEXPECTED-DURING-ENCRYPTION";
}
return String.format(Locale.ENGLISH, "%s/%d %s Android/%s Device/%s", "Brainwallet", versionNumber, cfnetwork, Build.VERSION.RELEASE, deviceCode);
}

public static String reverseHex(String hex) {
Expand Down Expand Up @@ -245,6 +330,9 @@ else if (name == ServiceItems.OPSALL) {
else if (name == ServiceItems.AFDEVID) {
return keyObject.optString(name.getKey());
}
else if (name == ServiceItems.AGENTPUBKEY) {
return keyObject.optString(name.getKey());
}
else if (name == ServiceItems.CLIENTCODE) {
return keyObject.optString(name.getKey());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ fun YourSeedWordsScreen(
}
}

LaunchedEffect(Unit) {
viewModel.uiEffect.collect { effect ->
when (effect) {
is UiEffect.Navigate -> onNavigate.invoke(effect)
else -> Unit
}
}
}

BrainwalletScaffold(
topBar = {
BrainwalletTopAppBar(
Expand Down