android: block the wallet screen on an unbacked seed, and let it be re-shown #139

Merged
sirius merged 1 commit from onionwire/t_9b2544a7-wallet-screen-block-on-an-unbacked-seed into main 2026-09-20 16:14:30 +00:00
Owner

What

Make the seed backup impossible to miss on Android, and make it recoverable afterwards.

A created wallet's seed was two lines of small text at the bottom of the wallet page, dismissed by one tap, gone for good once the screen was left. A real user created a wallet, never saw the seed, and the app had no way to show it again.

Changes

  • ui/SeedBackupGate.kt (new) — the gate as pure Kotlin: the confirm word is SEEN, matched case-insensitively and trimmed, mirroring src/tui.rs WalletSetup::CreateSeed (eq_ignore_ascii_case("SEEN")) rather than inventing a second word. Create starts unbacked, import is backed up without the gate, and only a correct word can confirm — a wrong word can never un-confirm.
  • ui/WalletScreen.kt — the seed card is the whole body of the screen until the word is typed and Done is tapped: no Cancel, and Done is dead until the word matches. No copy button, on purpose: the Android clipboard is readable by every other app (and by clipboard history on 13+), which would hand the spend key to whoever asks for it next.
  • Back up seed re-reads the seed through the parent card's Wire::wallet_seed() (WireViewModel.walletSeed()), so a seed missed the first time is not lost. The strip carries the button while the seed is unconfirmed, the actions row carries it afterwards, so exactly one is ever on screen. A failed read is shown next to the button rather than at the bottom of a long scroll.
  • Persistent unbacked state — while unconfirmed, a warning strip stays at the top of the wallet screen and the receive address and Show QR are hidden: XMR received into a wallet whose 25 words were never written down is unrecoverable.
  • WireViewModel.kt — the flag lives in app-local prefs (wallet_seed_backup, a plain boolean; not the Keystore-wrapped store, which holds the passphrase only). createWallet resets it to unbacked itself, so no caller can forget. importWallet marks backed up.

Decisions a reviewer should see

  • The stored flag is nullable, and the null is load-bearing. false means this install created a wallet and nobody has confirmed the seed, so the strip is up whether or not the balance reads. null means nothing is stored — an install that predates the flag, or one that has never created a wallet here — and there the strip waits for wallet_balance to return a real amount, the core's own evidence that the child has a wallet open. Without that distinction, a first-run user who had configured a chain source but not yet created a wallet would be warned about a seed they do not have: wallet_balance returns "err" for a configured chain whose child has no wallet open, and the daemon card's Save is enough to reach that state.
  • The app-bar Back still leaves the screen. That is the TUI's Esc, and it costs nothing now: leaving no longer loses the seed. The wallet stays unbacked — strip up, address hidden — until Back up seed puts the card back on screen. The card itself is what cannot be dismissed: it has no Cancel and its Done is dead until SEEN.
  • The seed is a Kotlin String, so it cannot be wiped in place the way the TUI's Zeroizing<String> is. Dropping the reference is the strongest thing available; it is never persisted and never logged.

Scope

Only the four files the card allows. No build.gradle.kts change, no new dependency, nothing under src/, crates/, android/sdk/, docs/ or .forgejo/.

Base

main. This started stacked on #138 (wallet: expose an on-demand seed accessor over core + UniFFI), because :app could not compile against walletSeed() until that landed; #138 is now merged (94d29b8), and this branch has been rebased onto main, so the diff is the four files below and nothing else.

Verification

cd android && ./gradlew :app:testDebugUnitTest — 135 tests, 0 failures (SeedBackupGateTest: 18), run with -x :sdk:cargoBuildAndroid -x :sdk:cargoHostLib -x :sdk:uniffiBindgen -x :sdk:verifyDynamicLibc after :sdk:uniffiBindgen had generated the Kotlin for this branch.

