ui: saved-wallets screen and profile copy on the shared components (plan P4.1)
All checks were successful
android-ci / android (pull_request) Successful in 14m2s

The catalogue screen was still the alpha build: a TopAppBar with a text "Back"
and a text "Refresh", eight hand-rolled Cards on Material's surfaceVariant,
outlined twins for the two secret actions, and every failure — including "no
wallet is open", which is a state the app is in, not a failure — printed as a
raw red Text. It now uses the shared components: a chevron top bar, OwCard rows
with an "In use" pill, and OwButton tiers.

Copy, verbatim from the plan:

  "No wallet is open in the wallet child yet. Open a saved wallet on the Saved
   wallets screen, or create or import one here."
      -> "Select a saved wallet or create a new one to view your balance and
         transact."

  "No wallet is open in the wallet child yet. Open one from the list below — a
   wallet that needs a passphrase asks for it here — and the balance, address
   and backups work again."
      -> "Open or create a wallet to enable balance, address, and backup
         controls."

WALLET_NOT_OPEN_TEXT is now rendered as an info banner with its own title, not
as an error; ErrorText picks the variant from the text, so the same string
cannot read as a crash on one screen and a state on the other. The "no wallet
open" hint, the passphrase prompt's blocked reasons and its "wallet is not
running" line, and the catalogue/keys failures are banners too.

The two remaining user-facing mentions of the daemon process are gone: the
passphrase card says "the wallet is pointed at <file>" and the secrets block
reason says "the wallet is not running". ProfileScreen's empty-address notice
loses its copy of the same phrase ("then comes from the running wallet"), and
its test now asserts the consequence instead of the internal name.

No behaviour change: every predicate (walletSecretsEnabled,
walletPassphraseSubmitEnabled, walletChildReadable, walletFailureText,
displayLastError) is the same function with the same branches; only strings and
layout moved. The four WalletManagerTest assertions that pinned the old strings
are updated here, in the same commit, as the card requires.
This commit is contained in:
agent 2026-10-29 01:01:45 -04:00
commit 0d0b0b975d
No known key found for this signature in database
4 changed files with 265 additions and 258 deletions

View file

