docs(wallet): describe the child lifecycle that ships here
All checks were successful
ci / test (pull_request) Successful in 5m31s
ci / sdk (pull_request) Successful in 1m22s
android-ci / android (pull_request) Successful in 8m52s
ci / fuzz (pull_request) Successful in 4m37s

The inherited section described an F7 config screen with endpoint entry and
test-connection that is not in this stack (it lives on
feat/wallet-create-import), and called local mode 'not wired yet'. Both are
now wrong: the child is wired, and the stored wallet config is a core API
without a screen. Say which is which.
This commit is contained in:
agent 2026-09-18 09:28:11 -04:00
commit c5af978d14
No known key found for this signature in database

View file

@ -154,23 +154,32 @@ what leaves receipts permanently unverified.
| `ONIONWIRE_WALLET_RPC_LOGIN` | `user:pass` when you do not want the password in the URL. Ignored if the URL carries userinfo. | | `ONIONWIRE_WALLET_RPC_LOGIN` | `user:pass` when you do not want the password in the URL. Ignored if the URL carries userinfo. |
| `ONIONWIRE_WALLET_NO_SPEND` | `1` / `true` / `yes` / `on` → view-only deployment: `/tip` is refused locally, before any RPC dial. `/pay` and receipt verification keep working. | | `ONIONWIRE_WALLET_NO_SPEND` | `1` / `true` / `yes` / `on` → view-only deployment: `/tip` is refused locally, before any RPC dial. `/pay` and receipt verification keep working. |
As of v0.2.2 these three are the **migration path**, not the only path: the These three are the **migration path**, not the only path: a config stored in
stored config set in **F7** wins at boot. See *Stored wallet config* below. the encrypted store wins at boot. See *Stored wallet config* below.
`README.md` carries the operator summary; this file is the long form. `README.md` carries the operator summary; this file is the long form.
## Stored wallet config (no env required) ## Stored wallet config (no env required)
Editing env vars is a deployment step, not a UI step. The TUI's **F7** screen Editing env vars is a deployment step, not a UI step. The same three fields can
sets the same three fields and stores them, so a desktop install never needs env be stored instead, so a deployment never needs env at all:
at all:
| Field | Meaning | | Field | Meaning |
|---|---| |---|---|
| `rpc_url` | `http://host:port[/path]` for an **externally run** `monero-wallet-rpc`. **No** `user:pass` in the URL. Loopback only, same rule as env. | | `rpc_url` | `http://host:port[/path]` for an **externally run** `monero-wallet-rpc`. **No** `user:pass` in the URL. Loopback only, same rule as env. |
| `rpc_login` | `user:pass`. Masked in the UI. Never logged, never in a status line, never on disk in the clear. | | `rpc_login` | `user:pass`. Never logged, never in a status line, never on disk in the clear. |
| `no_spend` | View-only deployment. Same semantics as `ONIONWIRE_WALLET_NO_SPEND`. | | `no_spend` | View-only deployment. Same semantics as `ONIONWIRE_WALLET_NO_SPEND`. |
`Store::save_wallet_config` / `Store::load_wallet_config` are the read/write
pair, and `Node::wallet_save_config` re-reads the live wallet after a save so
`configured` / the readouts follow without a restart. **No screen in this
repository calls them yet**: the TUI wallet config screen (F7) and its endpoint
entry, test-connection button and save path ship on
`feat/wallet-create-import`, which is not part of this change — see
*Starting and stopping the app-owned child* below for what this stack does
expose. Until that lands, set the stored config programmatically (or use the env
vars above).
They live in the **encrypted SQLCipher store** (`wallet_config` table, one row: They live in the **encrypted SQLCipher store** (`wallet_config` table, one row:
the URL and the flag in the clear inside the encrypted db, the login sealed with the URL and the flag in the clear inside the encrypted db, the login sealed with
the store data key and a `onionwire/wallet-config/v1` AAD on top of whole-db the store data key and a `onionwire/wallet-config/v1` AAD on top of whole-db
@ -179,11 +188,11 @@ row; clearing the URL deletes it, which is how you turn the stored wallet off
again. again.
**Boot precedence is stored → env → disabled.** Stored config wins; the env vars **Boot precedence is stored → env → disabled.** Stored config wins; the env vars
in the table above remain the pre-F7 migration path (and the only path for in the table above remain the migration path (and the only path for headless
headless / non-TUI runs). A stored config that cannot be used — non-loopback runs). A stored config that cannot be used — non-loopback host, `.onion`,
host, `.onion`, missing login — is reported and then **falls back to env** missing login — is reported and then **falls back to env** rather than dialling
rather than dialling the bad endpoint. To override a stored config with env, the bad endpoint. To override a stored config with env, clear the stored one
clear the stored one (F7, empty endpoint) first. first.
### Wallet status, and how fresh `connected` is ### Wallet status, and how fresh `connected` is
@ -207,10 +216,10 @@ Two probes exist:
- `wallet_refresh` / the readiness guard probe the **configured** endpoint and - `wallet_refresh` / the readiness guard probe the **configured** endpoint and
update the snapshot; update the snapshot;
- **Test connection** on the F7 screen probes the endpoint you are *currently - `wallet_test_connection` probes an endpoint the caller is *currently typing*
typing* (`Wallet::ping`) and returns `{ok, status, error}` without touching (`Wallet::ping`) and returns `{ok, status, error}` without touching the live
the live wallet or the snapshot — testing an untyped endpoint is not the wallet or the snapshot — testing an untyped endpoint is not the wallet the app
wallet the app is running. is running. (The F7 screen that calls it ships on `feat/wallet-create-import`.)
### The pay/tip readiness guard ### The pay/tip readiness guard
@ -228,15 +237,63 @@ already known locally. The order is fixed and the copy is part of the contract:
4. otherwise ready. `/pay` is fine on a view-only wallet. 4. otherwise ready. `/pay` is fine on a view-only wallet.
The check is cheap enough to run on Enter: steps 1 and 2 are local, and step 3 The check is cheap enough to run on Enter: steps 1 and 2 are local, and step 3
is one bounded probe (5s local budget). `wallet_readiness(is_tip)` is `async` is one bounded probe (5s local budget). `wallet_readiness(is_tip)` is `async`;
and the TUI calls it with `rt.block_on` from the key handler, the same pattern the TUI calls it from its key handler on both the `/pay` and `/tip` paths before
`send_pay` / `send_tip` already use. it sends anything.
**Local mode is not wired yet.** Wallet-child fields (binary paths, wallet dir, The "open F7" wording inside the not-configured message is the copy that ships
daemon address, chain backend, daemon sync state) are not part of this stored with the F7 screen on `feat/wallet-create-import`; this stack stores the config
config; the app-owned child keeps its own record (see *Where the RPC credentials and exposes the guard, but no screen writes it yet.
live* above). Until a screen sets them from the store, treat local mode as
not-yet-available rather than pretending a child is running. ## Starting and stopping the app-owned child
Nothing spawns the child by accident: `Node::start_wallet_child` is the only
start path, and it is never called at boot. The desktop TUI drives it from the
wallet screen (F6):
| Key | Effect |
|---|---|
| `s` | Start the child, then probe it once. |
| `x` | Stop it (idempotent) and fall back to the stored/env wallet config. |
| `p` | Probe the running child: is its wallet RPC answering, is the chain at the tip? |
The state shown next to the wallet readouts is `off` / `connecting` / `syncing`
/ `ready` / `exited`, plus the chain-source label (`receive-only`,
`local node`, `remote onion daemon`, `remote daemon`). It is derived from the
real process (`try_wait`) and the last probe — **never** from env-var presence,
and `ready` is never reported for a child that has died.
- **`off`** — nothing started (or stopped). The default state.
- **`connecting`** — the `monero-wallet-rpc` process is alive but has not
answered yet. This is what a fresh `s` reports; the RPC is not up the instant
the process exists.
- **`syncing`** — it answered but `chain_ready()` is false.
- **`ready`** — it answered and the chain is at the tip.
- **`exited`** — a started child has died. Stop and start again; the status is
not stale, it is the process table.
`start` is idempotent: a live child is reported, not respawned. A start that
cannot spawn the binary is an error and leaves no child behind.
**The chain source and the binaries are settings, not flags.** They live in the
same sealed `wallet_child` record as the generated RPC creds (see *Where the RPC
credentials live*), so they survive a restart:
- `src/wallet_child.rs` `ChildConfig` — `source`, `wallet_rpc_bin`, `arti_bin`,
`wallet_filename`; validated before anything is written.
- Core: `Node::wallet_child_config` / `Node::set_wallet_child_config`, then
`Node::start_wallet_child` / `stop_wallet_child` / `wallet_child_status` /
`wallet_child_refresh`.
- Android (UniFFI): `set_chain_source(ChainConfig)` / `chain_source()`,
`start_wallet_child()`, `stop_wallet_child()`, `wallet_status()`. Pass
absolute paths for `wallet_rpc_bin` / `arti_bin` (`nativeLibraryDir`); the
core never resolves a binary the caller named explicitly.
So local mode is **available**, not wired off: a local chain source spawns
`monerod` from the path you set, a `.onion` daemon spawns the `arti` SOCKS
child, and everything else is unchanged. What is still missing is a *screen* to
type those fields on the desktop — the API above is the surface until the F7
work lands.
## Create vs import ## Create vs import