Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 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
642f9e6
updated metadata (#105)
kcw-grunt Jun 24, 2025
50f44de
chore: remove screen lock detection (#106)
andhikayuana Jun 24, 2025
ea15423
🧰 Fx/seed words UI polish (#108)
kcw-grunt Jun 25, 2025
5b6dff3
❇️ Feat/add polish punjabi farsi (#109)
kcw-grunt Jun 27, 2025
4ff50b8
fix: fix YourSeedProveItState.isWordUsedCorrectly (#111)
andhikayuana Jun 29, 2025
2fd094f
Upgrade targetSdk 36 (#113)
andhikayuana Aug 5, 2025
4efd95f
feat(#195): adopt koin annotation for dependency injection (#120)
JosephSanjaya Aug 18, 2025
5900ed4
Create PULL_REQUEST_TEMPLATE.md
kcw-grunt Aug 19, 2025
3b1f628
bump for test (#121)
kcw-grunt Aug 19, 2025
f11d5a8
feat(#174): initiate games module (#119)
JosephSanjaya Aug 20, 2025
77ed7df
Force pushed the version and code bump and catch up with Prod.
kcw-grunt Aug 20, 2025
ef353e3
πŸš€[Release v4.7.2] Merge into Develop (#127)
kcw-grunt Aug 25, 2025
e25e9e1
Fix(#227): Crash when launching MoonPay Widget (#126)
JosephSanjaya Aug 25, 2025
e0aebb5
feat(#138): Improve Unlock Screen UI and add dark mode toggle (#122)
JosephSanjaya Aug 25, 2025
7d8dd14
Redesign welcome screen (#123)
josikie Aug 25, 2025
18df293
fix(#226): android test failure on RecoverWalletScreenGrabsTest (#130)
JosephSanjaya Aug 26, 2025
9b191b7
fix(#223): fix issue on test environment SLF4J + agent warnings in te…
JosephSanjaya Aug 26, 2025
c9b1ef0
feat(#225): Send sync duration in Firebase Analytics as a custom even…
JosephSanjaya Aug 30, 2025
58f0cd8
feat(#234): Implement language-specific Firebase messaging topics (#132)
JosephSanjaya Aug 30, 2025
4bb06cf
bump code
kcw-grunt Aug 30, 2025
9f4908b
chore(#234): normalize Indonesian language code to "id" (#133)
JosephSanjaya Aug 30, 2025
4a27ae0
Feat: Detekt and Test Plugins, (Including Create Detekt Baseline) (#136)
JosephSanjaya Sep 22, 2025
3285d8e
Chore/renamed gp module (#140)
kcw-grunt Sep 29, 2025
94459d0
create private gp submodule
kcw-grunt Sep 23, 2025
13c39a0
Update settings.gradle.kts
kcw-grunt Sep 23, 2025
c0683ad
chore: Migrate build logic to version catalog and update submodules
JosephSanjaya Sep 24, 2025
2fcb1b2
feat(deps): add kotlin-immutable dependency
JosephSanjaya Oct 5, 2025
631b4f6
refactor(app): Relocate core module imports
JosephSanjaya Oct 8, 2025
0b46614
Merge pull request #141 from gruntsoftware/js/feat/iap
JosephSanjaya Oct 9, 2025
279fa23
build bump
kcw-grunt Oct 9, 2025
5ea5fe9
Merge branch 'main' into release/v4.8.0
kcw-grunt Oct 9, 2025
779f47f
removed cruft
kcw-grunt Oct 9, 2025
05813ad
chore(submodules): remove bugged games repository
JosephSanjaya Oct 10, 2025
67000e9
bump code
kcw-grunt Oct 10, 2025
83f1b85
Release/v4.8.0 (#147)
kcw-grunt Oct 13, 2025
798b7c9
Merge branch 'develop' of https://github.com/brainwallet-co/android i…
kcw-grunt Oct 18, 2025
d5b14db
bug(crashlytics): Remove InputWordsActivity from AndroidManifest
JosephSanjaya Oct 18, 2025
a08c6f6
fix(crashlytics): resolve ReEnterPinActivity crashes and deprecation …
JosephSanjaya Oct 22, 2025
56be50f
Remove resizability and orientation restrictions in our app (#146)
josikie Oct 22, 2025
2f06f5c
build: Build secp256k1 as a static library and add ABI splits (#149)
JosephSanjaya Nov 14, 2025
aeb5ab5
version bump (#159)
kcw-grunt Feb 7, 2026
8cabf2a
Revert "build: Build secp256k1 as a static library and add ABI splits…
kcw-grunt Feb 7, 2026
0a46627
Techdebt/adjust build logic (#161)
kcw-grunt Feb 8, 2026
5738254
Added auto translate (#178)
kcw-grunt Apr 9, 2026
25fcc5d
Add auto-translate workflow for strings.xml
kcw-grunt Apr 12, 2026
34e6d65
Create PR summary workflow with GitHub Copilot
kcw-grunt Apr 12, 2026
914bcd3
Changed the AI completions
kcw-grunt Apr 13, 2026
ca4fcd9
Add more information of the README
kcw-grunt Apr 13, 2026
12a3d83
nit fix
kcw-grunt Apr 13, 2026
5d3a6c2
πŸ¦–πŸ˜± HUGE!! Bento Integration (#192)
kcw-grunt Apr 14, 2026
010be8c
Release/v4.9.0 (#201)
kcw-grunt Apr 16, 2026
ce9d121
Feat/add thai dutch (#197)
kcw-grunt Apr 16, 2026
083027f
update gitignore (#204)
kcw-grunt Apr 17, 2026
9495b47
Add send/receive transaction integration tests (#203)
kcw-grunt Apr 18, 2026
e0b116a
Designdebt/polish main screen (#205)
kcw-grunt Apr 18, 2026
902f8fb
Feat/add gamehub minigame (#206)
kcw-grunt Apr 19, 2026
879ab6f
Moved clipboard test point into event (#207)
kcw-grunt Apr 20, 2026
334ce3b
moved out of the state update (#208)
kcw-grunt Apr 20, 2026
4455c07
Version bump
kcw-grunt Apr 20, 2026
fcc51f9
fix: issue when user tries to send (#210)
kcw-grunt Apr 22, 2026
b220d0f
reformatted the test
kcw-grunt Apr 18, 2026
5d01e5a
Added More comprehensive Send Tests to cover better stability
kcw-grunt Apr 23, 2026
2ad22d0
Add WalletManager; make validateAddress instance
kcw-grunt Apr 23, 2026
f0e16f6
Updated the InstrumentedTest
kcw-grunt Apr 23, 2026
9a88ed3
adjust the config
kcw-grunt Apr 23, 2026
a11b4db
adjust config for running
kcw-grunt Apr 23, 2026
39cb5f4
Further fix
kcw-grunt Apr 23, 2026
b981834
Fixes the bug: BreadActivity.initializeViews
kcw-grunt Apr 23, 2026
7828223
Merge branch 'main' into release/v4.9.1
kcw-grunt Apr 24, 2026
0dde01c
version bump
kcw-grunt Apr 24, 2026
84da88e
add notify script
kcw-grunt Apr 24, 2026
f9d187b
updated README
kcw-grunt Apr 24, 2026
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
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ jobs:
unit-test:
executor:
name: android/android_docker
resource_class: large
tag: 2024.07.1-ndk
resource_class: large
environment:
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2"
steps:
- setup_environment
- run:
name: "Execute Unit Tests"
command: ./gradlew testBrainwalletDebugUnitTest --no-daemon --max-workers=2 -Dorg.gradle.jvmargs="-Xmx8g" -Dkotlin.compiler.execution.strategy=in-process
command: ./gradlew testBrainwalletDebugUnitTest --no-daemon --max-workers=2
- android/save_gradle_cache
- run:
name: Save test results
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/auto-translate.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Auto-Translate strings.xml

name: πŸ‡§πŸ‡· πŸ‡³πŸ‡± πŸ‡ΉπŸ‡­ Auto-Translate strings.xml
on:
push:
branches:
Expand Down Expand Up @@ -51,7 +50,8 @@ jobs:
git checkout -b "$BRANCH"
git add app/src/main/res/values-*/strings.xml
git commit -m "chore(i18n): auto-translate missing strings [skip ci]
Languages updated: ar, zh-rTW, zh-rCN, fr, de, fa, pa, pl, in, es, sv, uk, ru, tr, ja, ko, hi, it, pt-rBR

Languages updated: ar, de, es, fa, fr, hi, in, it, ja, ko, nl, pa, pl, pt-rBR, ru, sv, th, tr, uk, zh-rCN, zh-rTW
Triggered by: ${{ github.sha }}
"
git push origin "$BRANCH"
Expand All @@ -63,7 +63,7 @@ jobs:
gh pr create \
--title "🌍 Auto-translations: missing strings updated" \
--body "$(cat /tmp/pr_body.md)" \
--base main \
--base develop \
--head "$BRANCH" \
--label "translations" \
--reviewer "${{ github.actor }}"
27 changes: 27 additions & 0 deletions .github/workflows/notify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Notify Mirror on PR

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
trigger-mirror:
runs-on: ubuntu-latest
steps:
- name: Trigger mirror workflow
uses: actions/github-script@v7
with:
github-token: ${{ secrets.MIRROR_REPO_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'gruntsoftware',
repo: 'brainwallet-android',
workflow_id: 'sync.yml',
ref: 'main',
inputs: {
source: '${{ github.event.repository.name }}',
pr_number: '${{ github.event.pull_request.number }}',
pr_title: '${{ github.event.pull_request.title }}',
branch: '${{ github.head_ref }}'
}
})
2 changes: 1 addition & 1 deletion .github/workflows/pr-summary-copilot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: πŸ€– Copilot PR Summary

on:
pull_request:
types: [opened, synchronize, reopened]
types: [opened, reopened]
branches:
- develop
- main
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ app/src/.DS_Store
/app/src/main/assets/service-data.json
/app/src/main/assets/canary-file.json
service-data.json
canary-file.json
canary-file.json

# Claude
.claude/
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,46 @@ The open source code of Brainwallet Android

**develop**: [![CircleCI](https://dl.circleci.com/status-badge/img/gh/gruntsoftware/android/tree/develop.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/gruntsoftware/android/tree/develop)

## Release Notes
### v4.8.3

# πŸš€ Brainwallet Android β€” Release Notes
### v4.9.0

### ✨ New Features

#### πŸ“‹ Copy Transaction Details to Clipboard
Transaction details can now be copied directly to the clipboard from the transaction detail view. A new `BRClipboardManager.putDetailsClipboard()` method handles the copy action with full analytics tracking, making it easy to share or reference transaction information outside the app.

#### πŸ“Š Analytics Tracking for Key Interactions
Firebase analytics events are now fired for core user interactions β€” fiat/LTC toggle, balance visibility toggle, and transaction detail copy β€” giving the team better insight into how users engage with the wallet's main screens.

---

### 🎨 UI / Design System

#### 🧱 Unified `bentoSurface` Design System
A new `bentoSurface()` modifier in `BentoModifiers.kt` consolidates gradient and border styling across the entire bento UI. Previously hardcoded values like `1.dp` borders are now driven by shared constants (`bentoBorderWidth`, `bentoCornerRadius`, `bentoCornerRadius`, `bentoSpacer`, `transactionActionHt`, `transactionDetailHt`), making the visual system consistent and easy to maintain going forward.

#### πŸƒ Bento Section Refactors
- **GameHub** β€” migrated from `Card` to `Box` with `bentoSurface()`, with a `clickable` modifier added
- **Favourites** β€” refactored to `bentoSurface()` with improved `Spacer` layout
- **LTC Picker** β€” label repositioned to top, spacing and item heights adjusted
- **Transactions** β€” `TransactionFilter`, `TransactionsBentoScreen`, `ConfirmationStatus`, `CopyTransactionWidget`, `ExportTransactionsWidget`, `NoTxRow`, `TransactionDetail`, `TransactionFilterWidget`, `TransactionRow` all updated to unified styling
- **Tutorials & Bottom Nav Bar** β€” updated to use unified theme system

---

### πŸ”§ Technical Changes
- `MainScreen`, `MainScreenEvent`, and `MainViewModel` updated for new event handling and state management
- `NoWifiBalanceAlertScreen` and `ReceiveDialog` border widths replaced with `bentoBorderWidth` constant
- `strings.xml` updated with new/updated string resources
- `gradle/libs.versions.toml` and `app/build.gradle.kts` dependencies updated
- `detekt-app-baseline.xml` baseline updated
- Version bumped: **v4.8.4 (202506314) β†’ v4.9.0 (202506315)**
- Release/v4.7.2 202506296 by @kcw-grunt in https://github.com/gruntsoftware/android/pull/134
- Release/v4.8.0 by @kcw-grunt in https://github.com/gruntsoftware/android/pull/145

**Full Changelog**: https://github.com/gruntsoftware/android/compare/v4.7.2...v4.9.0
### v4.8.3

## ✨ New UI β€” Favourites & Tutorials Bento Sections
**PR [#191](https://github.com/gruntsoftware/android/pull/191)**
Expand Down
2 changes: 1 addition & 1 deletion android-build-logic
26 changes: 22 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
import org.gradle.kotlin.dsl.androidTestImplementation
import org.gradle.kotlin.dsl.grunt

plugins {
Expand Down Expand Up @@ -34,8 +35,8 @@ android {
applicationId = "ltd.grunt.brainwallet"
minSdk = 29
targetSdk = 35
versionCode = 202506315
versionName = "v4.9.0"
versionCode = 202506323
versionName = "v4.9.1"
multiDexEnabled = true
base.archivesName.set("${defaultConfig.versionName}(${defaultConfig.versionCode})")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -179,9 +180,18 @@ android {
packaging {
resources {
pickFirsts.add("protobuf.meta")
excludes += setOf(
"META-INF/LICENSE.md",
"META-INF/LICENSE-notice.md",
"META-INF/NOTICE.md",
"META-INF/NOTICE",
"META-INF/LICENSE"
)
}
}

testFixtures {
enable = true
}
//TODO: rename output apk/bundle
}

Expand All @@ -190,6 +200,8 @@ dependencies {
implementation(project(":iap"))
implementation(project(":core"))
implementation("androidx.webkit:webkit:1.9.0")
testImplementation(testFixtures(project(":app")))
androidTestImplementation(testFixtures(project(":app")))
implementation(grunt.androidx.core.ktx)
implementation(grunt.app.startup)
implementation(libs.androidx.appcompat)
Expand Down Expand Up @@ -218,7 +230,6 @@ dependencies {
implementation(libs.bundles.google.play.review)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.coroutines.android)
implementation (libs.airbnb.lottie.compose)
implementation(platform(grunt.koin.bom))
implementation(grunt.bundles.koin)
implementation(platform(grunt.koin.annotation.bom))
Expand All @@ -229,6 +240,7 @@ dependencies {
implementation(libs.androidx.runtime)
implementation(libs.androidx.foundation)
implementation(libs.androidx.animation)
implementation(libs.play.services.games)
ksp(grunt.koin.annotation.compiler)
implementation(platform(libs.squareup.okhttp.bom))
implementation(libs.bundles.squareup.okhttp)
Expand Down Expand Up @@ -259,8 +271,14 @@ dependencies {
androidTestImplementation(libs.bundles.android.test)
androidTestImplementation(libs.fastlane.screengrab)
androidTestImplementation(libs.slf4j.android)
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test:runner:1.5.2")
androidTestImplementation("androidx.test:rules:1.5.0")
androidTestImplementation("io.mockk:mockk-android:1.13.8")
androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
}

tasks.withType<Test> {
jvmArgs("-XX:+EnableDynamicAgentLoading")
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package com.brainwallet.ui.screens.send

import android.content.Context
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import com.brainwallet.presenter.entities.TransactionItem
import com.brainwallet.tools.security.PostAuth
import com.brainwallet.wallet.BRWalletManager
import io.mockk.mockk
import junit.framework.TestCase.assertFalse
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Assume.assumeTrue
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.assertNotNull
import org.junit.runner.RunWith
import kotlin.test.DefaultAsserter.assertTrue

/**
* Instrumentation tests that exercise [BWSender] against the REAL
* [com.brainwallet.wallet.BRWalletManager] JNI layer. These are the only way to catch regressions in
* the native boundary β€” MockK cannot stub native methods on the JVM.
*
* Run on an emulator/device where libcore.so and libbreadwallet.so are loaded.
*
* NOTE: These tests assume a wallet has been initialised by the test runner or
* a prior setup step. They `assumeTrue(isCreated)` so they are safely skipped
* on fresh installs rather than failing spuriously.
*/
@LargeTest
@OptIn(ExperimentalCoroutinesApi::class)
@RunWith(AndroidJUnit4::class)
class SendInstrumentationTest {

private lateinit var context: Context
private lateinit var walletManager: BRWalletManager

@Before
fun setUp() {
context = ApplicationProvider.getApplicationContext()
walletManager = BRWalletManager.getInstance()
}

@Before
fun loadNativeLibrary() {
System.loadLibrary("core-lib")
}

// -------------------------------------------------------------------------
// Native address validation β€” the regression that crashed production
// -------------------------------------------------------------------------

@Test
fun validateAddress_acceptsKnownGoodLitecoinAddress() {
// Litecoin P2PKH sample address (starts with L).
val addr = "LcWHwzZitnqQsXwi6UScRjtjDFYjR7t24t"
assertTrue(
"Native validator must accept canonical L-prefix addresses",
BRWalletManager.getInstance().validateAddress(addr)
)
}

@Test
fun validateAddress_rejectsEmptyString() {
assertFalse(BRWalletManager.getInstance().validateAddress(""))
}

@Test
fun validateAddress_rejectsGarbage() {
assertFalse(BRWalletManager.getInstance().validateAddress("not-a-real-address"))
}

@Test
fun validateAddress_rejectsBitcoinAddress() {
// Bitcoin address should be rejected by a Litecoin wallet.
assertFalse(
BRWalletManager.getInstance().validateAddress("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa")
)
}

// -------------------------------------------------------------------------
// BWSender through the real JNI layer
// -------------------------------------------------------------------------

@Test
fun bwSender_withRealWalletManager_handlesNullTransactionGracefully() = runTest {
assumeTrue("Skipping β€” wallet not created on this device", walletManager.isCreated())

val postAuth = mockk<PostAuth>(relaxed = true)
val sender = BWSender(
context = context,
getWalletManager = { walletManager },
getPostAuth = { postAuth }
)

// Send to an invalid address so the native method returns null rather
// than throwing β€” this is the real-world failure mode that previously
// locked the Send button.
val tx = TransactionItem(
"LhK2kQwiaAvhjWY799cZvMyYwnQAcxkarr",
"LOpsAddrInvalid",
null,
/* sendAmount = */
1L,
/* opsFee = */
0L,
null,
false,
""
)

val result = sender.prepareTransaction(tx)

// Either AmountTooSmall or Unknown is acceptable here β€” what matters is
// that isSending is reset and the app is not permanently locked.
assertNotNull(result)
assertFalse(
"isSending must not leak through real-JNI error paths",
sender.isSending
)
}

@Test
fun bwSender_reentrancyGuard_holdsAgainstRealWallet() = runTest {
assumeTrue(walletManager.isCreated())

val postAuth = mockk<PostAuth>(relaxed = true)
val sender = BWSender(
context = context,
getWalletManager = { walletManager },
getPostAuth = { postAuth }
)

sender.isSending = true
val result = sender.prepareTransaction(buildDummyTx())

assert(result is BWSendResult.Error.AlreadySending)
}

// -------------------------------------------------------------------------
// Balance read β€” driven through getBalance which is used by SendViewModel
// to decide isAmountBelowBalance. A zero/stale read is the "Send stays
// disabled" production symptom.
// -------------------------------------------------------------------------

@Test
fun getBalance_returnsNonNegativeValue() {
val balance = BRWalletManager.getInstance().getBalance(context)
assertTrue("Balance must never go negative", balance >= 0)
}

private fun buildDummyTx() = TransactionItem(
"LhK2kQwiaAvhjWY799cZvMyYwnQAcxkarr",
"LOpsAddr",
null,
100_000L,
500L,
null,
false,
""
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.brainwallet.wallet

class FakeWalletManager(
private val created: Boolean = true,
private val addressValid: Boolean = true
) : WalletManager {
override fun isCreated() = created
override fun validateAddress(address: String) = addressValid
}
Loading
Loading