android-ci.yml matches android/**, so this PR builds the debug-signed APK + AAR; the run URL is in the task thread.

## What Make the seed backup impossible to miss on Android, and make it recoverable afterwards. A created wallet's seed was two lines of small text at the bottom of the wallet page, dismissed by one tap, gone for good once the screen was left. A real user created a wallet, never saw the seed, and the app had no way to show it again. ## Changes - **`ui/SeedBackupGate.kt` (new)** — the gate as pure Kotlin: the confirm word is `SEEN`, matched case-insensitively and trimmed, mirroring `src/tui.rs` `WalletSetup::CreateSeed` (`eq_ignore_ascii_case("SEEN")`) rather than inventing a second word. Create starts unbacked, import is backed up without the gate, and only a correct word can confirm — a wrong word can never un-confirm. - **`ui/WalletScreen.kt`** — the seed card is the whole body of the screen until the word is typed and Done is tapped: no Cancel, and Done is dead until the word matches. No copy button, on purpose: the Android clipboard is readable by every other app (and by clipboard history on 13+), which would hand the spend key to whoever asks for it next. - **`Back up seed`** re-reads the seed through the parent card's `Wire::wallet_seed()` (`WireViewModel.walletSeed()`), so a seed missed the first time is not lost. The strip carries the button while the seed is unconfirmed, the actions row carries it afterwards, so exactly one is ever on screen. A failed read is shown next to the button rather than at the bottom of a long scroll. - **Persistent unbacked state** — while unconfirmed, a warning strip stays at the top of the wallet screen and the receive address and `Show QR` are hidden: XMR received into a wallet whose 25 words were never written down is unrecoverable. - **`WireViewModel.kt`** — the flag lives in app-local prefs (`wallet_seed_backup`, a plain boolean; not the Keystore-wrapped store, which holds the passphrase only). `createWallet` resets it to unbacked itself, so no caller can forget. `importWallet` marks backed up. ## Decisions a reviewer should see - **The stored flag is nullable, and the null is load-bearing.** `false` means *this install created a wallet and nobody has confirmed the seed*, so the strip is up whether or not the balance reads. `null` means *nothing is stored* — an install that predates the flag, or one that has never created a wallet here — and there the strip waits for `wallet_balance` to return a real amount, the core's own evidence that the child has a wallet open. Without that distinction, a first-run user who had configured a chain source but not yet created a wallet would be warned about a seed they do not have: `wallet_balance` returns `"err"` for a configured chain whose child has no wallet open, and the daemon card's Save is enough to reach that state. - **The app-bar `Back` still leaves the screen.** That is the TUI's `Esc`, and it costs nothing now: leaving no longer loses the seed. The wallet stays unbacked — strip up, address hidden — until `Back up seed` puts the card back on screen. The card itself is what cannot be dismissed: it has no Cancel and its Done is dead until `SEEN`. - The seed is a Kotlin `String`, so it cannot be wiped in place the way the TUI's `Zeroizing<String>` is. Dropping the reference is the strongest thing available; it is never persisted and never logged. ## Scope Only the four files the card allows. No `build.gradle.kts` change, no new dependency, nothing under `src/`, `crates/`, `android/sdk/`, `docs/` or `.forgejo/`. ## Base `main`. This started stacked on #138 (`wallet: expose an on-demand seed accessor over core + UniFFI`), because `:app` could not compile against `walletSeed()` until that landed; #138 is now merged (`94d29b8`), and this branch has been rebased onto `main`, so the diff is the four files below and nothing else. ## Verification `cd android && ./gradlew :app:testDebugUnitTest` — **135 tests, 0 failures** (`SeedBackupGateTest`: 18), run with `-x :sdk:cargoBuildAndroid -x :sdk:cargoHostLib -x :sdk:uniffiBindgen -x :sdk:verifyDynamicLibc` after `:sdk:uniffiBindgen` had generated the Kotlin for this branch. `android-ci.yml` matches `android/**`, so this PR builds the debug-signed APK + AAR; the run URL is in the task thread.
android: block the wallet screen on an unbacked seed, and make it re-showable
All checks were successful
android-ci / android (pull_request) Successful in 10m39s
3431a9eda9
A created wallet's seed was two lines of small text at the bottom of the
wallet page, dismissed by one tap, gone for good once the screen was left.
A real user created a wallet, never saw the seed, and the app had no way to
show it again.

- `SeedBackupGate` (new, pure Kotlin): the confirm word `SEEN` and its
  case-insensitive match mirror the TUI's own `WalletSetup::CreateSeed`
  gate; create starts unbacked, import is backed up without the gate, and
  only a correct word can confirm.
- The seed card is the whole body until the word is typed and Done is
  tapped: no Cancel, no copy button (the Android clipboard is readable by
  every other app), Done dead until `SEEN`.
- "Back up seed" re-reads the seed through the new `Wire::wallet_seed()`
  (`WireViewModel.walletSeed()`), so a seed missed the first time is not
  lost. Its failure is shown next to the button, not at the bottom of a
  long scroll.
- While unconfirmed: a warning strip stays at the top of the wallet screen
  and the receive address and Show QR are hidden — XMR received into a
  wallet whose 25 words were never written down is unrecoverable.
- The flag lives in app-local prefs (`wallet_seed_backup`), not in the
  Keystore-wrapped store, and is reset by `createWallet` itself so no
  caller can forget it. An install that predates the flag reads as
  unconfirmed: "we never asked" is not "the user wrote it down", and
  "Back up seed" is the way out.

The app-bar Back still leaves the screen, deliberately — it is the TUI's
`Esc`. It costs nothing now, because leaving no longer loses the seed.

Verification: `./gradlew :app:testDebugUnitTest` green, 132 tests
(`SeedBackupGateTest` 15 of them).
sirius force-pushed onionwire/t_9b2544a7-wallet-screen-block-on-an-unbacked-seed from 3431a9eda9
All checks were successful
android-ci / android (pull_request) Successful in 10m39s
to 3bcbe3556c
All checks were successful
android-ci / android (pull_request) Successful in 10m39s
2026-09-20 16:13:02 +00:00
Compare
sirius force-pushed onionwire/t_9b2544a7-wallet-screen-block-on-an-unbacked-seed from 3bcbe3556c
All checks were successful
android-ci / android (pull_request) Successful in 10m39s
to 118191c541
All checks were successful
android-ci / android (pull_request) Successful in 10m35s
2026-09-20 16:14:04 +00:00
Compare
sirius changed target branch from onionwire/t_2142490d-wallet-seed-expose-an-on-demand-seed-acc to main 2026-09-20 16:14:19 +00:00
sirius merged commit 2256d036d5 into main 2026-09-20 16:14:30 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!139
No description provided.