App::open_wallet propagated the node's "no receive address" error with `?`,
so on an install with no wallet RPC configured and no profile xmr the Err
travelled out of App::run and out of boot(), and the process exited 1. The
same call already degrades to an empty address on F9.
Degrade it here too, and leave a status note that names the way forward:
this screen's own `c`/`i` create/import keys plus ONIONWIRE_WALLET_RPC.
A configured-but-failing endpoint gets the existing NOT_CONNECTED_MSG
instead of the unconfigured copy. balance and transfers are unchanged.
Tests: F6 on a bare install opens Screen::Wallet with an empty receive_addr,
a status note, and no error text in the frame drawn through App::draw; the
frame after Esc back to Main really renders the note. The control case (a
profile xmr address) still fills receive_addr and sets no note. The existing
offset-notice test asserted the propagation itself and now asserts the screen
it reaches instead.
Report-only audit of the wallet screens at a1f5c878: rendered frames at
80x24/120x40/200x60 for the first-run frame, the F6 wallet screen, the
F6 -> w wallet list, the create-spend-wallet gate and the F9 menu, plus a
findings table located by function and line.
No source file changed.
Monero's `restore_deterministic_wallet` takes a `seed_offset`: a second
spend secret mixed into the 25 words at restore time, so the same words
with a different offset open a different wallet. It is not the wallet-file
passphrase and must never be sealed, stored, logged or put on an argv.
- `Wallet::restore_wallet` gains `seed_offset: Option<&str>`: None, empty
or whitespace-only leaves the field out of the JSON entirely; otherwise
the ends are trimmed and it is sent beside the seed.
- `Node::wallet_restore` passes it through and still seals only the file
passphrase.
- SDK: `import_wallet` keeps its signature (None) and
`import_wallet_with_offset` is added (Kotlin `importWalletWithOffset`).
- TUI: a new `ImportOffset` step between the seed and the file passphrase
(blank Enter skips, a real one is confirmed, a mismatch never dials), and
`ImportOffsetSeen` after a successful import that used one -- Esc cannot
leave it, only SEEN, and the offset is not drawn anywhere.
- Docs: WALLET.md, THREAT_MODEL.md, TUI.md, one README sentence.
`a_restart_opens_the_stored_wallet_file` failed on the Pi runner twice in a
row — CI run 905 job 1373 and run 901 job 1365 — and passed 3/3 on a 16-core
host:
open the wallet with a passphrase: "wallet file onionwire-1 is not open —
the wallet RPC never answered (wallet connect: Connection refused (os error
111))"
The whole `WALLET_OPEN_WAIT` was burned on refusals, so the mock was bound on
a port the restarted child never dialled. Production is not the suspect:
`WalletChild::start_children` builds the child's argv and the `WalletClient`
URL from the same `pick_port` value, and `start_wallet_child_with` installs
that client in `self.wallet` before `open_child_wallet` dials it, so the client
can never carry the previous child's port.
The harness is the suspect. It learned the restarted child's port from the
*shared* argv log — a file every child writes — and cleared that file first.
A clear is not a synchronisation: on a loaded runner the killed child's write
lands after it, so the poller read the port of a child that was already dead
and bound the mock there. Reproduced deterministically with a stand-in whose
exec is late; with the old read the new test fails with the CI message, byte
for byte.
Each fake child now writes `<log>.<pid>` as well, and the shared copy lands
first, so a pid-named file implies the shared one is complete. A test that
spans two children reads the pid-named file: only that child can write it, so
the port belongs to the child that dials it. `WalletChild::wallet_rpc_pid`
(test-only) supplies the pid.
`open_wallet_blocking` already retries while the RPC is unreachable and gives
up after a bounded wait with a typed `OpenFailure::NotAnswering`, so it cannot
refuse forever against a merely slow child: no production change.
new test: node::tests::a_restart_is_not_given_the_stopped_childs_port
The wallet-child tests learn a spawned stand-in's port by polling its argv
log, and `fake_bin`/`fake_child_bin` truncated the log and then appended
one line per argument -- so a poller could read a prefix. A truncated port
is a *valid* u16 ("427" out of "42765"), so `wait_for_child_rpc_port`
happily returned a port nothing was listening on and the restart's
`open_wallet` died with `Connection refused` after its 10s budget; the
same prefix read is what `loopback_and_clearnet_remotes_carry_no_proxy...`
printed with its `--daemon-address` value missing.
Both tests failed on the first CI run of this branch (ci / test) and are
green in isolation, which is the signature of this race rather than of a
code defect. The argv now lands in the log with a single `mv`, so a reader
sees either no log or the complete one.
Measured with a tight read loop (argv-race-probe.sh): the append version
was caught mid-write 1/300 reads, the mv version 0/300.
The status line renders WalletChildInput.lastError through walletChildLine,
and the same field feeds walletChildStatusDescription for the screen reader.
The filter added in 3f84021 sat on the sticky error card only, so in exactly
the state this card targets — a live child with no wallet file open answering
-13 No wallet file — the raw daemon sentence still reached the line and the
screen-reader sentence.
Move it to the producer: WalletChildStatus.toInput() now runs lastError
through walletFailureText, the one seam where the SDK record becomes the
Kotlin model. Idempotent on its own replacement texts, so the error card's
second pass is stable.
New JVM tests build the SDK record and assert on the rendered line (and its
description), not on walletFailureText in isolation: with the filter removed
they fail on the raw 'No wallet file'.
next_wallet_filename returned <default>-<n> for the first n the SQLCipher
catalogue did not hold, and never looked at the wallet directory. monero
writes two files per wallet (<name> and <name>.keys) and refuses a create
that would collide with either, so a file whose catalogue row is gone -
Store::delete_wallet keeps the file, and a create whose record_wallet
failed leaves one - meant every attempt proposed the same taken name and
the daemon answered -21 Cannot create wallet. Already exists. for ever.
Add wallet_name_taken (src/wallet_child.rs): it lists the wallet dir and
answers whether <name> or <name>.keys is already there. next_wallet_filename
now needs the candidate free in both places, and Node::wallet_dir() is the
single source of $ONIONWIRE_HOME/wallet, used by the child spawn too.
Fail closed: an unreadable (or missing) wallet dir is an error, not a
guess. Reads only - nothing here deletes a file the catalogue does not
hold, which may be the only copy of a funded wallet.
The wallet manager could not open a wallet it holds no passphrase for: the
child came up pointed at the file with no wallet open, `needs_passphrase`
was true, and every read answered the daemon's `-13 No wallet file`. The
screen rendered that string.
Phone side of t_67879b98:
* WalletManagerScreen asks for the passphrase when the child reports
`needs_passphrase` and no wallet is open, and submits it through the
parent's `Wire::open_wallet_with_passphrase` on the file the child is
already pointed at. Masked field, no copy action (same rule as the seed
card), wiped on success and on dispose, FLAG_SECURE while the screen is
up.
* `walletFailureText` filters every user-visible wallet failure: the
daemon's `No wallet file`, a bare `-13`, and any JSON envelope become a
plain sentence that says whether a wallet is open and what to do next.
Applied at every site that renders a wallet error, in both wallet
screens and the wallet-child error flow in the ViewModel.
* The wallet screen says "no wallet is open in the child" and where to fix
it, instead of leaving it to surface later as the daemon's own words.
Tests: WalletManagerTest covers the new decisions (prompt shown / not
shown, submit gate and its reasons, the failure-text filter, the open
hint) on the JVM. 203 unit tests green.
`monero-wallet-rpc` starts with no wallet open and keeps one only for the
life of its process, so a restart, a Lock/unlock or a wallet re-point left
a live child answering `-13 No wallet file` to every read while the file
sat on disk. The app now opens the configured catalogue file itself
(`Wallet::open_wallet`, over RPC — never `--wallet-file`/`--password` on
argv, which `ps` exposes) after the child is up, and keeps the passphrase
that does it, sealed with the store data key beside the RPC creds under
its own AAD.
- core: `Wallet::open_wallet`, `WalletConfig::wallet_passphrase`
(+ `with_wallet_passphrase`, redacted Debug, kept out of the endpoint
config), `Error::is_unreachable` for the one retryable class (the port
binds a moment after spawn; a timeout is not a start in progress).
- store: `wallet_config.sealed_passphrase` column (additive, AAD
`onionwire-store-v1:wallet-passphrase`), read-modify-written so the
endpoint/login survive; `wallet_save_config` keeps the stored one.
- node: `start_wallet_child` opens the file, `open_wallet_with_passphrase`
opens a file with a passphrase the user just typed and seals it only
once a live daemon accepted it, `wallet_status` grows `wallet_open` and
`needs_passphrase`. A child the RPC refuses is stopped rather than left
inert; an install with no stored passphrase still starts, and says so.
- tui: one-shot prompt (`WalletSetup::UnlockPass`) on a wallet that needs
it, reachable from the saved-wallet picker and from `s`.
- sdk: `openWalletWithPassphrase`, the two status fields, README flow.
- docs: WALLET/THREAT_MODEL/README — the passphrase is kept, and the
consequence (the store passphrase is sufficient to spend) is stated
rather than implied.
Tests: 4 new node tests drive a real child lifecycle against a loopback
wallet RPC (open on restart, no open without a passphrase, refused
passphrase, sealed-on-success), a `tests/wallet.rs` test asserts the bytes
sent (`open_wallet` + filename + password), and `tests/store.rs` covers
the sealed column and the plaintext->encrypted upgrade with it set.
Mutation-checked: stubbing the two open paths fails all four.
The phone's half of the TUI's `/profile`. A `Profile` action on the roster's
app bar opens `ui/ProfileScreen.kt`: nickname, bio, and the Monero address
friends pay to, all three loaded from the store and written back through the
core's own validation.
- The address is checked with `uniffi.onionwire_sdk.checkAddress` *before* the
write, so a typo is refused with the typed text still in the field instead of
surfacing as a store error afterwards. An empty address is allowed and is
labelled with its consequence: with no profile address and no running wallet
child the core has nothing to hand a payer.
- The bio is carried, not owned: a save that did not touch the field writes
back the value read from the store immediately before the write, so a bio set
in the TUI cannot be blanked from the phone.
- On save the profile is pushed to **every** friend in the roster, one-shot and
fail-closed per friend like the TUI's `save_profile`. A push failure is not a
save failure: the status line always starts with `profile saved` and names the
count, with each failure listed by petname (else shortened fingerprint).
Every decision the screen makes is a pure function in the new file, covered by
`ProfileDraftTest` (21 cases) on the JVM: the save-button rule (dead until the
read lands, dead while the form is unchanged), the address branch, the bio rule,
label selection and the status-line aggregation.
Verified on AVD ow35 (x86_64 slice, emulator-5560): the roster app bar carries
`Profile`; nickname/bio/address survive `am force-stop` + relaunch; an invalid
address is refused before the write; a save with an empty roster reports
`profile saved`; with one (self-)peer in the roster a save reports
`profile saved · sent to 1 friend`, and with the emulator's network cut the same
save reports `profile saved · sent to 0 of 1 friend · failed: <label>: <tor err>`.
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.
The identity card's full fingerprint wraps to several lines on a phone and
pushes the friend list off the first screen. Collapse it: one line by
default (label + `shortId(fingerprint)` + chevron), the full fingerprint and
the full onion behind a tap, in the order they already had.
The `sdk …` line and `keepAliveNote` stay outside the disclosure — the
keep-alive denial is the only place that note appears, so hanging it off a
collapsed block would hide it.
`shortId` is a pure top-level function (`head … tail`, unchanged when the
value is no longer than the abbreviation, empty stays empty) so the collapsed
line is a slice of the value shown expanded, not a parallel encoding. The
expand state is `rememberSaveable`: a rotation keeps what the user chose, and
nothing about it belongs in the store.
RosterIdTest covers the abbreviation on the JVM (7 cases: the 64-hex
fingerprint, the head/tail boundary, custom head/tail, shorter-than-input,
empty, single-char ellipsis).
The Android wallet/profile screens had nothing to call: the core could list
wallets, switch the child onto one, read its keys and read/write the self
profile, but none of it crossed UniFFI.
Core:
- Wallet::keys() -> WalletKeys { view_key, spend_key: Option<String> }: two
query_key calls against the file the RPC has open. A view-only wallet's -29
is spend_key: None, not an error. WalletKeys' Debug redacts both halves.
- Node::wallet_keys() mirrors wallet_create/wallet_seed; refuses locally when
no wallet is configured.
- Node::active_wallet_filename() -> Option<String>: the file the child is
pointed at, None until wallet-child settings exist, so a client can mark the
open row.
SDK (UniFFI):
- records WalletRow / WalletKeys / SelfProfile, and Wire::{wallets,
open_wallet, active_wallet_filename, wallet_keys, self_profile,
set_self_profile, push_self_profile}.
- The rule the clients must express is in the docs: the seed and the private
keys come from the OPEN wallet, so there is deliberately no accessor that
reads another saved wallet's secrets without opening it.
docs/WALLET.md (catalogue + 'secrets belong to the open wallet'),
docs/THREAT_MODEL.md (the new on-demand-display exposure surface) and the SDK
README are updated in the same commit.
The selection screen shipped as presentation only: `F6 w` opened its
unavailable state, the rows were never read, and Enter on a wallet said
switching was not wired up. The catalogue, the create path and the screen
all existed; nothing joined them.
- `App::open_wallet_select` builds its rows from `Node::list_wallets` at
the moment the screen opens (never cached from startup), and a failed
read is the screen's own error state rather than "no saved wallets".
- `App::choose_wallet` resolves `WalletChoice::Open(index)` against the
catalogue as it is now — the index is a position, and two saved wallets
may share an identity key — then loads it. `+ create new wallet` still
starts the existing create flow.
- `Node::open_wallet(filename)` is the load: it refuses a file the
catalogue does not hold, re-points the sealed wallet-child record with a
read-modify-write (the generated RPC creds survive), and restarts a
running child onto the new file. An idle child takes the change on its
next start.
- `App::new` starts on the selection screen when the catalogue is
non-empty and on the create flow when it is empty, so a restart lands on
the wallets it remembers and a first run has no dead empty list.
- The stored identity/locator stay catalogue columns: a locator rotates
(F4) and identity is the roster key the node already holds, so the live
header keeps reading them from the node.
- `SELECT_UNAVAILABLE` is gone with the state it described; docs/TUI.md
now describes the wired behaviour.
Tests (both new): `Node::open_wallet` over an offline node — the chosen
file, the creds kept across the read-modify-write, the choice surviving a
reopen, and a non-catalogue file refused; and the app path in src/tui.rs
over a real store-backed node — start screen both ways, catalogue mapping,
row index over a shared identity, the create row, and a wallet recorded
after startup appearing the next time the list opens.
Screen::WalletSelect: a table of saved wallets — name, identity prefix,
locator prefix, creation day — the selected row's full identity and locator
under it, and a `+ create new wallet` row as the last item. j/k or arrows
move, Enter takes the choice, Esc back. Empty, failed and in-flight reads
each get their own copy; a wallet with a NULL label, no published locator or
no usable timestamp reads `(unlabelled)` / `-` / `unknown` rather than blank.
Presentation only. Rows are plain display data (WalletRow) built by the
caller; the render path never reads the store, and the selection is by row
index because two records may share an identity key. Loading a chosen record
into the session is the wallet-store integration step, so the F6 `w` entry
opens the screen on its unavailable state until that accessor lands, and the
create row works today either way.
Evidence: tests/tui_select.rs (16 tests) drives the real draw path through
TestBackend at 80x24, 120x40 and 200x60, pins the dumped frame's footer to
status_footer_phased(..., wallet_select_footer_hint()), asserts exactly one
focus marker, a cell-width line budget from 20 to 200 columns, the window
disclosure with the create row always visible, hostile labels (ESC/BEL/C1/
bidi/newline/tab) and the crate-local UTC date formatter.
(cherry picked from commit 99a4ab640e)
A wallet created in-app was never remembered: `Node::wallet_create` called
the RPC and returned the seed, and the wallet file name was the one
hardcoded `wallet::DEFAULT_WALLET_FILENAME` ("onionwire"). A second create
reused that name, so the RPC refused it (or opened the first wallet's
file) and no row was ever written — the "cannot create a new wallet, and
nothing survives a restart" report.
Creation and import now go through the catalogue (t_64c9ba3c's
`Store::{create_wallet,list_wallets}`):
- each create/import gets its own file name, `onionwire-<n>` for the first
`n` the catalogue does not hold, so several wallets coexist;
- the stored row (id, identity, locator, file, created_at) is returned:
`Node::wallet_create` -> `CreatedWallet` (row + the one-time seed, with a
redacting `Debug`), `Node::wallet_restore` -> `WalletRecord`;
- `Node::list_wallets` reads the catalogue without dialing;
- the child config is re-pointed at the new file (read-modify-write, so the
sealed RPC creds survive) — a row the child never opens would still be a
broken wallet.
The SDK keeps its UniFFI signature (`create_wallet -> String` seed,
`import_wallet -> ()`), so no Kotlin change: it unwraps `.seed`.
TDD: 5 new `src/node.rs` cases (row + list, two wallets + reopen, import,
wallet-off empty list, child re-pointed) over a loopback wallet-RPC mock.
`cargo test --locked` exit 0, `cargo clippy --locked --all-targets -- -D
warnings` clean, and the same two commands are clean in
`crates/onionwire-sdk`.
Screen::WalletSelect: a table of saved wallets — name, identity prefix,
locator prefix, creation day — the selected row's full identity and locator
under it, and a `+ create new wallet` row as the last item. j/k or arrows
move, Enter takes the choice, Esc back. Empty, failed and in-flight reads
each get their own copy; a wallet with a NULL label, no published locator or
no usable timestamp reads `(unlabelled)` / `-` / `unknown` rather than blank.
Presentation only. Rows are plain display data (WalletRow) built by the
caller; the render path never reads the store, and the selection is by row
index because two records may share an identity key. Loading a chosen record
into the session is the wallet-store integration step, so the F6 `w` entry
opens the screen on its unavailable state until that accessor lands, and the
create row works today either way.
Evidence: tests/tui_select.rs (16 tests) drives the real draw path through
TestBackend at 80x24, 120x40 and 200x60, pins the dumped frame's footer to
status_footer_phased(..., wallet_select_footer_hint()), asserts exactly one
focus marker, a cell-width line budget from 20 to 200 columns, the window
disclosure with the create row always visible, hostile labels (ESC/BEL/C1/
bidi/newline/tab) and the crate-local UTC date formatter.
Wallets were only ever a file in $ONIONWIRE_HOME/wallet plus the
single-row wallet_child config for the one the child is currently
pointed at, so a created wallet was not remembered and a second create
had nowhere to go.
Add a 'wallets' table (id, name, identity_pubkey, onion_locator,
wallet_filename, created_at) and CRUD on Store: create_wallet,
get_wallet_by_id, list_wallets, delete_wallet. wallet_filename is
UNIQUE so a second wallet cannot silently reuse the first one's file,
and identity_pubkey is deliberately not unique (identity is the roster
key, a wallet is a file; the locator may rotate or be empty).
No new crate: the store is already rusqlite + SQLCipher with a raw
PRAGMA key, and sqlx has no SQLCipher path, so a second pool would be a
second unencrypted way in.
Tests: 5 store cases in tests/store.rs (round-trip, coexistence across
a reopen, duplicate filename, delete, blank label/filename) plus the
at_rest upgrade case in src/store.rs.
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.
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 (`wallet_balance` returns "err") would
be warned about a seed they do not have.
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, 135 tests
(`SeedBackupGateTest` 18 of them).
Wallet::create_wallet returned the 25-word seed exactly once and nothing
could reach it afterwards, so a seed that was never backed up at creation
was unrecoverable. Add Wallet::mnemonic() (one query_key mnemonic call on
the open wallet file), Node::wallet_seed() mirroring wallet_create, and the
additive UniFFI export Wire::wallet_seed() -> Kotlin Wire.walletSeed().
No existing signature changes. The refusals stay leak-free: an unconfigured
wallet gets NOT_CONFIGURED_MSG without a dial, a watch-only wallet keeps the
RPC's -29 view-only mapping, and no error string carries the RPC login.
Tests (tests/wallet.rs) drive the per-connection Digest mock: the words come
back verbatim, a JSON-RPC error surfaces without the login or endpoint, a
rejected digest refusal does not leak the password, and an unconfigured
wallet is refused without dialing.