@ -56,7 +56,7 @@ import uniffi.onionwire_sdk.checkAddress
* store error after it. * store error after it.
* - An **empty** address is a real, allowed value: it clears the profile * - An **empty** address is a real, allowed value: it clears the profile
* address. It is labelled with its consequence, because with no profile * address. It is labelled with its consequence, because with no profile
* address and no running wallet child the core has nothing to hand a payer * address and no running wallet the core has nothing to hand a payer
* (`Node::wallet_receive_address`) and the invoice path fails. * (`Node::wallet_receive_address`) and the invoice path fails.
* - The bio is carried, not owned: a save that did not touch the bio field * - The bio is carried, not owned: a save that did not touch the bio field
* writes back the value read from the store immediately before the write, so * writes back the value read from the store immediately before the write, so
@ -211,7 +211,7 @@ fun ProfileScreen(
supportingText = { supportingText = {
Text( Text(
// The consequence, on the screen, before a payment fails: // The consequence, on the screen, before a payment fails:
// `Node::wallet_receive_address` uses the wallet child's // `Node::wallet_receive_address` uses the wallet process's
// subaddress while it is up and this address otherwise, // subaddress while it is up and this address otherwise,
// and with neither there is nothing to be paid to. // and with neither there is nothing to be paid to.
profileAddressNotice(form.address), profileAddressNotice(form.address),
@ -437,7 +437,7 @@ internal const val PROFILE_SAVED: String = "profile saved"
/** /**
* What an empty address means, stated where the address is typed. * What an empty address means, stated where the address is typed.
* *
* `Node::wallet_receive_address` answers with the wallet child's own subaddress * `Node::wallet_receive_address` answers with the wallet process's own subaddress
* while it is up, and this address otherwise; with neither, the invoice path * while it is up, and this address otherwise; with neither, the invoice path
* fails outright. The user should read that here, not after a friend's payment * fails outright. The user should read that here, not after a friend's payment
* bounces. * bounces.
@ -445,7 +445,7 @@ internal const val PROFILE_SAVED: String = "profile saved"
internal fun profileAddressNotice(address: String): String = internal fun profileAddressNotice(address: String): String =
if (address.trim().isEmpty()) { if (address.trim().isEmpty()) {
"Empty is allowed, and it clears the profile address. Your receive address " + "Empty is allowed, and it clears the profile address. Your receive address " +
"then comes from the wallet child while it is running — with no address " + "then comes from the running wallet — with no address " +
"here and no wallet running, nobody can send you an invoice." "here and no wallet running, nobody can send you an invoice."
} else { } else {
"What friends pay to. Validated before it is saved; an invalid address is " + "What friends pay to. Validated before it is saved; an invalid address is " +

View file

@ -14,20 +14,13 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
@ -40,11 +33,21 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalView import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.testTag import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.siriusdevops.onionwire.WireViewModel import com.siriusdevops.onionwire.WireViewModel
import com.siriusdevops.onionwire.ui.components.Label
import com.siriusdevops.onionwire.ui.components.Mono
import com.siriusdevops.onionwire.ui.components.OwAlertBanner
import com.siriusdevops.onionwire.ui.components.OwAlertVariant
import com.siriusdevops.onionwire.ui.components.OwButton
import com.siriusdevops.onionwire.ui.components.OwButtonRow
import com.siriusdevops.onionwire.ui.components.OwButtonVariant
import com.siriusdevops.onionwire.ui.components.OwCard
import com.siriusdevops.onionwire.ui.components.OwPill
import com.siriusdevops.onionwire.ui.components.OwSectionTitle
import com.siriusdevops.onionwire.ui.components.OwTopBar
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import uniffi.onionwire_sdk.WalletKeys import uniffi.onionwire_sdk.WalletKeys
import uniffi.onionwire_sdk.WalletRow import uniffi.onionwire_sdk.WalletRow
@ -83,7 +86,7 @@ internal fun walletRowDate(createdAt: Long): String {
} }
/** /**
* Whether the wallet child has a wallet open that the RPC answers for. * Whether the wallet process has a wallet open that the RPC answers for.
* *
* The core's `state` is the only honest signal available here: `connecting` * The core's `state` is the only honest signal available here: `connecting`
* means its wallet RPC has not answered, `off`/`exited` mean there is no child * means its wallet RPC has not answered, `off`/`exited` mean there is no child
@ -126,8 +129,8 @@ internal fun walletSecretsBlockedReason(
isActive: Boolean, isActive: Boolean,
walletReadable: Boolean, walletReadable: Boolean,
): String? = when { ): String? = when {
!isActive -> "open this wallet to view its backup" !isActive -> "Open this wallet to view its backup."
!walletReadable -> "the wallet child is not running — start it on the wallet screen to read the backup" !walletReadable -> "The wallet is not running — start it on the wallet screen to read the backup."
else -> null else -> null
} }
@ -159,14 +162,18 @@ private val RAW_RPC_CODE = Regex("""(?<![\d-])-13(?!\d)""")
*/ */
private val RAW_JSON = Regex("""[{}]|\[\s*\{|"(error|code|message|result|jsonrpc)"\s*:""") private val RAW_JSON = Regex("""[{}]|\[\s*\{|"(error|code|message|result|jsonrpc)"\s*:""")
/** Shown instead of the daemon's `-13` / `No wallet file` / JSON answer. */ /**
* Shown instead of the daemon's `-13` / `No wallet file` / JSON answer.
*
* A state the app is *in*, not a failure of the last call — the wallet screen
* renders it as an info banner, never as a red error line.
*/
const val WALLET_NOT_OPEN_TEXT: String = const val WALLET_NOT_OPEN_TEXT: String =
"No wallet is open in the wallet child yet. Open one from the list below — a wallet that " + "Open or create a wallet to enable balance, address, and backup controls."
"needs a passphrase asks for it here — and the balance, address and backups work again."
/** Shown instead of a raw JSON refusal that names no condition the user can act on. */ /** Shown instead of a raw JSON refusal that names no condition the user can act on. */
const val WALLET_DAEMON_REFUSED_TEXT: String = const val WALLET_DAEMON_REFUSED_TEXT: String =
"The wallet daemon refused that request and gave no readable reason. Check the wallet child " + "The wallet daemon refused that request and gave no readable reason. Check the wallet " +
"on the wallet screen, then try again." "on the wallet screen, then try again."
/** /**
@ -251,7 +258,7 @@ internal fun walletPassphrasePromptVisible(needsPassphrase: Boolean, walletOpen:
* A file name is required because the open is per-file (`open_wallet` on the * A file name is required because the open is per-file (`open_wallet` on the
* file the child is pointed at); a blank passphrase is refused by the core * file the child is pointed at); a blank passphrase is refused by the core
* anyway, so the button stays dead rather than round-tripping a guaranteed * anyway, so the button stays dead rather than round-tripping a guaranteed
* failure. An in-flight open is not re-submitted: it restarts the wallet child. * failure. An in-flight open is not re-submitted: it restarts the wallet process.
*/ */
internal fun walletPassphraseSubmitEnabled( internal fun walletPassphraseSubmitEnabled(
activeFilename: String?, activeFilename: String?,
@ -270,14 +277,14 @@ internal fun walletPassphraseBlockedReason(
typed: String, typed: String,
): String? = when { ): String? = when {
activeFilename == null -> activeFilename == null ->
"the wallet child is not pointed at a wallet file yet — open one from the list below" "No wallet file is open yet — open one from the list below."
typed.isEmpty() -> "type the passphrase for this wallet file" typed.isEmpty() -> "Type the passphrase for this wallet file."
else -> null else -> null
} }
/** /**
* Why the wallet child has nothing open, in this app's words — or `null` when * Why the wallet process has nothing open, in this app's words — or `null` when
* it has a wallet open, or no child is running to hold one. * it has a wallet open, or nothing is running to hold one.
* *
* A live `monero-wallet-rpc` is not a usable wallet: it starts with no wallet * A live `monero-wallet-rpc` is not a usable wallet: it starts with no wallet
* file open, and every read then answers `-13 No wallet file`. The status line * file open, and every read then answers `-13 No wallet file`. The status line
@ -294,11 +301,10 @@ internal fun walletChildOpenHint(
): String? = when { ): String? = when {
!childRunning || walletOpen -> null !childRunning || walletOpen -> null
needsPassphrase -> needsPassphrase ->
"No wallet is open in the wallet child: it needs the passphrase for the file it is " + "The wallet needs its passphrase: open it on the Saved wallets screen, where the " +
"pointed at. Open it on the Saved wallets screen, where the prompt is." "prompt is."
else -> else ->
"No wallet is open in the wallet child yet. Open a saved wallet on the Saved wallets " + "Select a saved wallet or create a new one to view your balance and transact."
"screen, or create or import one here."
} }
/** /**
@ -319,7 +325,6 @@ internal fun walletChildOpenHint(
* in saved state (`remember`, not `rememberSaveable`, and cleared on * in saved state (`remember`, not `rememberSaveable`, and cleared on
* dispose). * dispose).
*/ */
@OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun WalletManagerScreen( fun WalletManagerScreen(
vm: WireViewModel, vm: WireViewModel,
@ -503,25 +508,24 @@ fun WalletManagerScreen(
// Root owns systemBars ∪ ime, exactly as the wallet screen does (see // Root owns systemBars ∪ ime, exactly as the wallet screen does (see
// `screenContentInsets`). // `screenContentInsets`).
contentWindowInsets = WindowInsets(0, 0, 0, 0), contentWindowInsets = WindowInsets(0, 0, 0, 0),
containerColor = OwColors.Canvas,
topBar = { topBar = {
TopAppBar( OwTopBar(
title = { Text("Saved wallets") }, title = "Saved wallets",
navigationIcon = { // A pushed sub-screen, so the chevron — never the word "Back".
TextButton(onClick = onBack) { Text("Back") } onBack = onBack,
},
actions = { actions = {
TextButton( OwButton(
text = "Refresh",
variant = OwButtonVariant.Outline,
onClick = { onClick = {
scope.launch { scope.launch {
vm.refreshWalletChild() vm.refreshWalletChild()
reload() reload()
} }
}, },
) { Text("Refresh") } )
}, },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.background,
),
) )
}, },
) { pad -> ) { pad ->
@ -559,22 +563,21 @@ fun WalletManagerScreen(
) )
} }
keysError?.let { message -> keysError?.let { message ->
Card( OwAlertBanner(
variant = OwAlertVariant.Error,
title = "Could not read the open wallet's private keys",
description = message,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .padding(horizontal = 16.dp, vertical = 8.dp)
.padding(horizontal = 12.dp, vertical = 8.dp), .testTag("wallet-keys-error"),
colors = CardDefaults.cardColors( action = {
containerColor = MaterialTheme.colorScheme.errorContainer, OwButton(
), text = "Dismiss",
) { variant = OwButtonVariant.Outline,
Column(Modifier.padding(12.dp)) { onClick = { keysError = null },
Text("could not read the open wallet's private keys") )
Spacer(Modifier.height(4.dp)) },
Text(message, style = MaterialTheme.typography.bodySmall) )
Spacer(Modifier.height(8.dp))
TextButton(onClick = { keysError = null }) { Text("Dismiss") }
}
}
} }
actionError?.let { ErrorText(it) } actionError?.let { ErrorText(it) }
@ -608,46 +611,55 @@ fun WalletManagerScreen(
// A read failure is not an empty catalogue, and the two must // A read failure is not an empty catalogue, and the two must
// not read alike: one is "the store did not answer", the other // not read alike: one is "the store did not answer", the other
// is "you have no wallets yet". // is "you have no wallets yet".
listError != null -> Column(Modifier.padding(12.dp)) { listError != null -> OwAlertBanner(
Text( variant = OwAlertVariant.Error,
"could not read the wallet catalogue", title = "Could not read the wallet catalogue",
style = MaterialTheme.typography.titleSmall, description = listError ?: "",
color = MaterialTheme.colorScheme.error, modifier = Modifier
) .padding(horizontal = 16.dp, vertical = 8.dp)
Spacer(Modifier.height(4.dp)) .testTag("wallet-list-error"),
Text( action = {
listError ?: "", OwButton(
style = MaterialTheme.typography.bodySmall, text = "Retry",
color = MaterialTheme.colorScheme.error, variant = OwButtonVariant.Outline,
) onClick = { scope.launch { reload() } },
Spacer(Modifier.height(8.dp)) )
TextButton(onClick = { scope.launch { reload() } }) { Text("Retry") } },
}
listed == null -> Text(
"loading…",
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.padding(12.dp),
) )
listed.isEmpty() -> Column(Modifier.padding(12.dp)) { listed == null -> Text(
Text("No saved wallets yet", style = MaterialTheme.typography.titleSmall) "Loading…",
Spacer(Modifier.height(4.dp)) style = MaterialTheme.typography.bodyMedium,
color = OwColors.TextSecondary,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
)
listed.isEmpty() -> OwCard(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp),
) {
OwSectionTitle("No saved wallets yet")
Spacer(Modifier.height(6.dp))
Text( Text(
"Wallets this install remembers show up here. Create or import one " + "Wallets this install remembers show up here. Create or import one " +
"on the wallet screen and it appears on the next look.", "on the wallet screen and it appears on the next look.",
style = MaterialTheme.typography.bodySmall, style = MaterialTheme.typography.bodySmall,
color = OwColors.TextSecondary,
)
Spacer(Modifier.height(12.dp))
OwButton(
text = "Create or import a wallet",
variant = OwButtonVariant.Primary,
onClick = onBack,
modifier = Modifier.fillMaxWidth(),
) )
Spacer(Modifier.height(8.dp))
Button(onClick = onBack) { Text("Create or import a wallet") }
} }
else -> { else -> {
Text( Label(
"${listed.size} saved ${if (listed.size == 1) "wallet" else "wallets"}", "${listed.size} SAVED ${if (listed.size == 1) "WALLET" else "WALLETS"}",
style = MaterialTheme.typography.labelSmall, modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp),
) )
listed.forEach { row -> listed.forEach { row ->
val isActive = active != null && active == row.walletFilename val isActive = active != null && active == row.walletFilename
@ -680,7 +692,7 @@ fun WalletManagerScreen(
* and whether it is the open one. * and whether it is the open one.
* *
* The open row is not tappable. Re-opening it would stop and restart a running * The open row is not tappable. Re-opening it would stop and restart a running
* wallet child onto the file it already has open — a slow no-op whose only * wallet process onto the file it already has open — a slow no-op whose only
* effect is to make the screen look like it did something. * effect is to make the screen look like it did something.
*/ */
@Composable @Composable
@ -694,72 +706,70 @@ private fun WalletRowCard(
onShowPhrase: () -> Unit, onShowPhrase: () -> Unit,
onShowKeys: () -> Unit, onShowKeys: () -> Unit,
) { ) {
Card( OwCard(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 6.dp) .padding(horizontal = 16.dp, vertical = 6.dp)
.then(if (isActive) Modifier else Modifier.clickable(enabled = !opening, onClick = onOpen)), .then(if (isActive) Modifier else Modifier.clickable(enabled = !opening, onClick = onOpen)),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceVariant,
),
) { ) {
Column(Modifier.padding(12.dp)) { Row(
Row( Modifier.fillMaxWidth(),
Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween,
horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically,
verticalAlignment = Alignment.CenterVertically, ) {
) { Text(
Text( walletRowLabel(row.name, row.walletFilename),
walletRowLabel(row.name, row.walletFilename), style = MaterialTheme.typography.titleMedium,
style = MaterialTheme.typography.titleSmall, color = OwColors.TextPrimary,
modifier = Modifier.weight(1f),
)
Spacer(Modifier.width(8.dp))
when {
isActive -> OwPill(
text = "In use",
textColor = OwColors.Accent,
container = OwColors.InfoTint,
borderColor = OwColors.InfoBorder,
dotColor = OwColors.Accent,
) )
when { opening -> OwPill(text = "Opening…", textColor = OwColors.TextSecondary)
isActive -> Text( else -> OwPill(text = "Tap to open", textColor = OwColors.TextSecondary)
"in use",
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.primary,
)
opening -> Text(
"opening…",
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
else -> Text(
"tap to open",
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
} }
Spacer(Modifier.height(4.dp)) }
Text( Spacer(Modifier.height(8.dp))
"file ${row.walletFilename}", Label("FILE")
style = MaterialTheme.typography.bodySmall, Mono(row.walletFilename)
fontFamily = FontFamily.Monospace, Spacer(Modifier.height(4.dp))
) Text(
Text( "Created ${walletRowDate(row.createdAt)}",
"created ${walletRowDate(row.createdAt)}", style = MaterialTheme.typography.bodySmall,
style = MaterialTheme.typography.bodySmall, color = OwColors.TextSecondary,
color = MaterialTheme.colorScheme.onSurfaceVariant, )
)
Spacer(Modifier.height(8.dp)) Spacer(Modifier.height(10.dp))
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { OwButtonRow {
OutlinedButton(onClick = onShowPhrase, enabled = secretsEnabled) { OwButton(
Text("Recovery phrase") text = "Recovery phrase",
} variant = OwButtonVariant.Outline,
OutlinedButton(onClick = onShowKeys, enabled = secretsEnabled) { enabled = secretsEnabled,
Text("Private keys") onClick = onShowPhrase,
} modifier = Modifier.weight(1f),
} )
blockedReason?.let { OwButton(
Spacer(Modifier.height(4.dp)) text = "Private keys",
Text( variant = OwButtonVariant.Outline,
it, enabled = secretsEnabled,
style = MaterialTheme.typography.labelSmall, onClick = onShowKeys,
color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.weight(1f),
) )
} }
blockedReason?.let {
Spacer(Modifier.height(6.dp))
Text(
it,
style = MaterialTheme.typography.labelSmall,
color = OwColors.TextMuted,
)
} }
} }
} }
@ -774,10 +784,10 @@ private fun WalletRowCard(
* wallet file. It is never logged, never persisted, and the caller drops it when * wallet file. It is never logged, never persisted, and the caller drops it when
* the screen goes. * the screen goes.
* *
* Submit is dead while the wallet child is not running: the core verifies a * Submit is dead while the wallet is not running: the core verifies a
* passphrase against a live daemon and refuses to seal an unverified one, so a * passphrase against a live daemon and refuses to seal an unverified one, so a
* tap there could only fail. When the child *is* up — including `connecting`, * tap there could only fail. When it *is* up — including `connecting`, whose RPC
* whose RPC has not answered yet — the core restarts it onto the file with this * has not answered yet — the core restarts it onto the file with this
* passphrase, which is exactly the fix. * passphrase, which is exactly the fix.
*/ */
@Composable @Composable
@ -791,77 +801,74 @@ private fun WalletPassphraseCard(
error: String?, error: String?,
onSubmit: () -> Unit, onSubmit: () -> Unit,
) { ) {
Card( OwCard(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 8.dp) .padding(horizontal = 16.dp, vertical = 8.dp)
.testTag("wallet-passphrase-card"), .testTag("wallet-passphrase-card"),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceVariant,
),
) { ) {
Column(Modifier.padding(12.dp)) { OwSectionTitle("This wallet needs its passphrase")
Text("This wallet needs its passphrase", style = MaterialTheme.typography.titleSmall) Spacer(Modifier.height(6.dp))
Spacer(Modifier.height(4.dp)) Text(
Text( "The wallet is pointed at ${filename ?: "a wallet file"} but this install " +
"The wallet child is pointed at ${filename ?: "a wallet file"} but this install " + "holds no passphrase that opens it — the wallet was created before the " +
"holds no passphrase that opens it — the wallet was created before the " + "passphrase was stored, or on another device. Type it once: the wallet " +
"passphrase was stored, or on another device. Type it once: the wallet " + "opens, and later starts reopen it on their own.",
"opens, and later starts reopen it on their own.", style = MaterialTheme.typography.bodySmall,
style = MaterialTheme.typography.bodySmall, color = OwColors.TextSecondary,
) )
Spacer(Modifier.height(12.dp))
OutlinedTextField(
value = typed,
onValueChange = onTyped,
singleLine = true,
// Masked on screen: this string opens a spend-capable wallet.
visualTransformation = PasswordVisualTransformation(),
label = { Text("wallet passphrase") },
modifier = Modifier
.fillMaxWidth()
.testTag("wallet-passphrase-input"),
)
Spacer(Modifier.height(6.dp))
Text(
"Never copied to the clipboard, never logged, and dropped when you leave this screen.",
style = MaterialTheme.typography.labelSmall,
color = OwColors.TextSecondary,
)
if (!childRunning) {
Spacer(Modifier.height(8.dp)) Spacer(Modifier.height(8.dp))
OutlinedTextField( OwAlertBanner(
value = typed, variant = OwAlertVariant.Info,
onValueChange = onTyped, title = "The wallet is not running",
singleLine = true, description = "Start it on the wallet screen, then come back.",
// Masked on screen: this string opens a spend-capable wallet.
visualTransformation = PasswordVisualTransformation(),
label = { Text("wallet passphrase") },
modifier = Modifier
.fillMaxWidth()
.testTag("wallet-passphrase-input"),
) )
Spacer(Modifier.height(4.dp))
Text(
"Never copied to the clipboard, never logged, and dropped when you leave this screen.",
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
if (!childRunning) {
Spacer(Modifier.height(4.dp))
Text(
"the wallet child is not running — start it on the wallet screen, then come back",
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
error?.let {
Spacer(Modifier.height(6.dp))
Text(
it,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.error,
)
}
blockedReason?.let {
Spacer(Modifier.height(4.dp))
Text(
it,
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Spacer(Modifier.height(8.dp))
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
Button(
onClick = onSubmit,
enabled = childRunning &&
walletPassphraseSubmitEnabled(filename, typed, inFlight),
modifier = Modifier.testTag("wallet-passphrase-submit"),
) { Text(if (inFlight) "Opening…" else "Open this wallet") }
}
} }
error?.let {
Spacer(Modifier.height(8.dp))
OwAlertBanner(
variant = OwAlertVariant.Error,
title = "Could not open this wallet",
description = it,
)
}
blockedReason?.let {
Spacer(Modifier.height(8.dp))
OwAlertBanner(
variant = OwAlertVariant.Info,
title = "Not ready to open",
description = it,
)
}
Spacer(Modifier.height(12.dp))
OwButton(
text = if (inFlight) "Opening…" else "Open this wallet",
variant = OwButtonVariant.Primary,
enabled = childRunning && walletPassphraseSubmitEnabled(filename, typed, inFlight),
onClick = onSubmit,
modifier = Modifier
.fillMaxWidth()
.testTag("wallet-passphrase-submit"),
)
} }
} }
@ -880,64 +887,57 @@ private fun PrivateKeysCard(
warning: String, warning: String,
onDone: () -> Unit, onDone: () -> Unit,
) { ) {
Card( OwCard(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 8.dp), .padding(horizontal = 16.dp, vertical = 8.dp)
colors = CardDefaults.cardColors( .testTag("wallet-private-keys-card"),
containerColor = MaterialTheme.colorScheme.errorContainer,
),
) { ) {
Column(Modifier.padding(12.dp)) { OwSectionTitle("Private keys of the open wallet")
Text("Private keys of the open wallet", style = MaterialTheme.typography.titleSmall) Spacer(Modifier.height(6.dp))
Spacer(Modifier.height(4.dp)) Text(warning, style = MaterialTheme.typography.bodySmall, color = OwColors.Danger)
Text(warning, style = MaterialTheme.typography.bodySmall) Spacer(Modifier.height(12.dp))
Spacer(Modifier.height(8.dp)) Label("VIEW KEY")
// Mono, and deliberately no testTag: a handle on a spend secret is a
// handle an automation can read back.
Mono(keys.viewKey, modifier = Modifier.fillMaxWidth())
Spacer(Modifier.height(10.dp))
val spend = keys.spendKey
if (spend != null) {
Label("SPEND KEY")
Mono(spend, modifier = Modifier.fillMaxWidth())
} else {
Text( Text(
"view key", "View-only wallet — no spend key.",
style = MaterialTheme.typography.labelSmall, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant, color = OwColors.TextSecondary,
) )
Text(
keys.viewKey,
style = MaterialTheme.typography.bodySmall,
fontFamily = FontFamily.Monospace,
)
Spacer(Modifier.height(8.dp))
val spend = keys.spendKey
if (spend != null) {
Text(
"spend key",
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
Text(
spend,
style = MaterialTheme.typography.bodySmall,
fontFamily = FontFamily.Monospace,
)
} else {
Text(
"view-only wallet — no spend key",
style = MaterialTheme.typography.bodyMedium,
)
}
Spacer(Modifier.height(8.dp))
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
Button(onClick = onDone) { Text("Done") }
}
} }
Spacer(Modifier.height(12.dp))
OwButton(
text = "Done",
variant = OwButtonVariant.Outline,
onClick = onDone,
modifier = Modifier.fillMaxWidth(),
)
} }
} }
/** A display-ready failure line. Never carries a secret; callers pass errors. */ /**
* A display-ready failure line, as a banner. Never carries a secret; callers
* pass errors.
*
* "No wallet is open" is not a failure — it is a state the app is in, and it
* gets the info banner and its own title. Only a real refusal is red.
*/
@Composable @Composable
private fun ErrorText(text: String) { private fun ErrorText(text: String) {
Text( val notOpen = text == WALLET_NOT_OPEN_TEXT
text, OwAlertBanner(
style = MaterialTheme.typography.bodySmall, variant = if (notOpen) OwAlertVariant.Info else OwAlertVariant.Error,
color = MaterialTheme.colorScheme.error, title = if (notOpen) "No wallet open" else "Something went wrong",
modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp), description = text,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
) )
} }

View file

@ -239,7 +239,9 @@ class ProfileDraftTest {
fun an_empty_address_says_nobody_can_pay() { fun an_empty_address_says_nobody_can_pay() {
val text = profileAddressNotice("") val text = profileAddressNotice("")
assertTrue(text.contains("clears the profile address")) assertTrue(text.contains("clears the profile address"))
assertTrue(text.contains("wallet child")) // The consequence, not the process name: the copy no longer says
// "wallet child" anywhere a user can read it.
assertTrue(text.contains("running wallet"))
assertTrue(text.contains("nobody can send you an invoice")) assertTrue(text.contains("nobody can send you an invoice"))
} }

View file

@ -117,7 +117,7 @@ class WalletManagerTest {
@Test @Test
fun a_row_that_is_not_open_says_to_open_it() { fun a_row_that_is_not_open_says_to_open_it() {
val why = walletSecretsBlockedReason(isActive = false, walletReadable = readable) val why = walletSecretsBlockedReason(isActive = false, walletReadable = readable)
assertEquals("open this wallet to view its backup", why) assertEquals("Open this wallet to view its backup.", why)
} }
@Test @Test
@ -212,7 +212,7 @@ class WalletManagerTest {
walletPassphraseSubmitEnabled(activeFilename = null, typed = "pw", inFlight = false), walletPassphraseSubmitEnabled(activeFilename = null, typed = "pw", inFlight = false),
) )
val why = walletPassphraseBlockedReason(activeFilename = null, typed = "pw") val why = walletPassphraseBlockedReason(activeFilename = null, typed = "pw")
assertTrue("got '$why'", why != null && why.contains("not pointed at")) assertTrue("got '$why'", why != null && why.contains("No wallet file is open yet"))
// The two reasons are different fixes and must not read alike. // The two reasons are different fixes and must not read alike.
assertFalse(why == walletPassphraseBlockedReason(activeFilename = openFile, typed = "")) assertFalse(why == walletPassphraseBlockedReason(activeFilename = openFile, typed = ""))
} }
@ -225,7 +225,7 @@ class WalletManagerTest {
@Test @Test
fun nothing_typed_is_the_other_reason() { fun nothing_typed_is_the_other_reason() {
val why = walletPassphraseBlockedReason(activeFilename = openFile, typed = "") val why = walletPassphraseBlockedReason(activeFilename = openFile, typed = "")
assertTrue("got '$why'", why != null && why.contains("type the passphrase")) assertTrue("got '$why'", why != null && why.contains("Type the passphrase"))
} }
// --- the daemon's own words never reach the screen ----------------------- // --- the daemon's own words never reach the screen -----------------------
@ -348,7 +348,12 @@ class WalletManagerTest {
walletOpen = false, walletOpen = false,
needsPassphrase = false, needsPassphrase = false,
) )
assertTrue("got '$hint'", hint != null && hint.contains("No wallet is open")) // The §4.1 replacement copy, verbatim: a live wallet with no file open
// is a state, not an error.
assertEquals(
"Select a saved wallet or create a new one to view your balance and transact.",
hint,
)
assertNoRawRpc(hint!!) assertNoRawRpc(hint!!)
} }
@ -463,7 +468,7 @@ class WalletManagerTest {
fun wallet_reads_reload_only_once_the_child_is_answering() { fun wallet_reads_reload_only_once_the_child_is_answering() {
// `walletBalance()` answers `"err"` — it does not throw — while the // `walletBalance()` answers `"err"` — it does not throw — while the
// child is still dialling, so reloading in that window is what pins the // child is still dialling, so reloading in that window is what pins the
// headline on `balance —`. Reload only when the child has answered. // headline on `Balance unavailable`. Reload only when the child has answered.
assertFalse(shouldReloadWalletReads(null)) assertFalse(shouldReloadWalletReads(null))
assertFalse(shouldReloadWalletReads("off")) assertFalse(shouldReloadWalletReads("off"))
assertFalse(shouldReloadWalletReads("connecting")) assertFalse(shouldReloadWalletReads("connecting"))