android: saved-wallets screen (list, select, back up the open wallet)
All checks were successful
android-ci / android (pull_request) Successful in 10m37s
All checks were successful
android-ci / android (pull_request) Successful in 10m37s
The app could hold several wallets and show none of them. Add the screen
that lists the store's catalogue, marks the one the wallet child has open,
switches to another on a tap, and — for the open one only — shows its
recovery phrase and private keys.
Everything secret here belongs to the file the child currently has open:
`query_key` is answered by that file and no other, so the seed card and the
keys card hang off `active_wallet_filename()`, not off a row. On a row that
is not the open one both actions are dead and say why ("open this wallet to
view its backup") instead of opening it under the user — switching wallets
is a deliberate tap, because `open_wallet` stops and restarts a running
child.
The phrase keeps the existing treatment: the wallet screen's own
`SeedBackupCard`, widened from `private` to `internal` rather than copied,
so the gate constants are still the one `SeedBackupGate`. The keys card
shows the view key always and the spend key when there is one; a view-only
wallet says "view-only wallet — no spend key" in words, because `null` is
the wallet's own answer and not a failure. Neither value is logged,
persisted, tagged, or held in saved state, and both are dropped on dispose.
The catalogue is re-read on entry and on Refresh, never cached from app
start, so a wallet created on the wallet screen after this one was first
opened shows up without restarting the app. An empty catalogue ("No saved
wallets yet") and a read failure ("could not read the wallet catalogue" +
the core's text) are rendered as the two different states they are.
The gate is pure Kotlin in the new file and `WalletManagerTest` covers it on
the JVM (17 cases): the row label's name/blank/whitespace fallback, which
child states count as readable, and whether the secret actions are offered
for a row.
This commit is contained in:
parent
573bf4bf8d
commit
812c259f46
5 changed files with 806 additions and 2 deletions
|
|
@ -41,6 +41,8 @@ import uniffi.onionwire_sdk.RotateOutcome
|
|||
import uniffi.onionwire_sdk.SendState
|
||||
import uniffi.onionwire_sdk.TransferRow
|
||||
import uniffi.onionwire_sdk.WalletChildStatus
|
||||
import uniffi.onionwire_sdk.WalletKeys
|
||||
import uniffi.onionwire_sdk.WalletRow
|
||||
import uniffi.onionwire_sdk.Wire
|
||||
import uniffi.onionwire_sdk.decodeInvite
|
||||
import java.io.File
|
||||
|
|
@ -619,6 +621,50 @@ class WireViewModel(app: Application) : AndroidViewModel(app) {
|
|||
suspend fun walletSeed(): Result<String> =
|
||||
runCatching { requireWire().walletSeed() }
|
||||
|
||||
// --- Wallet catalogue, the open wallet, and its secrets ----------------
|
||||
// The saved-wallets screen's reads. The catalogue is a store read that
|
||||
// never dials, so it goes to [Dispatchers.IO] like the other store reads in
|
||||
// this file — a SQLCipher decrypt on the main thread is an ANR waiting for a
|
||||
// slow device.
|
||||
|
||||
/**
|
||||
* Every wallet this install remembers, oldest first.
|
||||
*
|
||||
* A store read: it works with the wallet child stopped or never configured,
|
||||
* and "no wallets" is an empty list rather than a failure — the caller must
|
||||
* not render the two alike.
|
||||
*/
|
||||
suspend fun wallets(): Result<List<WalletRow>> =
|
||||
withContext(Dispatchers.IO) { runCatching { requireWire().wallets() } }
|
||||
|
||||
/**
|
||||
* The file name of the wallet the child currently has open, or null when it
|
||||
* has none. The catalogue's in-use marker is this and nothing else.
|
||||
*/
|
||||
suspend fun activeWalletFilename(): Result<String?> =
|
||||
withContext(Dispatchers.IO) { runCatching { requireWire().activeWalletFilename() } }
|
||||
|
||||
/**
|
||||
* Point the wallet child at a catalogue wallet's file.
|
||||
*
|
||||
* Slow on purpose: a live child is stopped and started again onto the new
|
||||
* file. The core refuses a name the catalogue does not hold, and that
|
||||
* refusal is surfaced verbatim to the caller.
|
||||
*/
|
||||
suspend fun openWallet(filename: String): Result<Unit> =
|
||||
withContext(Dispatchers.IO) { runCatching { requireWire().openWallet(filename) } }
|
||||
|
||||
/**
|
||||
* The **open** wallet's private keys, for the saved-wallets screen.
|
||||
*
|
||||
* Both values are spend secrets: only ever called from an explicit tap,
|
||||
* never logged, never persisted, and dropped when the screen goes. There is
|
||||
* deliberately no accessor for another catalogue row's keys — the only way
|
||||
* to read a saved wallet's keys is to open it first.
|
||||
*/
|
||||
suspend fun walletKeys(): Result<WalletKeys> =
|
||||
withContext(Dispatchers.IO) { runCatching { requireWire().walletKeys() } }
|
||||
|
||||
fun spendAuthorityWarning(): String = runCatching {
|
||||
requireWire().spendAuthorityWarning()
|
||||
}.getOrElse {
|
||||
|
|
|
|||
Loading…
Reference in a new issue