From f95c1e7ca732be720cb1704f0fad57b963aabe13 Mon Sep 17 00:00:00 2001 From: agent Date: Sun, 20 Sep 2026 00:31:07 -0400 Subject: [PATCH] docs: rewrite README and living docs to match the tree Audit the operator docs against the source: pin downloads to v0.14.0, document the real CLI/flags/env/F-keys (including F9, no F7), keep 18081 as the app-owned daemon port, describe the local chat outbox vs a server-side one, and stop implying SECURITY_AUDIT.md is a third-party audit. Spike reports stay; they get a status header only. --- README.md | 444 ++++++------- docs/ARTI_UPGRADE.md | 13 +- docs/PROTOCOL.md | 92 ++- docs/README.md | 23 +- docs/RELEASING.md | 7 +- docs/SECURITY_AUDIT.md | 5 +- docs/THREAT_MODEL.md | 10 +- docs/TUI.md | 1069 ++++-------------------------- docs/WALLET.md | 600 +++++------------ docs/arti-socks-feasibility.md | 4 + docs/cuprate-android-spike.md | 4 + docs/cuprate-launch-spike.md | 3 + docs/option-a-recommendation.md | 3 + docs/payment-integration-plan.md | 6 + 14 files changed, 649 insertions(+), 1634 deletions(-) diff --git a/README.md b/README.md index 477f41a..d77917a 100644 --- a/README.md +++ b/README.md @@ -1,71 +1,89 @@ # OnionWire Lean Tor messenger: one Rust process (ratatui + Noise IK + sqlite + in-process Arti). -No hosted server. Identity is a public key; the onion is only a locator. +No hosted server. Identity is an ed25519 public key; the onion is only a locator. -**v0.2.1** — Linux TUI + Android SDK/APK. Two people add each other with an `onionwire:v1:…` invite string (`F2` share / `F3` paste). There is no QR graphic. Chat is Noise IK over your own v3 onion, and every chat message is ratcheted inside that session. Unreachable chat peers go to a **local outbox** (device-only retry queue — no relay); file transfer and payment frames still fail closed. Optional Monero payments: `/pay` invoices (receive), `/tip` payments (send), and a full in-app wallet create/import (`F6` wallet screen, `/wallet create`, `/wallet import`). Arti onion services are still experimental. The whole store is encrypted at rest with SQLCipher; message bodies add a row-bound AEAD layer on top. +Current tagged release: **v0.14.0**. Linux TUI + Android SDK/APK. Two people add +each other with an `onionwire:v1:…` invite string (`F2` share / `F3` paste). There +is no invite QR graphic. Chat is Noise IK over your own v3 onion; every chat +message is ratcheted inside that session. Unreachable chat peers go to a **local +outbox** (device-only retry queue — no relay). File transfer and payment frames +fail closed. Optional Monero: `/pay` invoices, `/tip` payments, and in-app wallet +create/import (`F6`). Arti onion services are still experimental. The store is +SQLCipher; chat bodies add a row-bound AEAD layer. -You do **not** install a `tor` daemon, `torrc`, Prosody, or XMPP. OnionWire embeds Arti and publishes its own v3 onion. +You do **not** install a `tor` daemon, `torrc`, Prosody, or XMPP. OnionWire embeds +Arti and publishes its own v3 onion. There is no C-tor fallback. -**Docs** (protocol first, then claims): [PROTOCOL.md](docs/PROTOCOL.md) · [threat model](docs/THREAT_MODEL.md) · [audit notes](docs/SECURITY_AUDIT.md) (in-house, not a third-party audit). Index: [docs/README.md](docs/README.md). +**Docs** (protocol first, then claims): [PROTOCOL.md](docs/PROTOCOL.md) · +[threat model](docs/THREAT_MODEL.md) · [audit notes](docs/SECURITY_AUDIT.md) +(in-house, **not** a third-party audit). Index: [docs/README.md](docs/README.md). +TUI keys: [docs/TUI.md](docs/TUI.md). Wallet: [docs/WALLET.md](docs/WALLET.md). +Releases: [docs/RELEASING.md](docs/RELEASING.md). ## Install -Pick one: a CI-built binary (fastest), or build from source. +Pick one: a CI-built binary, or build from source. ### Requirements | Need | Notes | |---|---| | Linux | x86_64 or aarch64. TUI needs a real terminal (not a pipe). | -| Network | First run bootstraps Tor via Arti. Offline start will fail closed. | +| Network | First run bootstraps Tor via Arti. Offline start fails closed. | | Not needed | `tor` package, `torrc`, Prosody, an XMPP account, a DHT. | -Arti onion services are still **experimental**. If the hidden service cannot come up, OnionWire exits — it does not fall back to C-tor. +Arti onion services are still **experimental**. If the hidden service cannot come +up, OnionWire exits. ### Option A — download a release binary -CI (`.forgejo/workflows/release.yml`) does **not** release on a merge. Releases are manual and batched: a maintainer runs the workflow at a stopping point (Actions → release → Run workflow, `dry_run=true` first), which tags the next `v*.*.*` version and publishes both Linux binaries — aarch64 on the Pi runner, x86_64 on the amd64 runner — to one [Forgejo release](https://forgejo.siriusdevops.com/sirius/onionwire/releases), with the Android APK + AAR attached to that same tag. Policy and inputs: [docs/RELEASING.md](docs/RELEASING.md). `scripts/build-release-local.sh` remains the offline x86_64 fallback. This Forgejo does not serve `/releases/latest/download/…` (404); pin the tag. +CI does **not** release on a merge. Releases are manual and batched: a maintainer +dispatches `.forgejo/workflows/release.yml` at a stopping point (`dry_run=true` +first), which tags the next `v*.*.*` version and publishes both Linux binaries to +one [Forgejo release](https://forgejo.siriusdevops.com/sirius/onionwire/releases). +The Android APK + AAR attach to **the same tag** by a second dispatch of +`android-release` with `tag=`. Policy: [docs/RELEASING.md](docs/RELEASING.md). +This Forgejo does not serve `/releases/latest/download/…` (404); pin the tag. -**x86_64 (most PCs / VMs):** +**x86_64:** ```bash -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.2.1/onionwire-x86_64-unknown-linux-gnu -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.2.1/onionwire-x86_64-unknown-linux-gnu.sha256 +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.14.0/onionwire-x86_64-unknown-linux-gnu +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.14.0/onionwire-x86_64-unknown-linux-gnu.sha256 sha256sum -c onionwire-x86_64-unknown-linux-gnu.sha256 chmod +x onionwire-x86_64-unknown-linux-gnu ./onionwire-x86_64-unknown-linux-gnu --version ``` -**aarch64 (Raspberry Pi, ARM servers):** +**aarch64:** ```bash -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.2.1/onionwire-aarch64-unknown-linux-gnu -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.2.1/onionwire-aarch64-unknown-linux-gnu.sha256 +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.14.0/onionwire-aarch64-unknown-linux-gnu +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.14.0/onionwire-aarch64-unknown-linux-gnu.sha256 sha256sum -c onionwire-aarch64-unknown-linux-gnu.sha256 chmod +x onionwire-aarch64-unknown-linux-gnu ./onionwire-aarch64-unknown-linux-gnu --version ``` -Install onto `PATH` if you want `onionwire` as a command (keep the asset filename until after `sha256sum -c`): +Install onto `PATH` (keep the asset filename until after `sha256sum -c`): ```bash mkdir -p ~/.local/bin install -m 755 onionwire-x86_64-unknown-linux-gnu ~/.local/bin/onionwire -# ensure ~/.local/bin is on PATH, then: onionwire ``` -The binary is dynamically linked against glibc (Ubuntu 24.04 builders). If `./onionwire` dies with `GLIBC_… not found`, use Option B on that machine. - -Checksum files are `sha256sum` format (` onionwire-`). Download both files with `curl -O` so the names match, then `sha256sum -c`. +The binary is dynamically linked against glibc (Ubuntu 24.04 builders). If it +dies with `GLIBC_… not found`, use Option B. Checksum files are `sha256sum` +format (` onionwire-`). ### Option B — build from source -Needs [Rust](https://rustup.rs/) **1.91+** (`edition = "2024"`; the pinned Arti 0.46 crates require rustc 1.91). A distro `rustc` is fine if `rustc --version` reports 1.91 or newer. Do not install `tor` for this app. +Needs [Rust](https://rustup.rs/) **1.91+** (`edition = "2024"`; `Cargo.toml` +`rust-version = "1.91"`; Arti 0.46 requires 1.91). Do not install `tor`. ```bash -# rustup (if you do not already have cargo) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source "$HOME/.cargo/env" rustc --version # must be 1.91 or newer @@ -81,30 +99,35 @@ cargo build --release --locked ./target/release/onionwire ``` -Install the binary: - ```bash cargo install --path . --locked --force # lands in ~/.cargo/bin/onionwire ``` Build needs a C toolchain plus `perl` and `make`: SQLCipher is compiled from -vendored OpenSSL sources (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`). -No system OpenSSL headers or `pkg-config` are required — Arti's TLS backend is -`rustls`, and the binaries carry no dynamic `libssl` dependency. +vendored OpenSSL (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`). No +system OpenSSL headers or `pkg-config` are required — Arti's TLS backend is +`rustls`. + +The crate version in `Cargo.toml` is **not** bumped by the release workflow. The +tag (`v0.14.0`) is the version users download; `onionwire --version` prints +`CARGO_PKG_VERSION` from the tree that was built. ### Two instances on one machine -Each process needs its own data dir (identity + onion + sqlite): +Each process needs its own data dir: ```bash ONIONWIRE_HOME=/tmp/ow-a ./onionwire ONIONWIRE_HOME=/tmp/ow-b ./onionwire ``` -Then `F2` on A (invite string), `F3`-paste on B (and the other way around). No QR. +Then `F2` on A, `F3`-paste on B (and the other way). No invite QR. -## First run +## Run + +There are **no subcommands**. Flags are `--version` / `-V` and `--help` / `-h` +only (`src/main.rs`). Anything else exits 2 with `onionwire: unknown argument`. ```bash onionwire @@ -112,22 +135,64 @@ onionwire or `cargo run --release`. -On start you are prompted for a store passphrase (echo off, like other CLI passwords) or set `ONIONWIRE_STORE_PASSPHRASE`. Empty passphrase is rejected; a wrong passphrase does not open chat. Then you should see `onionwire: bootstrapping Arti…` on stderr. Directory bootstrap is usually under a minute; the onion is ready once a probe connect works (combined Arti status may still say Bootstrapping). Fail closed at 360s. Data lives in `ONIONWIRE_HOME` if set, otherwise `~/.local/share/onionwire/` (`onionwire.db` + Arti state, mode 0700). First open creates an ed25519 identity key. That key **is** you. +On start you are prompted for a store passphrase (echo off) or set +`ONIONWIRE_STORE_PASSPHRASE`. Empty passphrase is rejected; a wrong passphrase +does not open chat. Then `onionwire: bootstrapping Arti…` on stderr. Directory +bootstrap is usually under a minute; the onion is ready once a probe connect +works (combined Arti status may still say Bootstrapping). Fail closed at 360s +(`PUBLISH_WAIT` in `src/hs.rs`). Data lives in `ONIONWIRE_HOME` if set, otherwise +`~/.local/share/onionwire/` (`onionwire.db` + Arti state, mode 0700). First open +creates an ed25519 identity key. That key **is** you. -Then `F2` to share your invite, `F3` to paste a friend's. Mouse-select the `onionwire:v1:…` line to copy. Highlight them in the roster, type in the composer, Enter to send. Chat rows show delivery state from the local outbox (`✓` delivered, `◷ queued (try n/8, retry …)`, `» sending`, `✗ failed: …`); the footer shows `{n} queued` while anything is outstanding. If their onion is down the message stays on this device and the retry worker re-dials with backoff — nothing is handed to a third party. File transfer and payments are still one-shot (both sides online). +Then `F2` to share your invite, `F3` to paste a friend's. Mouse-select the +`onionwire:v1:…` line to copy. Highlight them in the roster, type in the +composer, Enter to send. Chat rows show delivery state from the local outbox +(`✓` delivered, `◷ queued (try n/8, retry …)`, `» sending`, `✗ failed: …`); the +footer shows `{n} queued` while anything is outstanding. If their onion is down +the message stays on this device and the retry worker re-dials with backoff — +nothing is handed to a third party. File transfer and payments are still one-shot +(both sides online). ## Friends are keys -A friend is an ed25519 pubkey (`UNIQUE(pubkey)`). The `.onion` on that row is only where they are reachable right now. Pasting the same `k` updates the locator; it never creates a second person. +A friend is an ed25519 pubkey (`UNIQUE(pubkey)`). The `.onion` on that row is +only where they are reachable right now. Pasting the same `k` updates the +locator; it never creates a second person. + +## Commands and flags + +``` +onionwire [--version | -V | --help | -h] +``` + +Everything else is the TUI (function keys and `/commands` in the composer). + +### Environment + +| Variable | Read in | Meaning | +|---|---|---| +| `ONIONWIRE_HOME` | `src/store.rs` | Data dir. Unset → `~/.local/share/onionwire`. | +| `ONIONWIRE_STORE_PASSPHRASE` | `src/store.rs` | Non-empty store passphrase; skips the prompt. Empty/missing with no TTY fails closed. | +| `ONIONWIRE_ASCII` | `src/tui.rs` | Present → ASCII chrome (also follows `NO_COLOR`). | +| `ONIONWIRE_WALLET_RPC` | `src/wallet.rs` | External loopback `monero-wallet-rpc` URL. Unused by the app-owned wallet child. | +| `ONIONWIRE_WALLET_RPC_LOGIN` | `src/wallet.rs` | `user:pass` when the URL has no userinfo. | +| `ONIONWIRE_WALLET_NO_SPEND` | `src/wallet.rs` | `1` / `true` / `yes` / `on` → refuse `/tip` locally. | + +`NO_COLOR` (any value) also switches ASCII chrome. Android CI uses +`ONIONWIRE_REQUIRE_RELEASE_KEY`; the TUI does not read it. ## Keys (TUI) -Focus starts on the composer so typing works immediately. `Tab` cycles panes; `j`/`k` and arrows only move the focused pane (roster or chat). `1`/`2`/`3` switch focus when you are not typing in the composer. `?` opens help from every screen except paste (so a payload can contain `?`). +Focus starts on the composer. `Tab` cycles panes; `j`/`k` and arrows only move +the focused pane. `1`/`2`/`3` switch focus when you are not typing (on the +**wallet** screen those digits pick an in-process chain source instead — see +[docs/TUI.md](docs/TUI.md)). `?` opens help from every screen except paste (so a +payload can contain `?`). | Key | Action | |---|---| | `Tab` / `Shift-Tab` | Cycle focus: roster → chat → composer | -| `1` / `2` / `3` | Focus roster / chat / composer (when not typing) | +| `1` / `2` / `3` | Focus roster / chat / composer (Main, when not typing) | | `j` `k` / `↑` `↓` | Move or scroll the focused pane | | `g` / `G` | Jump to top / bottom of the focused pane | | `?` | Keybinding help (`Esc` closes) | @@ -135,51 +200,55 @@ Focus starts on the composer so typing works immediately. `Tab` cycles panes; `j | `F3` | Paste a friend's invite | | `F4` | Rotate **onion** (locator only) | | `F5` | Selected friend's profile (`/who`) | -| `F6` | Wallet screen (receive QR, balance, transfers) | +| `F6` | Wallet (receive QR, create/import, child, chain source) | | `F8` | Rotate **prekey** (hard cut: every friend re-pastes the invite) | +| `F9` | Wallets & settings menu (`/settings`) | | Enter | Send chat to the selected friend, or run a `/command` | | `Esc` | Close overlay / back to Main / clear composer | | `Ctrl-Q` | Quit: type `CLEAR`+Enter to wipe history, `QUIT`+Enter to leave it, Esc to stay | +There is **no `F7`**. The not-configured wallet error still says “open F7”; the +live screens are `F6` (wallet) and `F9` (settings). Full map: [docs/TUI.md](docs/TUI.md). + +Composer `/commands` (`src/tui.rs` `parse_cmd`): `/wipe`, `/wipe-all`, `/profile`, +`/who`, `/pay [memo]`, `/tip [memo]`, `/backup /path`, `/restore /path`, +`/file /path`, `/settings`, `/wallet create`, `/wallet import`. + ## F2 / F3 invite -There is no QR. `F2` opens `(o) invite` with truncated fingerprint, current onion, and the full payload (wrapped, mouse-select to copy): +There is no invite QR. `F2` opens the share screen with truncated fingerprint, +current onion, and the full payload (wrapped, mouse-select to copy): `onionwire:v1:k=…:o=…:spk=…:sig=…` -Give that string to a friend. They `F3` paste it (`(o) paste invite`). Unknown `k` asks for approval. Same `k` already in the roster updates `onion` only. +Give that string to a friend. They `F3` paste it. Unknown `k` asks for approval. +Same `k` already in the roster updates `onion` (and prekey) only. ## F4 rotate onion -`F4` is a locator change, not a new identity. Confirm by typing `ROTATE` (Enter alone does nothing). +`F4` is a locator change, not a new identity. Confirm by typing `ROTATE` (Enter +alone does nothing). -- Your identity fingerprint stays the same. +- Identity fingerprint stays the same. - A new onion is published; the old one is hard-cut (no dual-host grace). - Online friends get a signed `loc` frame. - Offline friends cannot find you until they F3-paste the new invite. There is no directory. ## Local outbox (chat) and fail closed -**Chat** to an unreachable onion is written to a local `outbox` row next to its -`messages` row and retried in-process while the app runs (exponential backoff, -cap 30 min between attempts, stop after 8 attempts or a terminal failure). There -is **no** server-side queue and **no** store-and-forward relay — a queued message -never leaves the device, and it dies with the device. Two consequences are real and are accepted: +**Chat** to an unreachable onion is written to a local `outbox` row and retried +in-process while the app runs (exponential backoff from 30s, cap 30 min, stop +after 8 attempts or a terminal failure — `src/outbox.rs`). There is **no** +server-side queue and **no** store-and-forward relay — a queued message never +leaves the device, and it dies with the device. -- **Device seizure.** A pending (never-delivered) message sits in the same SQLCipher store as the rest of the history, under the same per-row AEAD and the same passphrase-derived key — no weaker, but also no shorter-lived. Seizure *with* the passphrase reveals messages that were never actually sent, including ones the sender may have moved on from; seizure without it reveals nothing in this store. `/wipe` clears outbox rows with the rest of chat history; `/wipe-all` removes them with the data dir. Neither is a forensic erase — SSD wear-leveling can keep copies. Roster and identity stay. -- **Retry cadence is a local traffic-analysis surface.** A queued send re-dials the peer's onion on a backoff schedule while the app runs. An observer of your Tor client (or the network in front of it) sees a repeating connection attempt to one onion on a predictable cadence — it does not learn the plaintext or the recipient identity, but it can infer that you have an undelivered message for someone, and roughly when you composed it. The backoff is per-row, capped at one attempt per 30 min per message, and stops after 8 attempts or on a terminal failure. - -Delivery markers in the TUI and Android chat UI are the store's own statuses: - -| Row state | Marker | -|---|---| -| delivered | `you: ping ✓` | -| queued (2nd attempt, 45s out) | `you: pong ◷ queued (try 2/8, retry 45s)` | -| sending | `you: pong » sending` | -| failed | `you: pong ✗ failed: connection timed out` | -| inbound | `them: pong` (no marker) | - -The footer shows `{n} queued` while any row is outstanding. `try {n}/{8}` is the outbox attempt count; `retry {s}s` / `retry {m}m` / `retry now` comes from the stored absolute `next_attempt_at`. Failed reasons are sanitized, cut to the tail of the `a: b: c` chain, and capped at 24 cells. +- **Device seizure.** A pending message sits in the same SQLCipher store as the + rest of the history. Seizure *with* the passphrase reveals messages that were + never sent; seizure without it reveals nothing in this store. `/wipe` clears + outbox rows with chat history; `/wipe-all` removes them with the data dir. + Neither is a forensic erase. +- **Retry cadence is a local traffic-analysis surface.** A queued send re-dials + the peer's onion on a backoff schedule while the app runs. Still **fail closed** (no queue, no retry): @@ -188,137 +257,95 @@ Still **fail closed** (no queue, no retry): - Arti cannot publish the onion (no C-tor fallback) - no DHT, no name server, no hosted chat server -## Chat ratchet (per friend, on device) +## Chat ratchet -Chat is ratcheted on top of the Noise session: each chat send is -Double-Ratchet encrypted first, and the resulting `rat ` frame is what the -one-shot Noise session carries. Forward secrecy is per chain, and a snapshot of -one side's state stops reading the conversation at the next DH ratchet step. -The wire format and the honest limits are in -[docs/PROTOCOL.md](docs/PROTOCOL.md) and -[docs/THREAT_MODEL.md](docs/THREAT_MODEL.md). +Chat is ratcheted on top of the Noise session: each chat send is Double-Ratchet +encrypted first, and the resulting `rat ` frame is what the one-shot Noise +session carries. Wire format: [docs/PROTOCOL.md](docs/PROTOCOL.md). -- Per-friend state lives in the encrypted store (`ratchet_sessions`, one row per - friend). Nothing about it is transmitted, so the "no relay, no server queue" - rule is unchanged. -- Message numbers, ratchet keys and chain state ride *inside* the Noise - ciphertext; there is nothing new to observe on the wire. -- **Only chat is ratcheted.** `loc`, `prf`, `inv`, `rcp`, `tip` and file chunks - keep the one-shot Noise shape. +- Per-friend state lives in the encrypted store (`ratchet_sessions`). Nothing + about it is transmitted. +- **Only chat is ratcheted.** `loc`, `prf`, `inv`, `rcp`, `tip`, `png`, and + `fil` keep the one-shot Noise shape. - Out-of-order delivery works (bounded skipped keys: 2000 per chain jump, 2000 - stored, oldest-first eviction; a used key is deleted, so a replay fails - closed). A queued chat message re-sends the *same* `rat ` frame, so an outbox - retry never burns a second chain key. -- `/wipe` clears chat, payments and outbox rows but **keeps** the ratchet state - (roster and identity stay), so chat continues on the same epoch. `/wipe-all` - removes the data dir and the state with it. -- **Session reset.** There is no `/reset` command and no in-band reset in - v0.2.1. The state is dropped automatically when the friend's prekey changes — - i.e. when you `F3`-paste a refreshed invite — and the next chat frame - bootstraps a fresh epoch. That re-paste is the only recovery path today. -- **Desync today is quiet.** An inbound `rat ` frame that does not authenticate - is logged as `rat dropped ()` on stderr and dropped: no chat row, no - TUI marker, nothing stored. A send-side failure surfaces as the usual - `send failed: …` status note. There is no in-app "ratchet desynced" banner - yet, so a desync is diagnosed from the terminal the app was started in. + stored). A queued chat message re-sends the *same* `rat ` frame. +- `/wipe` clears chat, payments and outbox but **keeps** ratchet state. `/wipe-all` + removes the data dir. +- There is no `/reset`. State drops when the friend's prekey changes (you + `F3`-paste a refreshed invite). +- An inbound `rat ` frame that does not authenticate is logged as + `rat dropped ()` on stderr and dropped. There is no in-app desync banner. ## File transfer `/file /path` sends a local file to the selected friend. Both must be online. -Cap 1 MiB on send and receive. Fail closed: a bad chunk or hash mismatch -deletes the partial (never overwrite). Files land in -`$ONIONWIRE_HOME/inbox//`. Chat shows `[file] name (N bytes)`, -never raw frames. File transfer is **not** covered by the chat outbox — no -resume, no images in the TUI. +Cap 1 MiB (`file::MAX_BYTES`). Fail closed: a bad chunk or hash mismatch deletes +the partial. Files land in `$ONIONWIRE_HOME/inbox//`. Chat shows +`[file] name (N bytes)`. Not covered by the chat outbox. ## Profile -`/profile` edits your friend-visible display name, bio, and optional Monero address (64 / 512 byte limits, no images). Enter saves and one-shot sends a signed `prf` frame to the selected friend. `F5` or `/who` shows their last signed profile. There is no directory: unknown pubkeys are ignored. +`/profile` edits your friend-visible display name, bio, and optional Monero +address (64 / 512 byte limits, no images). Enter saves and one-shot sends a +signed `prf` frame to the selected friend. `F5` or `/who` shows their last signed +profile. Unknown pubkeys are ignored. ## Monero (opt-in) -Chat does not need a wallet. Spend is opt-in at wallet create/restore; default -is no spend key, no seed on the device. Optional JSON-RPC to `monero-wallet-rpc` on -loopback (you run it, or the app spawns it). Chain source is your choice: a -spawned local `monerod`, or a daemon address you supply. The wallet **must** -use `--rpc-login`; OnionWire refuses an open RPC (HTTP 200 without a Digest -challenge) and refuses URLs with no credentials. +Chat does not need a wallet. Spend is opt-in at wallet create/restore. Optional +JSON-RPC to `monero-wallet-rpc` on **loopback only** (you run it, or the app +spawns it). Chain source is your choice: spawned local `monerod`, in-process +Cuprate (opt-in feature, **unvalidated on mainnet**), or a daemon address you +type. The wallet **must** use `--rpc-login`; OnionWire refuses an open RPC and +refuses URLs with no credentials. Wallet RPC is never on clearnet and never over +`.onion`. `--trusted-daemon` is never passed. + +The app-owned local daemon RPC port is **18081**. **18089** is a daemon's +*restricted*-RPC port and belongs only in examples of a *remote* address you type. ```bash -# monero-wallet-rpc --rpc-bind-ip 127.0.0.1 --rpc-bind-port 18083 --rpc-login onionwire:secret +# externally run wallet RPC (migration path) export ONIONWIRE_WALLET_RPC=http://onionwire:secret@127.0.0.1:18083 -# or keep the password out of the URL: +# or: export ONIONWIRE_WALLET_RPC=http://127.0.0.1:18083 export ONIONWIRE_WALLET_RPC_LOGIN=onionwire:secret ``` -Loopback only, HTTP Digest (RFC 2617, matching `--rpc-login`), 5s timeout, 1 MiB response cap. `.onion` RPC URLs are rejected (no Arti dial; do not point this at a remote wallet). Unset → chat still works; `/pay`, `/tip`, and `F6` say so. Do not log the RPC password. - -**Prefer a view-only wallet.** OnionWire only needs invoices and receipt checks -(`create_address` / `get_transfers`); it does not need spend authority. Set -`ONIONWIRE_WALLET_NO_SPEND=1` (or `true` / `yes` / `on`) to refuse `/tip` -locally before any RPC dial — `/pay` and receipt verification keep working. -Details: [docs/WALLET.md](docs/WALLET.md). - -Payment frame summary: +Prefer `ONIONWIRE_WALLET_NO_SPEND=1` until you actually want `/tip`. Details: +[docs/WALLET.md](docs/WALLET.md). | Command | Wire frame | What it does | |---|---|---| -| `/pay [memo]` | `inv ` | Invoice to receive. We want to be paid. Uses a wallet subaddress if RPC is up, else the profile `xmr_addr`. | -| `/tip [memo]` | `rcp ` + `tip ` | Pay the selected friend. Sends a Monero `transfer`, then a signed receipt claim and a tip frame. Disabled under `ONIONWIRE_WALLET_NO_SPEND`. | +| `/pay [memo]` | `inv ` | Invoice to receive. Subaddress if RPC is up, else profile `xmr_addr`. | +| `/tip [memo]` | `rcp ` + `tip ` | Chain `transfer`, then signed receipt and tip. One-shot. Disabled under `ONIONWIRE_WALLET_NO_SPEND`. | -- `/pay` sends a signed `inv` frame one-shot (both sides must be online). -- `/tip` does the chain transfer first, then sends a signed `rcp` frame **and** a `tip` frame — both one-shot. Peer onion down → fails after the transfer. Not queued. +Peer onion down → `/pay` and `/tip` fail. A queued invoice does not exist. -## In-app wallet (create / import) - -`/wallet create` (F6 then `c`) generates a new spend-capable wallet on the RPC -(`create_wallet`), then shows the 25-word seed **once** for backup -(`query_key mnemonic`). Type `SPEND` to accept the spend-authority warning, set a -wallet passphrase, write the seed down, type `SEEN`. The seed is never pasted into -the composer or chat history — collect it on the dedicated screen. - -`/wallet import` (F6 then `i`) restores from an existing 25-word seed via -`restore_deterministic_wallet`. This is the only path that takes a user-supplied -secret. The seed is collected on its own screen. - -Both paths require the wallet RPC to be started with `--wallet-dir` (not only -`--wallet-file`); the in-app filename is `onionwire`. - -**Spend-authority warning** — unavoidable at create/restore: - -> An OnionWire instance pointed at a spend-capable `monero-wallet-rpc` is a local spend authority. Any process that can read the RPC credentials (env var, `/proc//environ`, shell history, a stored URL) can spend the wallet's balance, and `/tip` gives a chat peer a supported path to ask for a transfer. Prefer a view-only wallet or a separate low-balance hot wallet for spend. - -The wallet screen (`F6`) shows a receive address (fresh subaddress when the wallet is up, else the profile `xmr_addr`), the current balance, and up to 8 recent transfers. Press `r` (or Enter) to toggle a QR code of the receive address. `Esc` returns to the chat. +`F6` then `c` / `/wallet create` generates a spend-capable wallet and shows the +25-word seed **once**. `F6` then `i` / `/wallet import` restores from a seed. +Type `SPEND` then `SEEN` on create. The in-app filename is `onionwire`; the RPC +must be started with `--wallet-dir`. ## Backup / restore Losing `identity_sk` loses every friend relationship. -- `/backup /path` — type `BACKUP`, passphrase twice. Writes `owbak1` (Argon2id + ChaCha20-Poly1305). Onion is **not** in the file (locator is disposable; F4 after restore if needed). -- `/restore /path` — type `RESTORE`, passphrase. Overwrites self keys. **Does not rewrite the roster** — you may become a different person talking to old friends. - -Treat the backup file like the sqlite db. - -## Mixed versions - -0.1.2 peers store unknown plaintext as chat. A 0.2 sender of `prf ` / `inv ` / `rcp ` / `tip ` / `fil ` will leave a garbage line on an un-upgraded peer. Upgrade both sides. The Noise handshake is unchanged. +- `/backup /path` — type `BACKUP`, passphrase twice. Writes `owbak1` (Argon2id + + ChaCha20-Poly1305). Onion is **not** in the file. +- `/restore /path` — type `RESTORE`, passphrase. Overwrites self keys. **Does not + rewrite the roster.** ## Wipe -Composer (bottom of the roster screen): +- `/wipe` — type `WIPE`. Chat, payments, and outbox gone. Identity and friends stay. +- `/wipe-all` — type `WIPEALL`. Deletes the data dir. Next start is a **new person**. -- `/wipe` — confirm by typing `WIPE`. Chat and payments history gone (overwrite message bodies, drop `payments`, `VACUUM`, WAL checkpoint). Identity key and friends stay. Not a forensic erase (SSD wear-leveling). `/wipe-all` is the identity burn. -- `/wipe-all` — confirm by typing `WIPEALL`. Deletes the data dir. Next start is a **new person** (new identity key). Same disk caveat. Esc cancels. Nothing is wiped without confirm. +Not a forensic erase (SSD wear-leveling). Esc cancels. ## Uninstall ```bash -# binary (whichever you used) rm -f ~/.local/bin/onionwire ~/.cargo/bin/onionwire - -# optional: destroy identity, friends, and message log -# (same as /wipe-all — you become a new person next run) rm -rf ~/.local/share/onionwire ``` @@ -326,117 +353,76 @@ If you set `ONIONWIRE_HOME`, delete that directory instead. ## Seized laptop -The whole sqlite file is SQLCipher (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`). A 32-byte key is derived from the store passphrase with Argon2id over a per-install 16-byte salt in `store_salt` (mode 0600, in `ONIONWIRE_HOME`) and handed to SQLCipher as a **raw** key (`PRAGMA key = "x'…'"`) as the first statement after open. The file header, schema, `self.identity_sk`, friend public keys, locators, profiles and payment rows are all ciphertext on disk, so a disk grep of `onionwire.db` must not yield the message log, your identity key or your roster. A wrong or empty passphrase fails closed before any write; an encrypted store whose `store_salt` is missing refuses to open instead of guessing. v0.2.1 plaintext installs upgrade in place on the first open with the right passphrase; a wrong one leaves the plaintext file untouched. +The sqlite file is SQLCipher. A 32-byte key is derived from the store passphrase +with Argon2id over a per-install 16-byte salt in `store_salt` (mode 0600) and +handed to SQLCipher as a raw key. Chat bodies carry a second, row-bound +ChaCha20-Poly1305 layer. Unlock is fail-closed. At-rest encryption is not a +defense against a live compromise or an attacker who has your passphrase. +Pending outbox rows live in the same encrypted store as delivered chat. -Chat bodies carry a second, row-bound layer: ChaCha20-Poly1305 (`nonce || ciphertext` in `messages.plaintext`) with AAD `owmsg1 || friend_id_le64 || dir || 0x00 || row_id_le64`, plus a random 32-byte data key in `store_meta` wrapped with Argon2id from the same passphrase. Whole-file encryption does not stop someone who can write the file from moving one row's ciphertext into another row; the row-bound AAD does, and it stays. Unlock is fail-closed: wrong or empty passphrase does not open chat. Empty-AAD v0.2 blobs are rewrapped once on unlock; `list_messages` never falls back to empty AAD. - -At-rest encryption is not a defense against a live compromise: while OnionWire runs, the passphrase, the db key and decrypted rows are in process memory, and SQLCipher's page cache holds decrypted pages. Secret material (Noise/Ed25519/X25519 ephemerals, store key copies, TUI passphrase buffer) is zeroized with the `zeroize` crate when dropped; that shrinks the window, it does not close it. It also does not stop an attacker who has your passphrase. Pending outbox rows live in the same encrypted store as delivered chat — seizure *with* the passphrase can reveal messages that never left the device. `/wipe` deletes chat, payments and outbox history; it is not a forensic erase — SSD wear-leveling can keep copies. `/wipe-all` deletes the data dir (new identity). Ctrl-Q can clear history on the way out (`CLEAR`) without becoming a new person. - -Threat model: [`docs/THREAT_MODEL.md`](docs/THREAT_MODEL.md). +Threat model: [docs/THREAT_MODEL.md](docs/THREAT_MODEL.md). ## Android (SDK + APK) -Same repository, same protocol, separate product from the Linux TUI. An Android peer and a Linux peer that exchange invites interoperate — one protocol, not two. +Same repository, same protocol. An Android peer and a Linux peer that exchange +invites interoperate. -- **SDK** — `onionwire-sdk-.aar`. UniFFI Kotlin bindings over the same Rust crate the TUI runs on, plus `libonionwire_sdk.so` for `arm64-v8a`. `Wire.send()` returns `SendState.Sent` | `SendState.Queued`; chat rows carry `delivery` and `id`; `Wire.outbox(pubkey)` exposes attempt count and next attempt time so the UI can render `queued (try n/8, retry 45s)` without inventing a countdown. Explicit Tor lifecycle bindings (`shutdown`/`flush`/`torState`) stop, flush, and report observable Tor state. Another Android app can depend on the AAR directly. - - **Payment surface** — `sendInvoice(pubkey, amountXmr, memo)` for `/pay`-style invoices, `sendTip(pubkey, amountXmr, memo)` for `/tip`-style payments (chain transfer + signed `rcp` + `tip`), `walletBalance()`, `walletReceiveAddress()`, `walletRecentTransfers(cap)`, `createWallet(password)` (returns the 25-word seed once), `importWallet(password, seed)`, and `spendAuthorityWarning()`. All payments are one-shot; none are queued. See [crates/onionwire-sdk/README.md](crates/onionwire-sdk/README.md). -- **APK** — `onionwire--android-arm64-v8a.apk`. Kotlin + Jetpack Compose + Material 3 messenger that depends on `:sdk` and nothing else. Per-row delivery markers and a chat-level outbox footer match the TUI vocabulary. A foreground keep-alive service (ongoing notification) keeps the in-process Arti onion published and the outbox retry worker alive through Doze while the user wants the node reachable. The store passphrase can be remembered as an AES-256-GCM blob wrapped by the **Android Keystore** (StrongBox first, TEE/software fallback, labelled honestly). A Compose wallet route (receive QR, balance, transfers, create/import) and roster bottom actions are wired without dropping wipe-chat. +- **SDK** — `onionwire-sdk-.aar`. UniFFI Kotlin over the same Rust crate + the TUI runs. See [crates/onionwire-sdk/README.md](crates/onionwire-sdk/README.md). +- **APK** — `onionwire--android-arm64-v8a.apk`. Kotlin + Jetpack Compose. + Build notes: [android/README.md](android/README.md). -It is not a WebView, and `src/tui.rs` is untouched. The APK build itself is -amd64-only — the Pi runner is aarch64 Linux and cannot produce an APK. -[`.forgejo/workflows/android-release.yml`](.forgejo/workflows/android-release.yml) -is **dispatch-only** on this Forgejo (a CI-created tag does not wake it): after -the Linux `release` workflow finishes, dispatch `android-release` with that tag -so the amd64 job builds the APK/AAR and the Pi job attaches them (+ `.sha256`) -to the same Forgejo release. If that tag's release already exists and is missing -the APK, the workflow **joins** it instead of minting patch+1. Publish does not -run from amd64 dind: `POST /releases` from that egress returns 422 with an empty -body. +The APK build is amd64-only. After the Linux `release` workflow finishes, +dispatch `android-release` with that tag so the APK/AAR attach to the same +Forgejo release. ```bash -# one-time: sdkmanager platform 36 / build-tools 36.0.0 / ndk 28.2.13676358, -# rustup target add aarch64-linux-android, cargo install cargo-ndk -scripts/build-android-local.sh # -> dist/, with .sha256 files -PUBLISH_TAG=v0.2.1 scripts/build-android-local.sh # + upload to that release +scripts/build-android-local.sh # -> dist/, with .sha256 +PUBLISH_TAG=v0.14.0 scripts/build-android-local.sh # + upload to that release ``` -Every asset has a matching `.sha256` so `sha256sum -c` works. CI signs with the -repo-owned release keystore. A local run without those env vars still -debug-signs for sideload, not Play. Full build notes, the `minSdk 26` -rationale, the 16 KB page-size check and the signing story are in -[`android/README.md`](android/README.md). - ## Releases (maintainers) -Releases are **manual and batched**: no merge publishes anything, and neither -does a tag push. Cut one when a batch of work has reached a stopping point — -CI green on `main`, the feature set landed, no half-merged stack. Full policy -and procedure: [`docs/RELEASING.md`](docs/RELEASING.md) — it is two dispatches, -`release` (tag + Linux binaries) then `android-release` with that tag (APK + -AAR): on this Forgejo neither a tag push nor `workflow_call` can wake the -Android job. +Manual and batched: no merge publishes anything, and neither does a tag push. +Full procedure: [docs/RELEASING.md](docs/RELEASING.md). -Actions → release → Run workflow: +Actions → **release** → Run workflow: | Input | Meaning | |---|---| | `dry_run` | build + checksum both Linux binaries, no tag, no publish. Run this first. | | `bump` | `patch` / `minor` / `major` off the newest `v*.*.*` tag. Default `minor`. | -| `version` | explicit `X.Y.Z` (or `vX.Y.Z`) — overrides `bump`. | -| `tag` | rebuild / re-publish an existing tag instead of minting one. | +| `version` | explicit `X.Y.Z` — overrides `bump`. | +| `tag` | rebuild / re-publish an existing tag. | -Pass `tag` **or** `version`, not both; an unparseable version is rejected -rather than guessed at. The workflow computes the version, creates the tag over -the API (refusing to move an existing tag), builds aarch64 on the Pi runner and -x86_64 on the amd64 runner, and publishes all four assets (`onionwire-` -+ `.sha256`) to one release. Then dispatch `android-release` with that tag to -attach the APK + AAR to the same release (it has no automatic trigger on this -Forgejo — see `docs/RELEASING.md`). If a build or the publish fails, the core -run deletes the tag it created. Do not push tags by hand — -`release.yml` has no tag-push trigger, so a hand-pushed tag would build -nothing. +Then dispatch **android-release** with `tag=` to attach the APK + AAR. ```bash -# optional: keep Cargo.toml in sync with the tag the workflow will mint -# (the workflow does not edit Cargo.toml) - -# offline x86_64 fallback (idempotent — safe to re-run) -FORGEJO_TOKEN= scripts/build-release-local.sh v0.2.1 +FORGEJO_TOKEN= scripts/build-release-local.sh v0.14.0 ``` -Workflows (Forgejo Actions, `.forgejo/workflows/`): - -- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — two jobs on the Pi runner (`docker` label), serialized by `onionwire-ci-pi`. `test`: `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` at the repo root. `sdk`: the same for `crates/onionwire-sdk` (separate cargo workspace — own `Cargo.lock`, root crate by path, so a root signature change cannot silently break the Android SDK). Both run on `main` and PRs when `src/`, `crates/`, `tests/`, `Cargo.toml`, `Cargo.lock`, or this workflow change (ignored Tor-live tests are not run). `workflow_dispatch` always runs the suite. -- [`.forgejo/workflows/android-ci.yml`](.forgejo/workflows/android-ci.yml) — the android side of CI, on the `docker-amd64` runner: builds `:sdk:assembleRelease` + `:app:assembleRelease` with the same script the release uses (`scripts/build-android-local.sh`, Rust for `aarch64-linux-android` via cargo-ndk + UniFFI bindings) and verifies the packaged `libonionwire_sdk.so`, checksums and APK badging. Debug keystore, no publish, no tag. Runs on `main` and PRs when `android/`, `src/`, `crates/`, `Cargo.toml`, `Cargo.lock` or `scripts/build-android-local.sh` change. Same concurrency group **and** the same runner volumes as `android-release.yml`, so a PR build never fights a release build over the SDK/NDK, cargo and Gradle caches. -- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — manual, batched release (`workflow_dispatch` only: `dry_run`, `bump`, `version`, `tag`): next tag, aarch64 (`docker`) + x86_64 (`docker-amd64`), one release, fail-closed tag delete on failure. Dispatch [`android-release.yml`](.forgejo/workflows/android-release.yml) with that tag to add the APK + AAR (no automatic trigger fires on this Forgejo; it is `workflow_dispatch` only). Concurrency group `onionwire-ci-pi` (same as `ci.yml`, `cancel-in-progress: false`) so cargo jobs do not overlap on the Pi. Amd64 dind is serialized by runner `capacity=1`. -- [`.forgejo/workflows/android-release.yml`](.forgejo/workflows/android-release.yml) — amd64-only Android build (dispatch-only on this Forgejo; wakes from an explicit `tag=` input, not a tag push). - -Scripts: - -- [`scripts/publish-release.sh`](scripts/publish-release.sh) — create-or-update a release and (re)upload assets via the Forgejo API. Needs `FORGEJO_TOKEN` (repo secret in CI, env locally). -- [`scripts/build-release-local.sh`](scripts/build-release-local.sh) — x86_64 build + strip + checksum + publish. -- [`scripts/build-android-local.sh`](scripts/build-android-local.sh) — Android AAR + APK build, checksums, optional publish (see the Android section above). -- [`scripts/release-body.md`](scripts/release-body.md) — release notes template (`@TAG@` is substituted). - -Do not run `cargo publish`; `publish = false`. CI needs the repo secret -`FORGEJO_TOKEN` (an instance user PAT with repo write) to publish releases. +Do not run `cargo publish`; `publish = false`. ## Troubleshooting | Symptom | What to do | |---|---| -| `GLIBC_… not found` | Binary is newer than your libc. Build from source (Option B). | -| `sha256sum: FAILED` | Re-download both the binary and `.sha256`; run the check in the same directory. | -| Hang on `bootstrapping Arti…` / `hs status: Bootstrapping` | Outbound network required. Combined Arti status can stay Bootstrapping through a 5 min HsDir upload round; OnionWire probes the onion and proceeds once a connect works. Still fail closed after 360s if neither a probe nor `DegradedReachable`/`Running` — no C-tor fallback. | -| `onionwire: unknown argument` | No subcommands. Flags are `--version` / `--help` only, then the TUI. | -| Blank / broken TUI | Run in a real terminal emulator, not `nohup` / systemd without a TTY. | +| `GLIBC_… not found` | Build from source (Option B). | +| `sha256sum: FAILED` | Re-download binary and `.sha256`; check in the same directory. | +| Hang on `bootstrapping Arti…` | Outbound network required. Fail closed after 360s. No C-tor fallback. | +| `onionwire: unknown argument` | No subcommands. `--version` / `--help` only, then the TUI. | +| Blank / broken TUI | Real terminal emulator, not `nohup` / systemd without a TTY. | | Two chats, same laptop | Separate `ONIONWIRE_HOME` per process. | -| Friend cannot find you after F4 | Expected if they were offline. They must F3-paste the new invite. Same `k` updates the row. | +| Friend cannot find you after F4 | Expected if they were offline. They F3-paste the new invite. | +| Wallet error says “open F7” | There is no F7. Use `F6` / `F9`, or set `ONIONWIRE_WALLET_RPC`. | ## Not in v1 -Prosody, XMPP, s2s, MAM, carbons, a **server-side** outbox / store-and-forward relay, multi-device, DHT / name server, QR codes, A/V. The **local** chat retry queue is in; it never leaves the device. Protocol lock: [docs/PROTOCOL.md](docs/PROTOCOL.md). +Prosody, XMPP, s2s, MAM, carbons, a **server-side** outbox / store-and-forward +relay, multi-device, DHT / name server, invite QR codes, A/V. The **local** chat +retry queue is in; it never leaves the device. Protocol lock: +[docs/PROTOCOL.md](docs/PROTOCOL.md). ## License -MIT \ No newline at end of file +MIT diff --git a/docs/ARTI_UPGRADE.md b/docs/ARTI_UPGRADE.md index 1ca8b85..bdb6c0f 100644 --- a/docs/ARTI_UPGRADE.md +++ b/docs/ARTI_UPGRADE.md @@ -46,8 +46,7 @@ notes / the crate's own `rust-version`, then raise it in the same PR: * `rust-version` in `Cargo.toml`, * `RUST_IMAGE` in `.forgejo/workflows/ci.yml` **and** `.forgejo/workflows/release.yml`, -* the "Rust 1.91+" line in `README.md` (owned by another PR right now — add it - when that lands, or ask the owner). +* the "Rust 1.91+" line in `README.md`. ## How this gets noticed @@ -118,8 +117,10 @@ issue the watcher files. descriptor upload, not a hang), probe-connect against a live HS, a byte pipe in both directions, restart, and the dormant/offline path. 7. Confirm the fail-closed path by hand if the publish wait changed at all: - with the write timeout still 360s, a peer whose onion is down must fail the - send. There is no outbox in v1 — the message must not be silently queued. + with the publish wait still 360s, if Arti cannot publish the onion the + process must exit (no C-tor fallback). Chat to a *reachable-HS but down peer* + is queued locally (`src/outbox.rs`) and retried; file transfer and payment + frames still fail immediately. There is no **server-side** outbox. 8. Rebuild the Android target. The root crate defaults to `rustls` now, so this is less about exercising a non-default feature than about proving the default still cross-compiles where OpenSSL does not exist: @@ -135,7 +136,9 @@ issue the watcher files. the plaintext should appear in Arti's state directory. 10. Open a PR against `main` describing: crates bumped, MSRV, the live-test output, and anything upstream changed that touches `src/hs.rs`. Do not push - `main`; releases are minted by `.forgejo/workflows/release.yml` from a merge. + `main`. Releases are **manual and batched**: dispatch + `.forgejo/workflows/release.yml` (`dry_run=true` first). A merge does not + mint a release. See [RELEASING.md](RELEASING.md). ## Rolling back diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index 3481c11..07c07fd 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -4,7 +4,7 @@ This is the wire protocol. A second implementation should be able to interoperate from this document without reading the Rust. It is **not** an IETF RFC. It describes what this repository speaks today -(`frame::VERSION` 1, invite scheme `onionwire:v1`). There has been no public +(frame version 1, invite scheme `onionwire:v1`). There has been no public third-party audit. Arti onion services are experimental upstream. Related: [threat model](THREAT_MODEL.md), [audit notes](SECURITY_AUDIT.md). @@ -46,7 +46,7 @@ not on the wire. ## Transport 1. Each peer publishes a Tor v3 onion service (in-process Arti in this tree). -2. Application port is **80** (`HS_PORT`). +2. Application port is **80**. 3. The sender opens a Tor circuit to `(friend.onion, 80)`, runs the handshake, sends **one** application frame, and drops the circuit. 4. File transfer is N independent sessions (one handshake per chunk). There is @@ -58,12 +58,11 @@ at 30 min; 8 attempts, then terminal `Failed`). There is no server and no store-and-forward relay: each attempt is a fresh handshake straight to `(friend.onion, 80)`, exactly as above. Retries fire on a timer, on unlock/foreground, and whenever that peer is heard from (successful handshake or -`connect_onion()`). A protocol failure — signature mismatch, unknown frame, -oversize — is not a transport failure and is never queued. +a connect to that onion). A protocol failure — signature mismatch, unknown +frame, oversize — is not a transport failure and is never queued. File transfer and payment frames stay fail-closed: they are one-shot and are -**not** queued. The locator-push path still retries for 180 seconds and then -gives up. +**not** queued. The locator-push path retries for 180 seconds and then gives up. Incoming rendezvous accepts are token-bucket limited: 30 per 60s, burst 10. Excess is dropped before handshake. That is availability, not anonymity. @@ -99,7 +98,7 @@ from the invite (or roster). 1. **IK msg 1** — initiator → responder (framed). Responder’s Noise static is the invite `spk`. -2. Responder looks up `get_remote_static()` in the roster **by prekey**. +2. Responder looks up the remote static in the roster **by prekey**. Unknown prekey → close. This is how the answerer learns who is calling. 3. **IK msg 2** — responder → initiator (framed). 4. Both sides enter transport mode. Handshake hash `h` is 32 bytes (BLAKE2s). @@ -137,13 +136,14 @@ After decrypt, classify the plaintext: | Prefix (4 bytes) | Kind | If unknown / invalid | |---|---|---| +| `rat ` | Double Ratchet chat frame (see Ratchet) | drop | | `loc ` | locator update | drop | | `prf ` | profile | drop | | `inv ` | Monero invoice | drop | | `rcp ` | Monero receipt claim | drop | -| `png ` | ping (reserved) | drop | +| `tip ` | Monero tip (receipt + memo) | drop | +| `png ` | ping (reserved; classify and drop) | drop | | `fil ` | file chunk | drop | -| `rat ` | Double Ratchet chat frame (see Ratchet) | drop | | `[a-z][a-z][a-z] ` | unknown typed frame | **drop** (not chat) | | anything else | chat | store as a chat line | @@ -153,8 +153,7 @@ chat line. Older builds that stored `rat `-prefixed bytes as chat are obsolete; upgrade both sides. A peer that does not implement a typed prefix MUST still drop -`[a-z]{3}…` rather than render it as chat. Mixed-version 0.1.2 clients -that stored those as chat are obsolete; upgrade both sides. +`[a-z]{3}…` rather than render it as chat. Chat MUST NOT begin with three lowercase ASCII letters and a space. (Inside a `rat ` frame the plaintext is a chat line and is not re-classified.) @@ -170,6 +169,9 @@ form (type tag, then each field, `0x00` separators). Verify MUST accept that form and, for mixed-version peers, the legacy untagged LF-joined layout. Anything else fails closed. Do not emit the legacy layout. +`tip` is signed over the LF-joined fields only (no domain tag on encode today). +The `tip ` prefix is not signed. + The invite string is separate and keeps `onionwire-invite-v1` (see Invite). Older builds verify only the untagged bytes, so they reject tagged signatures @@ -255,7 +257,8 @@ ed25519_sign(identity_sk, accepted on verify. New invoices MUST use the domain-separated form. Do not emit legacy. -The frame is a signed claim, not a payment. +The frame is a signed claim, not a payment. It is one-shot: if the peer onion +is down, the send fails. There is no queued invoice. ### `rcp ` — receipt claim (we paid) @@ -279,8 +282,32 @@ emit legacy. Signature proves which friend sent the claim. It does **not** prove money moved. Local `verified=1` only if a user-hosted `monero-wallet-rpc` returns one transfer row with the same non-empty `txid`, `amount`, and `address` -(conjunction, not OR). RPC down → stay unverified. Wallet RPC is loopback -HTTP Digest; it is not this protocol. +(conjunction, not OR). RPC down or an unsynced daemon → stay unverified. +Wallet RPC is loopback HTTP Digest; it is not this protocol. + +### `tip ` — tip (we paid, with memo) + +Sent after a chain transfer, together with `rcp `. One-shot. + +``` +tip \n\n
\n\n\n +``` + +The `tip ` prefix is **not** signed. Encode signs the LF-joined fields: + +``` +ed25519_sign(identity_sk, + txid || LF || amount_atomic || LF || address || LF || memo || LF || ascii(ts)) +``` + +`memo` MUST NOT contain newlines. Same address and amount rules as invoices. +A peer that does not implement `tip ` MUST drop it as an unknown typed prefix, +not render it as chat. + +### `png ` — ping (reserved) + +Classified as ping and dropped. No ping body is defined in v1. Implementations +MUST NOT emit `png ` and MUST drop it inbound. ### `fil ` — file chunk @@ -288,11 +315,10 @@ Cap: 1 MiB reconstructed file. No resume. One Noise session per chunk. The sender is responsible for fitting the receiver's documented rendezvous budget (30 accepts / 60s, burst 10). Chunks MUST be paced so the average -interval between send attempts stays at least 3s — a margin under the 0.5/s -refill; pacing at exactly 2s sits on the refill boundary and drains under -jitter. A sender MAY retry an individual chunk a bounded number of times. -Exhausting retries fails the transfer. No outbox, no resume, no continuation -under a new `xfer_id`. +interval between send attempts stays at least 3s. A sender MAY retry an +individual chunk a bounded number of times (this tree: 3). Exhausting retries +fails the transfer. No outbox, no resume, no continuation under a new +`xfer_id`. ``` fil \n\n\n/\n @@ -314,7 +340,7 @@ is a chat line `[file] name (N bytes)`, never the raw frame. A chat send is ratcheted: the wire form of a chat message is a `rat ` frame (see “Ratchet (v1 chat layer)”), and the plaintext inside that frame is the chat line below. A bare chat frame with no typed prefix is still accepted inbound as -a chat line (v0.2.1 peers), but MUST NOT be emitted. +a chat line (older peers), but MUST NOT be emitted. UTF-8 is not enforced for chat text: invalid bytes become U+FFFD (the implementation does not drop the row). Control and bidi formatting @@ -334,9 +360,7 @@ one application frame, close — see Transport). Nothing else changes about the session. The ratchet header is **inside** the Noise transport message, never in clear on -the wire. That is a deliberate divergence from the shape this layer came from: -the plan assumed a plaintext header (`dh_pub || N || PN`) ahead of the -ciphertext, which was rejected because a plaintext header would hand an observer +the wire. A plaintext header (`dh_pub || N || PN`) would hand an observer per-message counters and ratchet-key changes for no benefit — the Noise session already hides the frame, so the header is authenticated as AEAD associated data instead. @@ -386,9 +410,8 @@ KDF_CK(chain_key): next_chain_key = HMAC-SHA256(chain_key, 0x02) ``` -`HKDF` is RFC 5869 with SHA-256 (`hkdf` 0.12), `HMAC` is SHA-256 (`hmac` -0.12). Each side of an epoch derives its chains from one shared DH output with -`KDF_RK` called **twice**: +`HKDF` is RFC 5869 with SHA-256, `HMAC` is SHA-256. Each side of an epoch +derives its chains from one shared DH output with `KDF_RK` called **twice**: ``` epoch_chains(root, shared) -> (new_root, ck_lo, ck_hi): @@ -520,11 +543,9 @@ lets the peer step too. `ratchet_sessions` in the SQLCipher store: one row per friend (`friend_id` primary key, `FOREIGN KEY` → `friends.id` `ON DELETE CASCADE`, `state BLOB NOT NULL`, `updated_at`). The blob is version byte `0x01` followed by -the implementation's serialized `RatchetState` (root, keypairs, both chain keys -and counters, `established`, and the skipped-key store). The state is -device-local: it is **never** transmitted, and its layout is not part of this -wire protocol. The store is encrypted as a whole, so the blob is ciphertext on -disk. +the implementation's serialized ratchet state. The state is device-local: it is +**never** transmitted, and its layout is not part of this wire protocol. The +store is encrypted as a whole, so the blob is ciphertext on disk. ### Not ratcheted @@ -570,8 +591,13 @@ Unknown `k`: prompt. Same `k`: update onion and prekey only. ## What v1 will not grow into -No DHT, no hosted server, no XMPP, no store-and-forward, no multi-device, no -A/V, no STUN/ICE/WebRTC, no SOCKS/C-tor fallback, no system DNS for friends. +No DHT, no directory server, no hosted/server-side outbox, no XMPP/Prosody, no +C-tor fallback, no multi-device, no A/V, no STUN/ICE/WebRTC, no system DNS for +friends. + +A **local-only** chat retry queue is in v1. It is not a mailbox and it never +leaves the device. “No outbox” in this document means **no server-side** +store-and-forward. Those are how Tox-over-Tor leaks (UDP DHT, mixed clearnet, “just one direct path”). They are out of scope, not postponed. diff --git a/docs/README.md b/docs/README.md index f6ce9ab..eb2fdbe 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,8 +9,23 @@ Read these in order if you are evaluating the protocol without the Rust: 3. **[SECURITY_AUDIT.md](SECURITY_AUDIT.md)** — in-house review notes and which findings are still open. **Not** a public third-party audit. -Operator / product docs stay in the [root README](../README.md). Android -build notes: [android/README.md](../android/README.md). SDK: +Operator / product docs: + +- **[../README.md](../README.md)** — install, run, real flags, F-key map, + wallet/chain source, releases. +- **[TUI.md](TUI.md)** — screens and keybindings as the TUI actually handles them. +- **[WALLET.md](WALLET.md)** — loopback wallet RPC, chain source, spend-authority + warning, receipt verification. +- **[RELEASING.md](RELEASING.md)** — manual, batched releases (not one per merge). +- **[ARTI_UPGRADE.md](ARTI_UPGRADE.md)** — how to bump the in-process Tor crates. + +Android build notes: [android/README.md](../android/README.md). SDK: [crates/onionwire-sdk/README.md](../crates/onionwire-sdk/README.md). -Maintainers cutting a release: [RELEASING.md](RELEASING.md) — manual, batched -releases, not one per merge. + +Decision records and spike reports (history — not living operator docs): + +- [arti-socks-feasibility.md](arti-socks-feasibility.md) +- [option-a-recommendation.md](option-a-recommendation.md) +- [cuprate-launch-spike.md](cuprate-launch-spike.md) +- [cuprate-android-spike.md](cuprate-android-spike.md) +- [payment-integration-plan.md](payment-integration-plan.md) diff --git a/docs/RELEASING.md b/docs/RELEASING.md index fe6b3b6..206ff39 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -1,7 +1,10 @@ # Releasing OnionWire -Policy and procedure for cutting a release. Read -[`README.md`](../README.md#releases-maintainers) for the short version. +How a maintainer cuts a release. This is **not** automatic: a merge to `main` +does not publish, and a tag push does not publish. Two dispatches, `dry_run` +first, Android APK joins the same tag. + +Short version: [`README.md`](../README.md#releases-maintainers). ## Policy: manual, batched releases diff --git a/docs/SECURITY_AUDIT.md b/docs/SECURITY_AUDIT.md index 3c2322b..cab9d75 100644 --- a/docs/SECURITY_AUDIT.md +++ b/docs/SECURITY_AUDIT.md @@ -2,7 +2,7 @@ **This is not a public third-party audit.** It is an in-house review of commit `2b42864` plus a status check against the current tree. Do not cite it -as “audited.” +as “audited.” OnionWire has not had a public external security assessment. Protocol: [PROTOCOL.md](PROTOCOL.md). Claims: [THREAT_MODEL.md](THREAT_MODEL.md). @@ -26,10 +26,11 @@ Original pass: rust-dev, no live hidden service / live wallet. Ignored tests - At rest the whole store is SQLCipher (Argon2id key over a 16-byte `store_salt`), so the identity secret key, roster (pubkeys + locators) and chat bodies are ciphertext on disk; chat bodies add a row-bound AEAD layer on top. That is not a defense against a live compromise or an attacker who has the passphrase — see [THREAT_MODEL.md](THREAT_MODEL.md). - Arti onion services are experimental. Fail closed; no C-tor fallback. -- No public third-party audit, no `cargo-audit` gate in CI as of the original pass. +- No public third-party audit. This file is not one. - Invite decode still accepts the legacy concat signature (compatibility). - Rate limit is availability, not traffic-analysis defense. - One-shot sessions: no channel binding across file chunks beyond “same Noise peer.” +- The in-process Cuprate chain daemon is opt-in and **unvalidated on mainnet**. ## Verified correct (original pass, still the protocol) diff --git a/docs/THREAT_MODEL.md b/docs/THREAT_MODEL.md index 9fd2b6c..9781368 100644 --- a/docs/THREAT_MODEL.md +++ b/docs/THREAT_MODEL.md @@ -1,8 +1,10 @@ # OnionWire threat model (v1) OnionWire is a two-party chat over Tor onion services. There is no chat server. -Wire format: [PROTOCOL.md](PROTOCOL.md). In-house review notes: -[SECURITY_AUDIT.md](SECURITY_AUDIT.md) — **not** a public third-party audit. +Identity is an ed25519 pubkey; the onion is a locator only (`F4` rotates the +locator, nothing else). Wire format: [PROTOCOL.md](PROTOCOL.md). Wallet: +[WALLET.md](WALLET.md). In-house review notes: [SECURITY_AUDIT.md](SECURITY_AUDIT.md) +— **not** a public third-party audit. Do not cite that file as “audited.” ## Tor relays are not a chat server @@ -207,7 +209,9 @@ the app does not pick a public remote node for them. for any serious purposes"*, and its `monerod` RPC parity is incomplete (Cuprate issue #278). This is why the source is an opt-in build feature and a stored user choice, never a default. - - The config pins **testnet**. Mainnet is not validated by this app. + - Mainnet is **unvalidated**. The TUI can store a mainnet choice (`F6` 1/2); + every in-process surface still says `testnet only — mainnet is unvalidated`. + Cross-compiled is not device-proven. - Cuprate's own `arti` feature is off (its Tor stack is `arti-client` 0.44, which cannot unify with this crate's 0.46), so the in-process daemon's P2P traffic is **clearnet**: your ISP sees that this device talks to Monero diff --git a/docs/TUI.md b/docs/TUI.md index f7744a5..9c52c70 100644 --- a/docs/TUI.md +++ b/docs/TUI.md @@ -1,964 +1,183 @@ -# OnionWire TUI — visual audit and design spec +# OnionWire TUI -This card does not change `src/`. Frames come from: +Operator map of the Linux terminal UI. Bindings live in `src/tui.rs` +(`function_key_for`, `parse_cmd`, per-screen `match` arms). This is not a +screenshot dump. -``` -cargo test --locked --test tui_frames -- --nocapture dump_audit_frames -``` +Run `onionwire` in a real terminal. `ONIONWIRE_ASCII` or `NO_COLOR` switches +ASCII chrome. -`tests/tui_chrome.rs` still locks helper **names** and **return strings**. Implementation -must keep `wordmark_banner`, `compact_banner`, `banner_for_width`, `onion_glyph`, -`status_footer`, `main_footer_hints`, `help_overlay_text`, `draw_share`, and `Pane` -working. Add helpers; do not rename those. +## Screens -## Gaps (could not render the live `App` frame) +`enum Screen` in `src/tui.rs`: -`App`, `App::draw`, `App::draw_main`, and every overlay except `draw_share` are -private and need `Arc` (Arti + store). This presentation-only test cannot -construct that. - -| Screen / state | What you get | Why | +| Screen | How you get there | What it is | |---|---|---| -| Main chat (empty, messages, long line, stale roster, alert) | **RECONSTRUCTED** at the time of the audit; since the clean-look redesign (`draw_main_chrome`) it is **REAL** — see “Clean-look chrome redesign” below | `App` private | -| Help / `/who` overlay | **RECONSTRUCTED** — Rect math copied from private `draw_text_overlay` | private | -| Share / invite | **REAL** `draw_share` | public | -| Profile, paste, approve, rotate, wipe, quit, backup, restore, passphrase | **RECONSTRUCTED** — public `*_screen_text` / `ProfileEditor` copy inside `Block::bordered`, titles taken from `src/tui.rs` | private `draw_*` | -| Pay / invoice / file transfer | **No screen exists.** Footer `status_note` only (`invoice sent`, `sending`, `sent file {name}`, `send failed: {e}`) | not a gap in the test — a product finding | -| Tor bootstrap / disconnected HS | Not a TUI screen. `hs status: Bootstrapping` is stderr before `ratatui::init` | out of TUI draw | -| Color / `NO_COLOR` | Glyph dumps only. Color findings are from reading `src/tui.rs` | TestBackend prints symbols | - -Color, focus-by-border, and RGB-only styling are invisible in these dumps. Treat -the reconstruction as the glyph skeleton, not a screenshot of Color. - -## Deliverable 1 — before frames - -Trailing spaces in the live buffer are omitted here. Re-run the command for -byte-identical dumps, including 120x40 and 200x60. - -### 80x24 — chrome (`banner_for_width` + `status_footer`, real helpers) - -``` - .-~~-. .-~~-. .-~~-. ONIONWIRE - ( o )( o )( o ) identity = pubkey onion = locator - `-..-' `-..-' `-..-' tor messenger no server - - - - - -TOR me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help -``` - -Same footer with `status_note = "send failed: connection timed out"` — the note -**does not appear**. Ident + hints win. Fail-closed copy is gone at 80 and at -120 (full onion eats the row). It only survives at 200. - -### 80x24 — RECONSTRUCTED main, empty - -``` - .-~~-. .-~~-. .-~~-. ONIONWIRE - ( o )( o )( o ) identity = pubkey onion = locator - `-..-' `-..-' `-..-' tor messenger no server -┌roster 0───────────────────┐┌chat─────────────────────────────────────────────┐ -│ ││no friends yet │ -│ ││F3 paste an invite to add one │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -└───────────────────────────┘└─────────────────────────────────────────────────┘ -┌composer──────────────────────────────────────────────────────────────────────┐ -│/wipe /wipe-all /profile /who /pay /tip /file │ -└──────────────────────────────────────────────────────────────────────────────┘ -TOR me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help -``` - -### 80x24 — RECONSTRUCTED main, messages + stale + alert - -``` - .-~~-. .-~~-. .-~~-. ONIONWIRE - ( o )( o )( o ) identity = pubkey onion = locator - `-..-' `-..-' `-..-' tor messenger no server -passphrases do not match -┌roster 2 1 stale──────────┐┌chat alice──────────────────────────────────────┐ -│> alice aaaaaaaa… ││you: ping │ -│ bob-the-stale-peer bbbbb││them: pong │ -│ ││them: this is a very long chat line that should │ -│ ││wrap inside the chat pane instead of running off │ -│ ││the right edge of an 80-column terminal and │ -│ ││colliding with the roster border │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -└───────────────────────────┘└─────────────────────────────────────────────────┘ -┌composer──────────────────────────────────────────────────────────────────────┐ -│hello from composer │ -└──────────────────────────────────────────────────────────────────────────────┘ -sent TOR me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help -``` - -Roster clips `bob-the-stale-peer bbbbb` mid-glyph. Chat wraps (good). Focus on -chat/composer is **not** visible in the glyph dump (color-only in `pane_block`). - -### 80x24 — RECONSTRUCTED main, fail-closed send (note dropped) - -``` - .-~~-. .-~~-. .-~~-. ONIONWIRE - ( o )( o )( o ) identity = pubkey onion = locator - `-..-' `-..-' `-..-' tor messenger no server -┌roster 2 1 stale──────────┐┌chat bob-the-stale-peer─────────────────────────┐ -│ alice aaaaaaaa… ││no messages │ -│> bob-the-stale-peer bbbbb││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -└───────────────────────────┘└─────────────────────────────────────────────────┘ -┌composer──────────────────────────────────────────────────────────────────────┐ -│/wipe /wipe-all /profile /who /pay /tip /file │ -└──────────────────────────────────────────────────────────────────────────────┘ -TOR me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help -``` - -`status_note` was `send failed: peer onion down`. The before frame above drops it. -`tests/tui_frames.rs` `status_footer_drops_send_failed_when_crowded` now asserts -the note **is** present at 80, 120, and 200, along with `TOR` / `me:` / `? help`. - -### 80x24 — `draw_share` (real) - -Invite is 346 chars. Inner width 78. Wraps mid-hex. Full v3 onion fits on its -own line. No QR blocks (locked). - -``` -┌(o) invite────────────────────────────────────────────────────────────────────┐ -│give this string to a friend; they F3 paste it │ -│ │ -│fp ea4a6c63… │ -│onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion │ -│ │ -│onionwire:v1:k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22│ -│c:o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion:spk=0101010│ -│101010101010101010101010101010101010101010101010101010101:sig=46caf16b6da95e86│ -│… │ -└──────────────────────────────────────────────────────────────────────────────┘ -``` - -### 80x24 — RECONSTRUCTED help overlay (private `draw_text_overlay` math) - -Help is 22 content lines + border. Popup height is `min(lines, height-2)` = 22, -so it covers the banner, punches through roster/composer borders, and **clips** -`Esc closes this overlay`. - -``` - .-~~-. .-~~-. .-~~-. ONIONWIRE - ( o ┌? help─────────────────────────────────────────────────────────┐ - `-..-' │OnionWire keys │ -┌roster│ │───────┐ -│ │Tab / Shift-Tab cycle roster, chat, composer │ │ -│ │… │ │ -│ │/backup /path encrypted identity export │ │ -└──────│/restore /path overwrite self keys │───────┘ -┌compos│? this help │───────┐ -│/wipe │Ctrl-Q quit; type CLEAR or QUIT │ │ -└──────└───────────────────────────────────────────────────────────────┘───────┘ -TOR me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help -``` - -### 80x24 — other overlays (copy is real) - -- Profile: `> name:` marker (good). Empty xmr is a blank value, not `(none)`. -- Paste: same wrap-mid-hex as share. Error state replaces the hint with the - error string (no "what next"). -- Approve / rotate / wipe / quit / backup / passphrase: full-screen bordered - column of copy + typed buffer. Readable. Fine as modal confirmations. -- `/who`: overlay Clear is only the popup rect; chat remnants (`d`, `ff`) show - in the side gutters. Full onion is shown (good). - -### 120x40 / 200x60 - -At 120, `status_footer` shows the **full** 62-char onion and still drops -`send failed: …`. At 200 the note survives in front of `TOR`. Banner stays the -3-line wordmark (width ≥ 63). Chat pane is large; hierarchy problem is worse -(more empty bordered void), not better. Dump: same cargo command. - -## Deliverable 2 — findings - -Walked in `tui-aesthetics` ladder order. - -### 1. Clipping / overlap - -| Sev | Where | Wrong | User impact | -|---|---|---|---| -| **blocker** | `src/tui.rs:1505` `status_footer` candidate list | Fail-closed `status_note` (`send failed: …`) is skipped when ident+hints fill the row. Proven at 80 and 120. | Peer down looks like success. The product rule is "send visibly fails". | -| **major** | `src/tui.rs:1702` `draw_text_overlay` | No `Wrap`. Height clipped to `area.height-2`. At 80x24 help overlaps banner/roster/composer and drops the last line. | `?` is unreadable on the floor size. | -| **major** | `src/tui.rs:1355` roster `format!("{name} {fp}")` | No truncate. `bob-the-stale-peer bbbbb` clips inside the 36% pane. | Cannot tell who is selected/stale. | -| **major** | `src/tui.rs:1570` `draw_share` (and paste body) | 346-char invite wraps mid-token at inner width 78. | Mouse-select copy is split; easy to miss a continuation line. | -| **minor** | `src/tui.rs:1334` alert | Alert is one raw line, no wrap/truncate. | Long error will collide with roster on the next row. | -| **nit** | `tests/tui_chrome.rs:15` (and `src/tui.rs:1512`, `1707`) | Width via `chars().count()`. See deliverable 4. | CJK/emoji can wrap in a real terminal while tests stay green. | - -### 2. Hierarchy - -| Sev | Where | Wrong | User impact | -|---|---|---|---| -| **major** | `src/tui.rs:1314` `draw_main` | Three-line wordmark + two equal bordered panes + bordered composer + footer. Chat is not the primary element. At 80x24, 3 rows of art + 3 composer + 1 footer + 2×2 borders leave the transcript starved. | First glance is ASCII onions, not the conversation. | -| **major** | `src/tui.rs:1340` | Roster is 36% of width on every size. | Chat (the primary pane) is the leftover. | -| **minor** | every `themed_block` / `pane_block` | Border on every pane, including composer and full-screen modals. | Eye cannot find content; "box drawing UI". | - -### 3. Spacing - -| Sev | Where | Wrong | User impact | -|---|---|---|---| -| **minor** | `src/tui.rs:1328` banner vs `1367` lists | Banner has no inner pad; list/paragraph sit against borders; footer has no pad. Mixed 0 and 1. | Ragged left edge: chat `no friends yet` vs roster empty. | -| **nit** | `src/tui.rs:93` `/file /path` extra space vs other slash rows | Help columns almost align, one extra space. | Looks unfinished. Do **not** change `help_overlay_text` unless `tui_chrome` is updated — the string is locked. Leave the space. | - -### 4. States - -| Sev | Where | Wrong | User impact | -|---|---|---|---| -| **major** | `src/tui.rs:1349` empty roster | `List` with zero items → blank pane titled `roster 0`. Empty copy lives only in chat. | Looks broken, not empty. | -| **major** | pay / tip / file | No pane. Outcome is a footer note that 80/120 may drop. | `/pay` and `/file` feel like they did nothing. | -| **minor** | `src/tui.rs:1414` empty composer | Placeholder is the slash cheatsheet, dim color only. | Reads as commands already typed. | -| **minor** | `src/tui.rs:1456` `no messages` | One word. No "type below, Enter sends". | Dead pane. | -| **nit** | loading | `sending` in footer, 100 ms poll, no spinner. | Correct. Keep. | - -There is no dedicated disconnected screen. Stale friends get a `stale` suffix -(`src/tui.rs:1357`) — keep the word, not color-only. - -### 5. Color - -| Sev | Where | Wrong | User impact | -|---|---|---|---| -| **major** | `src/tui.rs:15-21` | Seven RGB colors. No 16-color map. No `NO_COLOR`. | 16-color and `NO_COLOR` terminals get garbage or still emit ANSI. | -| **minor** | `src/tui.rs:1359-1372` | Stale is `C_STALE` plus the word `stale` (ok). Selection is bg+fg+bold+`> ` (ok for roster). | Chat/composer focus is color-only (see focus). | - -Accent RGB `(232,165,75)` is fine as **the** accent. Do not add more hues. - -### 6. Focus - -| Sev | Where | Wrong | User impact | -|---|---|---|---| -| **major** | `src/tui.rs:1468` `pane_block` | Focused chat/composer: accent border + bold title. No marker. Roster has `> `. | Monochrome / `NO_COLOR`: cannot see focus unless roster. Typing `j`/`k` feels dead. | - -### 7. Motion - -| Sev | Where | Wrong | User impact | -|---|---|---|---| -| **nit** | `src/tui.rs:24` `TUI_POLL` 100 ms | Full `terminal.draw` every poll even with no keys, so background send can refresh status. | Acceptable. No decorative spinner. Do not redraw faster. | - -### 8. Copy - -| Sev | Where | Wrong | User impact | -|---|---|---|---| -| **minor** | `src/tui.rs:1583` paste error | Error replaces the paste hint. No "what next". | User sees `bad invite` and an empty buffer. | -| **minor** | `src/tui.rs:1415` | Composer placeholder is a command dump, not a verb. | Conflicts with `?` help. | -| **nit** | `src/tui.rs:36` | `fingerprint mismatch` is a good short fail-closed string when it actually reaches the footer. | Often dropped (finding 1). | - -### Untrusted text - -`src/tui.rs:1461` `String::from_utf8_lossy(&m.plaintext)` goes into `Paragraph` -with wrap, **no** control/bidi strip, **no** ellipsis cap. Profile `bio` / -`display_name` and paste buffer are the same class. A separate in-flight PR -owns sanitization — do not duplicate it here. Implementation must call that -helper (or the agreed strip) on every peer-supplied string before draw. - -## Deliverable 3 — spec (implement this) - -### Pane structure - -One primary element per screen. - -| Screen | Primary | Secondary | Chrome | -|---|---|---|---| -| Main | Chat transcript | Roster (left, **22 cells** at 80, **28** at 120+, not 36%) | 1-line header, 3-row composer, 1-row status | -| Share / paste / approve | The invite string / typed buffer | fp + onion above it | title `(o) invite` etc. Keep `draw_share` public | -| Profile | The three fields with `>` on the active one | — | title `(o) profile` | -| Rotate / wipe / quit / backup / restore / passphrase | The confirm copy + typed token | — | existing titles | -| Help | The help text, **full screen** when `height < 28`, else a centered overlay that **fits** (wrap, scroll if needed, never clip the last line) | — | title `? help` | -| `/who` | Profile fields | — | same overlay rules as help | -| Pay / file | **None.** Stay on main. Status line carries the result. | — | — | - -`draw_main` at `height <= 24` **must not** spend 3 rows on `wordmark_banner()`. -Use a one-line header. Do **not** change `banner_for_width(80)` — chrome tests -lock it to the wordmark. Add `main_header_line(width, fp, onion)` or call -`compact_banner()` plus ident. At `height >= 40`, the 3-line wordmark **may** -sit above the one-line ident; it is optional, not required. - -### Spacing unit - -**1 cell.** Apply as: - -- Header: no box. One space between fields. -- Roster / chat: `Block` with `Borders::ALL` **only on those two** (the primary - split). Inner text starts one cell after the border (ratatui default). -- Composer: **no** outer box. Prefix `> ` when focused, ` ` when not. One - blank row is not required; the 3-row slot stays for wrapped input. -- Footer: no box. One space between clusters, two spaces between clusters if - width ≥ 120. -- Overlays: one box around the popup. No nested padding. - -### Palette - -One accent. Semantic color only for state. Pair every color with a glyph or -label. - -| Role | RGB (keep) | 16-color | `NO_COLOR` | -|---|---|---|---| -| accent | `Rgb(232,165,75)` | `Yellow` | default + bold / reverse | -| text | `Rgb(196,214,176)` | `White` | default | -| dim | `Rgb(98,110,92)` | `DarkGray` | default | -| alert | `Rgb(220,80,70)` | `Red` | default + `! ` prefix | -| stale | `Rgb(210,180,80)` | `Yellow` | default + ` stale` (already) | -| highlight bg | `Rgb(48,42,28)` | `Reverse` | reverse | -| border | `Rgb(72,84,64)` | `DarkGray` | default | - -`NO_COLOR` set (empty or any value): no `Style` fg/bg at all. Glyphs and -weight only. - -Detection: `std::env::var_os("NO_COLOR")` is Some → no color. Else if the -backend is not a TTY or `TERM=dumb` → 16-color or no color, never RGB. -Else RGB as today. - -### Glyphs - -| Use | Unicode | ASCII fallback | +| `Main` | boot | Roster, chat, composer | +| `Share` | `F2` | Invite string (`onionwire:v1:…`) | +| `Paste` | `F3` | Paste a friend's invite | +| `Approve` | paste of unknown `k` | `y` accept / `n` reject | +| `Rotate` | `F4` | Type `ROTATE` to change the onion locator | +| `RotatePrekey` | `F8` | Type `ROTATE` to hard-cut the Noise static | +| `Wipe` | `/wipe` or `/wipe-all` | Type `WIPE` or `WIPEALL` | +| `Profile` | `/profile` | Edit name, bio, optional Monero address | +| `ConfirmKeys` / `Passphrase` | `/backup`, `/restore` | Type `BACKUP`/`RESTORE`, then passphrase | +| `Wallet` | `F6` | Receive QR, balance, transfers, child, chain source | +| `WalletSetup` | `F6` `c` / `i`, or `/wallet create` / `import` | Spend warning, seed, import | +| `WalletsSettings` | `F9` or `/settings` | Discovery menu (does not replace F-keys) | +| `PeerPayments` | F9 then `p` | Peer-scoped `/pay` / `/tip` history | +| `Quit` | `Ctrl-Q` | Type `CLEAR` or `QUIT` | + +Help (`?`) is an overlay, not a screen. `/who` / `F5` is an overlay on Main. + +There is **no `F7`**. Function keys that fire from Main, the settings menu, and +peer-payments are: + +| Key | `FunctionKey` | Action | |---|---|---| -| onion / share title | `(o)` (already) | `(o)` | -| focus | `> ` | `> ` | -| truncate | `…` (`src/tui.rs:1730`) | `...` (budget 3 cells) | -| box | ratatui `Borders::ALL` (light) | `+` `-` `\|` via `border::Set` | -| alert prefix | `! ` | `! ` | -| stale | word `stale` | `stale` | -| delivery: delivered | `✓` | `ok` | -| delivery: queued | `◷` | (word) `queued` | -| delivery: sending | `»` | (word) `sending` | -| delivery: failed | `✗` | (word) `failed` | +| `F2` | Share | Invite | +| `F3` | Paste | Paste invite | +| `F4` | Rotate | Onion locator | +| `F5` | Who | Selected friend's profile | +| `F6` | Wallet | Wallet screen | +| `F8` | RotatePrekey | Prekey hard cut | +| `F9` | OpenMenu | Wallets & settings | -`queued` / `sending` / `failed` always carry their state word, so the ASCII -fallback drops the glyph instead of inventing one. Only `✓` is wordless, so it -falls back to `ok`. `delivery_glyph()` / -`tests/tui_spec.rs::delivery_markers_have_exercised_ascii_fallbacks` exercise the -fallback path. +`F9` is live on Main, the settings menu, and peer-payments so a printed shortcut +never no-ops there. Other screens handle their own keys (Esc back, typed +confirms). -No emoji. `onion_glyph()` stays for callers that already use it; do not put it -on the main header. +## Main -ASCII chrome when `ONIONWIRE_ASCII` is set **or** when `NO_COLOR` is set (same -switch is enough; do not add a crate). +Focus starts on the composer. Footer hints (`main_footer_hints`): -### Focus +``` +Tab F2 F3 F4 F5 F6 F9 ? help Ctrl-Q +``` -Never color alone. +Pane-specific (`pane_footer_hints`): -- Roster: keep `highlight_symbol("> ")` + bold. Unselected rows start with two - spaces so columns align. -- Chat: title becomes `> chat {name}` when focused, ` chat {name}` when not, - plus bold on the `> ` title. -- Composer: `> ` prefix on the input row when focused (see spacing). -- `Tab` cycle unchanged (`Pane` tests lock it). - -### `status_footer` priority (must change) - -Replace the current "first candidate that fits, dropping the note" list. - -Build left-to-right, **never drop** a non-empty `status_note`: - -1. `status_note` (truncate with `…`/`...` to a minimum of 12 cells if needed). -2. `TOR me:{8}…` (keep `me:` — chrome tests require it). -3. `onion:` + full onion if it fits, else 8-char truncate (keep today's - `width >= 110` full-onion rule if it still fits **after** the note). -4. Hints from `main_footer_hints()`, dropping from the left of that list. -5. Always end with `? help`. - -`? help` and `TOR` and `me:` must still be present at 80 and 120 so -`tests/tui_chrome.rs` stays green. - -Fail-closed copy is `send failed: {e}` or `fingerprint mismatch`. Prefix `! ` -when color is off. - -### Copy — non-happy states - -Do not soften fail-closed into a loader. - -| State | Copy | +| Pane | Hint | |---|---| -| no friends, roster | list item `no friends` (so the pane is not blank) | -| no friends, chat | `no friends yet` / `F3 paste an invite to add one` (keep) | -| friend, no messages | `no messages` / `type below, Enter sends` | -| nothing selected send | `no friend selected` (keep) | -| sending | `sending` (keep, no spinner) | -| sent | `sent` | -| peer down / send err | `send failed: {e}` (visible) | -| queued (outbox) | `{n} queued` — replaces the flat `sent`/`send failed` while rows are outstanding | -| queued + terminal failure | `{n} queued, send failed: {short}` | -| terminal failure | `send failed: {short}` (`{f} failed` when more than one) | -| already sending | `already sending` (keep) | -| stale friend | `stale` suffix (keep) | -| empty composer | `message` as dim placeholder (not the slash list). Slash list stays in `?` | -| paste error | `{err}` then `Enter resubmits Esc back` | -| unknown slash | `unknown command {cmd}` (keep) | -| passphrase mismatch | `passphrases do not match` (keep, alert line) | +| Roster | `j k select F3 add F6 wallet F9 settings ? help` | +| Chat | `j k scroll g G ends F4 rotate F9 settings ? help` | +| Composer | `Enter send / commands F9 settings ? help` | -### Before → after mockup (80x24 main) +| Key | Action | +|---|---| +| `Tab` / `Shift-Tab` | Cycle roster → chat → composer | +| `1` / `2` / `3` | Focus roster / chat / composer when not typing | +| `j` `k` / arrows | Move or scroll the focused pane | +| `g` / `G` | Top / bottom of the focused pane | +| Enter | Send chat, or run a `/command` | +| `Esc` | Close overlay / clear composer | +| `?` | Help (except on Paste, so `?` can be in a payload) | +| `Ctrl-Q` | Quit prompt | -**After** (target). Header 1 line. Roster 22-ish. Chat primary. Composer no -box. Fail-closed note kept. Focus marker on composer. +## Composer commands + +`parse_cmd` (`src/tui.rs`). Unknown `/foo` is sent as chat if it does not match. + +| Command | Effect | +|---|---| +| `/who` | Same as `F5` | +| `/profile` | Profile editor | +| `/pay [memo]` | Invoice (`inv `), one-shot | +| `/tip [memo]` | Transfer + `rcp ` + `tip `, one-shot | +| `/file /path` | File send, 1 MiB, one-shot | +| `/wallet create` | Same as `F6` then `c` | +| `/wallet import` | Same as `F6` then `i` | +| `/settings` | Same as `F9` | +| `/backup /path` | Encrypted identity export | +| `/restore /path` | Overwrite self keys | +| `/wipe` | Type `WIPE` — chat/payments/outbox; identity stays | +| `/wipe-all` | Type `WIPEALL` — delete data dir; new person | + +## Share / paste / rotate + +- **F2.** Full invite. `C` copies it (OSC 52). Esc back. +- **F3.** Paste buffer, Enter submits. Unknown `k` → Approve (`y`/`n`). Same `k` + updates locator and prekey only. +- **F4.** Type `ROTATE`. Identity fingerprint unchanged. Online friends get + `loc `; offline friends must F3-paste the new invite. +- **F8.** Type `ROTATE`. Prekey is the Noise static **and** the ratchet bootstrap + seed. Every friend must F3-paste the new invite. Status: + `prekey rotated · friends must F3-paste your new invite`. + +## Wallet (`F6`) + +Footer: ``` -onionwire tor me:abcdef01 onion:abcdefgh -┌friends 2 1 stale┐┌chat alice───────────────────────────────────────────────┐ -│ alice aaaaaaaa…││you: ping │ -│> bob bbbbbbbb… s││them: pong │ -│ ││them: this is a very long chat line that should wrap │ -│ ││inside the chat pane instead of running off the edge │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -│ ││ │ -└──────────────────┘└──────────────────────────────────────────────────────────┘ -> hello from composer -! send failed: peer onion down TOR me:abcdef01 ? help +c create i import r qr s/x child 1 pruned 2 full 3 testnet Esc back ? help ``` -Roster names truncate with ellipsis, not mid-letter. `stale` may abbreviate to -`s` only if the word does not fit; prefer keeping `stale`. +| Key | Effect | +|---|---| +| `r` or Enter | Toggle receive-address QR | +| `c` | Create wallet (`SPEND` then seed once, type `SEEN`) | +| `i` | Import 25-word seed | +| `s` | Start app-owned wallet child | +| `x` | Stop child (idempotent) | +| `p` | Probe child (RPC answering? chain at tip?) | +| `1` | In-process Cuprate **mainnet pruned** (unvalidated) | +| `2` | In-process Cuprate **mainnet full** (unvalidated) | +| `3` | In-process Cuprate **testnet** | +| Esc | Back to Main | -### Before → after mockup (80x24 help) +The chain line for an in-process source always carries +`testnet only — mainnet is unvalidated` (`cuprate::TESTNET_ONLY`). Starting +Cuprate needs `--features cuprate-daemon`; without it, start fails with that +feature name. -**After:** full-screen, no punch-through. Last line visible. `help_overlay_text()` -body unchanged (chrome tests). +Create/import require the wallet RPC started with `--wallet-dir`. Filename: +`onionwire`. Seed is never collected on the composer. -``` -┌? help────────────────────────────────────────────────────────────────────────┐ -│OnionWire keys │ -│ │ -│ Tab / Shift-Tab cycle roster, chat, composer │ -│ 1 / 2 / 3 focus roster / chat / composer │ -│ j k or Up Down move or scroll focused pane │ -│ g / G jump to top / bottom │ -│ Enter send chat to selected friend, or a /command │ -│ Esc close overlay, go back, clear composer │ -│ F2 share invite │ -│ F3 paste invite │ -│ F4 rotate onion locator │ -│ F5 selected friend's profile (/who) │ -│ /profile edit name, bio, Monero address │ -│ /pay [memo] invoice to receive │ -│ /tip [memo] pay selected friend │ -│ /file /path send file to selected friend (1 MiB) │ -│ /backup /path encrypted identity export │ -│ /restore /path overwrite self keys │ -│ ? this help │ -│ Ctrl-Q quit; type CLEAR or QUIT │ -│ │ -│Esc closes this overlay │ -└──────────────────────────────────────────────────────────────────────────────┘ -``` +## Wallets & settings (`F9` / `/settings`) -If the body still overflows 24 rows with the border, **scroll** the paragraph; -do not clip. Do not edit the locked help string to shrink it. +Discovery layer, not a replacement. Function keys stay live on this screen. +Rows name the shortcut they sit beside (`F6 c`, `F6 i`, `F6 r`, `F6 s/x`, +`F6 p`, `/profile`, `/backup`, `/wipe`, …). -### Left alone (on purpose) +- **No credentials** on this screen. Login, seed, and passphrase are never + passed into the menu snapshot. +- `c` copies the receive address (OSC 52). +- `p` opens peer payment history for the selected friend (`Node::list_payments`). +- Esc back to Main. -- Wire protocol, session, store, send path. -- Peer-text sanitization (other PR). Render must call it once it exists. -- Fail-closed semantics. Only the **visibility** of the error changes. -- Locked helper names and `help_overlay_text` / wordmark strings. -- No QR. Invite stays a string. -- No dedicated pay/invoice/file screens in v1. -- No spinner. `TUI_POLL` 100 ms stays. -- `docs/PROTOCOL.md` unchanged. -- No new crates on the implementation card unless `unicode-width` is approved - (deliverable 4). +The menu **shows** endpoint state; it does not edit a stored RPC URL. The error +copy for an unconfigured wallet still says “open F7” (`src/wallet.rs`); that +key does not exist. Set `ONIONWIRE_WALLET_RPC` or use `F6` create/import and +the child. -## Deliverable 4 — `chars().count()` is not terminal cells +Chain source (binaries, remote host) is stored via `Node::set_wallet_child_config`. +The desktop TUI's in-process picker is `F6` keys `1`/`2`/`3`. There is no +on-screen editor for an external RPC URL or a remote daemon host. -`tests/tui_chrome.rs` asserts `line.chars().count() <= width`. Same metric in -`status_footer` (`src/tui.rs:1512`) and `draw_text_overlay` (`src/tui.rs:1707`). +## Peer payments (`F9` then `p`) -| Input | `chars().count()` | Terminal cells (East Asian Width; emoji Wide) | -|---|---|---| -| `你好` | 2 | **4** (both Wide) | -| `e\u{0301}` (e + combining acute) | 2 | **1** | -| `🧅` (U+1F9C5) | 1 | **2** | +Peer-scoped signed invoices and tips, not the wallet's own transfer list. +`j`/`k` or arrows select. Esc back. Footer: `Esc back up/down select F9 menu ? help`. -A line of twenty `你` is 20 chars and 40 cells: the test passes at width 80, -the terminal wraps. A combining-mark string can look "too long" to the test and -still fit. +## Delivery markers (chat) -**Fix (implementation card, approved-then):** measure in cells. `unicode-width` -is already in the lockfile via ratatui but **not** a direct dependency. Do not -add it on this card. Preferred: depend on `unicode-width` explicitly and assert -`UnicodeWidthStr::width(line) <= width as usize`. Until then, keep the existing -`chars().count()` tests green; do not rewrite them to fit a redesign. +| Row state | Marker | +|---|---| +| delivered | `✓` | +| queued | `◷ queued (try n/8, retry …)` | +| sending | `» sending` | +| failed | `✗ failed: …` | +| inbound | no marker | -`tests/tui_frames.rs` `chars_count_is_not_terminal_cells` documents the three -examples without adding a crate. +Footer `{n} queued` while anything is outstanding. File transfer and payments +have no queue — outcome is a status note (`invoice sent`, `tip sent`, +`send failed: …`). -## After frames (spacing / ASCII / wrap / copy) +## Size -Base: `origin/main` after PR #24 (`33beede`). Hierarchy, fail-closed footer, -1-line header, roster width, help overlay, and `NO_COLOR` palette are unchanged -here. Optional 3-line wordmark at height ≥ 40 was skipped (it fights the 1-line -header without buying hierarchy). - -### 80x24 — `draw_share` after (field-boundary wrap) - -Invite lines break on `:`. `sig=` hex that does not fit continues as an -all-hex line. Joining those lines (no extra spaces) is the original payload. - -``` -┌(o) invite────────────────────────────────────────────────────────────────────┐ -│give this string to a friend; they F3 paste it │ -│ │ -│fp ea4a6c63… │ -│onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion │ -│ │ -│onionwire:v1: │ -│k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22c: │ -│o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion: │ -│spk=0101010101010101010101010101010101010101010101010101010101010101: │ -│sig=46caf16b6da95e86bf93a6ee80605ec74d9e24a419c4ef802632af74f46406fae9953690e0│ -│5401b0af934cefea617f71466f406af4bef956847200a8e915190b │ -└──────────────────────────────────────────────────────────────────────────────┘ -``` - -### 80x24 — ASCII switch (`ONIONWIRE_ASCII=1`) - -No non-ASCII byte. Truncation marker is `...`. Borders are `+` `-` `|`. - -``` -+(o) invite--------------------------------------------------------------------+ -|give this string to a friend; they F3 paste it | -| | -|fp ea4a6c63... | -|onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion | -| | -|onionwire:v1: | -|k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22c: | -|o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion: | -|spk=0101010101010101010101010101010101010101010101010101010101010101: | -|sig=46caf16b6da95e86bf93a6ee80605ec74d9e24a419c4ef802632af74f46406fae9953690e0| -|5401b0af934cefea617f71466f406af4bef956847200a8e915190b | -+------------------------------------------------------------------------------+ -``` - -### 80x24 / 120x40 — main chrome after - -Same 1-line header, unboxed composer, fail-closed footer as PR #24. Dump: +Floor **80×24**. Target **120×40**. Frame dumps: ``` cargo test --locked --test tui_spec -- --nocapture dump_spec_frames -``` - -Copy wired in `src/tui.rs` (not in the reconstructed standin): empty thread is -`no messages` / `type below, Enter sends`; paste error is `{err}` then -`Enter resubmits Esc back`; alerts truncate to the frame width. - -## Delivery state (outbox) — implemented - -Per-message state, read from the local outbox. The states are the store's own -(`Queued` / `Sending` / `Sent` / `Failed`) — no parallel model, no new wire -prefix, no server. - -| Row | Marker | -|---|---| -| delivered | `you: ping ✓` | -| queued (2nd attempt, 45s out) | `you: pong ◷ queued (try 2/8, retry 45s)` | -| sending | `you: pong » sending` | -| failed | `you: pong ✗ failed: connection timed out` | -| inbound | `them: pong` (no marker) | - -- `try {n}/{8}` is the outbox attempt count; `retry {s}s` / `retry {m}m` / - `retry now` comes from the stored absolute `next_attempt_at`. -- Failed reasons are sanitized, cut to the tail of the `a: b: c` chain and - capped at 24 cells (`short_send_reason`). -- Footer while rows are outstanding: `{n} queued`; any terminal failure keeps a - fail-closed `send failed: {short}` statement (with `! ` when colour is off). -- The tag trails the body and wraps with it, so it is never clipped away. - -Correlation: a delivered row is deleted from the outbox, so an outbound message -with no row is `Sent`; pending rows are joined to messages on the row id — -`store::Message::id` equals `OutboxEntry::message_id` (`chat_with_delivery`). -Two identical bodies are distinct rows with distinct ids, so the marker always -lands on the row that actually owns the outbox entry. - -### Size floor / target - -- **Floor: 80x24.** Everything above must render there. -- **Target: 120x40.** -- `tests/tui_spec.rs::chat_and_footer_rows_fit_80x24_and_wrap_instead_of_clipping` - draws the real `draw_chat` + `status_footer` at 80x24 and asserts every chat - and footer row is `<=` the terminal width, that the markers render, and that - an over-long message wraps instead of being clipped. -- Dump frames: `cargo test --locked --test tui_spec -- --nocapture dump_spec_frames`. - -## WALLETS & SETTINGS menu (F9 / `/settings`) — implemented - -The Monero wallet and the cuprate node shipped behind function keys only: a user -who did not already know F6 opened the wallet could not find wallet setup, the -child wallet, the chain source or the settings. F9 (`/settings`) is the -discoverable surface. It is a **screen, not a popup**, and it is a discovery -layer, not a replacement: F2, F3, F4, F5, F6 and F8 all keep working, and they -stay live *on this screen* so no row can print a key that does nothing there. - -``` cargo test --locked --test tui_spec -- --nocapture wallets_settings_menu_frame_dumps ``` - -dumps the menu at 80x24, 120x40 and 200x60 in both the configured and the -unconfigured state. - -### Rows - -Layout is ` label value … keys`: a 9-cell label column, the value truncated -in **cells** with the chrome's ellipsis, and a 12-cell key column right-aligned -so the eye can run down it. Every actionable row names the key or command that -fires it, including the F6 wallet screen's own keys (`F6 c`, `F6 i`, `F6 r`, -`F6 s/x`, `F6 p`), so the menu teaches the shortcuts it sits beside. - -| Group | Row | Value | Key | -|---|---|---|---| -| WALLET | endpoint | `configured · connected` / `configured · not connected` / `not configured · receive-only` | — | -| WALLET | child | `{chain source} · running` / `not started` | `F6 s/x` | -| WALLET | sync | chain readiness word (`chain at tip · wallet answering`, `wallet answering · chain not at tip`, `wallet RPC not answering yet`, `child exited`, `not probing · no chain source`) | `F6 p` | -| WALLET | receive | the receive address (truncated) or `no address yet · wallet unreachable` | `c copy` / `F6 r` | -| WALLET | balance | `{xmr}` / `off` / `err` | `F6` | -| WALLET | transfers | `{n} recent` / `no transfers yet` — the wallet's **own** transfer list | `F6` | -| WALLET | payments | `{n} with {peer}` / `no history with {peer}` / `no friend selected` / `history unreadable · {peer}` — the **peer's** payment rows | `p` | -| WALLET | create | `/wallet create · seed shown once` | `F6 c` | -| WALLET | import | `/wallet import · 25-word seed` | `F6 i` | -| SETTINGS | nickname | the self-profile name, or `(none)` | `/profile` | -| SETTINGS | profile | `bio set · xmr set` | `/profile` | -| SETTINGS | identity | `{fp}… · identity = pubkey` | `F2` | -| SETTINGS | colour | `auto · follows NO_COLOR / TERM` | — | -| SETTINGS | backup | `encrypted identity export` | `/backup` | -| SETTINGS | restore | `overwrite self keys from a backup` | `/restore` | -| SETTINGS | wipe | `messages · identity and friends stay` | `/wipe` | -| SETTINGS | wipe-all | `deletes your identity key · new person` | `/wipe-all` | - -20 rows at 80x24 against 21 available inner rows: nothing clips or scrolls. - -`transfers` and `payments` are deliberately two rows: `transfers` is the -wallet's own list (`Node::wallet_recent_transfers`, F6), `payments` is the -peer-scoped history (`Node::list_payments`, `p`). Signed `/pay` invoices and -`/tip` receipts a peer sent never appear in the wallet's own transfers, so the -two histories are not interchangeable and the menu names both. - -### Guarantees - -- **No credentials.** `WalletMenuState` carries booleans, labels and - display-ready error strings from `Node`'s getters. It is never given - `WalletConfig::rpc_login`, `secret()`, a seed or a passphrase, so the screen - cannot render one. -- **Untrusted text is display data.** Every value goes through - `sanitize::display_text` plus a newline/tab strip before it is placed on a - row, so a multi-line or bidi-laden error cannot split a row or reorder it. -- **Cells, not chars.** `cell_width()` measures with ratatui's own - `Span::width` — the same code path the renderer truncates with. - `unicode-width` is not a direct dependency of this crate, so no crate was - added; `chars().count()` is never used for a width. -- **Colour is never the only signal.** Each state word is present as a word - (`not connected`, `child exited`, `not probing`, `no transfers yet`); the - tone only answers "what is this?". -- **Copy without a clipboard crate.** `c` writes the receive address through - OSC 52 (`ESC ] 52 ; c ; BEL`): the terminal owns the clipboard, the - address never touches a file, and it still works over SSH. A terminal that - does not implement OSC 52 ignores the sequence; `F6 r` still shows the QR. -- **ASCII fallback.** The section rule is `─`, or `-` under `ONIONWIRE_ASCII` / - `NO_COLOR`, alongside the existing ellipsis swap. No emoji. - -### Reachable-from-the-TUI gaps this card does not close - -Named in the PR body's feature-analysis table. All of them need backend or -sibling-card work, not presentation: - -- `Node::wallet_config()` / `Node::wallet_save_config(cfg)` / - `Node::wallet_test_connection(..)` — the endpoint config screen is F7 on - `feat/wallet-create-import`; the menu shows the endpoint's *state* and leaves - the key free. -- Peer payment history — **closed by this screen.** `Node::list_payments` exists - on `main`; the `payments` row (key `p`) opens the peer-scoped history, and the - row is distinct from the wallet's own transfer list (`transfers`, F6). -- `Node::set_wallet_child_config(cfg)` — the child can be started/stopped and - probed, not edited. -- `Node::set_petname(..)` — no petname editor exists. - -## Peer payment history (F9 → `payments`, key `p`) - -A screen, not a popup, and peer-scoped: it renders what -`Node::list_payments(&friend_pk)` returns for the chat's selected friend, so the -signed `/pay` invoices and `/tip` receipts a peer sent are visible even though -they never appear in the wallet's own transfer list (F6). The call takes the -store lock only — no Tor dial, no wallet RPC — so it is safe while offline or -while Arti is still bootstrapping, and an empty result (`Ok(vec![])`) is the -**no history** state, never an error. - -``` -cargo test --locked --test tui_payments -- --nocapture peer_payments_frame_dumps -``` - -dumps the screen at 80x24, 120x40 and 200x60, populated and empty. - -### Layout - -``` - dir kind amount XMR receipt memo -> in receipt 0.025 verified lunch money - out tip 0.005 coffee - out invoice 0.1 rent - - tx 3f2a91c0d9e4b7a2c1f0e8d7b6a5948372615041324758697a8b9c0d1e2f3041 - addr 4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYJKUGVktfzxayGbMW - aC8iqPUE9XUBFGrLyDz4DpEBM -``` - -- Rows are **newest first**: `payments.id` ascending is oldest first, so - `PeerPaymentsState::from_payments` reverses it and the render path windows the - result. Rows outside the window are counted in an explicit `… N older` / - `… N newer` line — nothing is dropped silently. -- The focused row is marked with `>` **and** bold, so focus survives a - monochrome terminal. `up`/`down` (or `k`/`j`) move it, `Esc` returns to the - main screen, `F9` reopens the menu. -- `F9` is honoured **while this screen is open**, not only from the main screen: - the function-key table (`function_key_for`) answers it from `Main`, - `WalletsSettings` and `PeerPayments` alike, so the hint the screen prints - cannot be a no-op there. `peer_payments_footer_hint()` is the single place that - hint string is written, and the frame-dump fixture is driven from it — a dumped - frame cannot show a footer the app does not render. -- The selected row's `tx` and `addr` are spelled out under the rows: a 64-hex - txid is unusable truncated, and a 95-character base58 address is **wrapped** - over two lines rather than clipped to a prefix. -- Amounts use `pay::atomic_to_xmr_str`, the same piconero formatter the chat - lines use; the XMR unit is stated once, in the column header. -- Columns are dropped from the right when the pane is narrower than they need, - so no row can wrap or overrun at any width — not just at 80. - -### States - -| State | Frame | -|---|---| -| populated | the rows, plus the selected row's `tx` / `addr` | -| empty | `no payments with {peer}` and `invoices, receipts and tips from this peer land here` | -| read failed | `could not read payments` plus the sanitized reason — never a blank pane | -| no friend selected | the menu row refuses before the screen opens (`no friend selected` in the status line) | - -### Guarantees - -- **Memo is peer-signed text, sanitized at draw time.** `Node::list_payments` - returns `memo` as stored; the row goes through the same - `menu_cell_text`-then-`fit_cells` path the F9 menu uses, so C0/C1 controls, - ESC, bidi marks and newlines cannot reach the frame buffer or split a row. - `tests/tui_payments.rs` asserts a hostile memo (ESC, BEL, C1, bidi, newline) - never appears in a rendered frame. -- **Only receipts carry `verified`.** The flag column prints `verified` / - `unverified` for receipts and stays blank for invoices and tips, which have no - signature to check; `unverified` also takes the warn tone, so colour is never - the only signal. -- **Read-only.** The screen reads one getter and draws; it cannot send, sign or - dial. -## Clean-look chrome redesign — implemented - -The main screen was restructured around one accent, one primary pane and honest -states. The render path is no longer reconstructed in the dump: `App::draw_main` -builds a `MainView` of plain data and hands it to the public `draw_main_chrome`, -which is exactly what `tests/tui_frames.rs` draws. There is no stand-in layout, -so a frame dump is the real screen. - -``` -cargo test --locked --test tui_frames -- --nocapture dump_audit_frames -``` - -dumps every state below at 80x24, 120x40 and 200x60. - -### Hierarchy - -| Row | Content | Style | -|---|---|---| -| 0 | `onionwire {glyph} tor {phase} me:{fp8} onion:{onion8}` | app name bold text, phase semantic, identity muted | -| 1 | the alert (`send failed: …`, `fingerprint mismatch`) — only when set | alert | -| 2..h-4 | roster (22 cells at 80, 28 at 120+) next to the chat transcript | roster rows text/stale, focus marker on the focused pane | -| h-3..h-1 | composer, **no frame**, 3-row slot for wrapped input | `> ` marker + bold when focused, `message` muted when empty | -| h-1 | `{note} {glyph} TOR {phase} me:{fp8} {pane hints} ? help` | muted; phase semantic | - -The header no longer takes the accent — the accent is reserved for focus, which -is what let the header stop competing with the panes. - -### Tor phase is a first-class state - -`Node::tor_state()` was already cheap, read-only and unused by the TUI. It now -feeds `TorPhase` (one word + one glyph, both in the header and the footer), so -"connected" is never implied: - -| `hs::TorState` | `TorPhase` | glyph / ASCII | word | tone | -|---|---|---|---|---| -| `Bootstrapping` | `Connecting` | `…` / `...` | `connecting` | muted | -| `Published` | `Ready` | `✓` / `ok` | `ready` | text | -| `DegradedReachable` | `Degraded` | `!` | `degraded` | stale | -| `Stopped` | `Off` | `x` | `off` | alert | - -No new data field was needed: `App` already holds `Arc`, and this is a -read-only getter, not a store read from the render path. - -### States - -``` -onionwire ✓ tor ready me:abcdef01 onion:abcdefgh -┌roster 2 1 stale───┐┌> chat alice───────────────────────────────────────────┐ -│> alice aaaaaaaa… ││you: ping ✓ │ -│ bob-the-sta… stale││them: pong │ -│ ││them: this is a very long chat line that should wrap │ -│ ││inside the chat pane instead of running off the right │ -│ ││edge of an 80-column terminal and colliding with the │ -│ ││roster border │ -└────────────────────┘└────────────────────────────────────────────────────────┘ - message -✓ TOR ready me:abcdef01… j k scroll g G ends F4 rotate F9 settings ? help -``` - -``` -onionwire … tor connecting me:abcdef01 onion:abcdefgh -┌roster 0────────────┐┌ chat──────────────────────────────────────────────────┐ -│no friends ││no friends yet │ -│F3 adds one ││F3 paste an invite to add one │ -│ ││tor connecting — first publish takes a few minutes │ -└────────────────────┘└────────────────────────────────────────────────────────┘ - message -… TOR connecting me:abcdef01… j k select F3 add F6 wallet F9 settings ? help -``` - -``` -onionwire x tor off me:abcdef01 onion:unset -fingerprint mismatch -┌roster 0────────────┐┌ chat──────────────────────────────────────────────────┐ -│no friends ││no friends yet │ -│F3 adds one ││F3 paste an invite to add one │ -│ ││tor off — no onion service is running │ -└────────────────────┘└────────────────────────────────────────────────────────┘ - message -x TOR off me:abcdef01… j k select F3 add F6 wallet F9 settings ? help -``` - -The error state puts the fail-closed sentence on the alert row **once**; the -footer keeps the phase and the hints instead of repeating it. The outbox note -(`peer unreachable, queued (1/8, retry 45s)`) still outranks the hints when a -row is outstanding. - -### Footer variants - -| Helper | Identity | Used by | -|---|---|---| -| `status_footer(w, fp, onion, note, hints)` | `TOR`, `onion:` | locked chrome tests and every non-main screen | -| `status_footer_phased(w, fp, onion, phase, note, hints)` | `{glyph} TOR {word}`, `onion:` | F9 menu | -| `status_footer_compact(w, fp, phase, note, hints)` | `{glyph} TOR {word}` only | main (its header already carries `me:` and `onion:`) | - -The main footer drops the onion because the header one line above already prints -it; those cells go to the hints. `TOR`, `me:` and `? help` survive at 80, 120 -and 200 in every variant — `tests/tui_chrome.rs` asserts it. - -`pane_footer_hints(Pane)` changes the hint cluster with the focused pane -(roster / chat / composer) and every variant keeps `F9` and `? help`, so the -menu stays discoverable and the overlay stays reachable wherever the cursor is. - -### Levers from the reference (applied / skipped) - -Applied: one accent for focus (focused border, selected row, active-conversation -marker); focus as marker + weight (`> ` plus bold title, visible with colour -stripped); border weight = focus; one unframed muted footer that follows the -pane and the phase; designed empty / connecting / degraded / off states; -semantic colour only; outbox and stale state as marker + word. - -Skipped: the 3-line wordmark above the header at height ≥ 40 (fights the 1-line -header without buying hierarchy); bottom-anchoring the composer inside its -3-row slot (needs cell-accurate wrap prediction for no legibility gain); -per-row colour in the roster (name and fingerprint share one style so a narrow -pane can drop the fingerprint without changing the row's meaning). - -### Width - -`status_footer*`, `alert_line`, `main_header_line*`, `draw_text_overlay`, -`roster_row_text` and `fit_cells` all measure cells (`Span::width`), never -`chars().count()`. The roster row spends its budget on the name first, then the -`stale` word, then whatever is left on a fingerprint prefix — a 22-cell pane -reads `bob-the-sta… stale`, not `… bbbbbbbb… stale`. - -## Invite screen: the payload region (mouse-copy) - -OnionWire never turns on mouse capture (`grep -rn EnableMouseCapture src/` is -empty), so sharing an invite means the terminal's own drag-select. A drag copies -every cell it crosses — and `draw_share` used to render the payload inside -`themed_block("(o) invite")`, which is `Borders::ALL`: every payload row sat -between `│` at column 0 and `│` at the last column, so the pasted string carried -border glyphs. - -The payload now gets its own region: **flush at column 0, full frame width, no -block, no title, no gutter on any row it occupies**. Everything that is not the -payload — why it exists, `fp`, `onion`, the copy key — lives in the bordered -block *above* it. The layout is `Layout::vertical([Length(body + 2), Min(0)])`, -so the chrome block grows with its own content and the payload always starts on -the row after its bottom border. - -``` -===== draw_share (real) 80x24 ===== -┌(o) invite────────────────────────────────────────────────────────────────────┐ -│give this string to a friend; they F3 paste it │ -│fp ea4a6c63… │ -│onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion │ -│select the link below with the mouse, or press C to copy │ -└──────────────────────────────────────────────────────────────────────────────┘ -onionwire:v1:k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22c: -o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion: -spk=0101010101010101010101010101010101010101010101010101010101010101: -sig=46caf16b6da95e86bf93a6ee80605ec74d9e24a419c4ef802632af74f46406fae9953690e054 -01b0af934cefea617f71466f406af4bef956847200a8e915190b -``` - -At 120x40 and 200x60 `fp` and `onion` share one row (the block is one line -shorter); the payload region is unchanged. `wrap_invite` still breaks on `:`, so -joining the payload rows (trailing pad cells aside) is the payload byte for byte. -`tests/tui_chrome.rs` renders `draw_share` at 80x24, 120x40, 200x60 and 60x20 and -asserts exactly that, and that no row carrying payload carries `│`, `|`, `┃`, -`+`, `-` or `┄`. - -### `C` — the explicit copy affordance - -`C` on the invite screen writes the payload to the terminal's own clipboard with -OSC 52 (`osc52_copy_sequence`, the same sequence the F9 menu uses for the receive -address — no crate, no clipboard daemon, works over SSH). A terminal that does -not implement OSC 52 ignores the sequence, so the screen names the mouse -selection too; the line reads `select the link below with the mouse, or press C -to copy` whenever the block is wide enough, and `press C to copy, or select the -link below` otherwise. `?` lists the key as `F2 share invite (C copies it)`. - -The copy has no transient confirmation of its own: `draw_share` takes only the -payload, and `status_note` is not rendered on this screen. The mouse remains the -path that always works. diff --git a/docs/WALLET.md b/docs/WALLET.md index abf3c26..6e431e2 100644 --- a/docs/WALLET.md +++ b/docs/WALLET.md @@ -8,405 +8,214 @@ receipt checks (`get_transfers`). `/tip` is off. **Spend is opt-in** at wallet create or restore (seed-backed). That makes OnionWire a local spend authority for that wallet file — see the spend-authority -warning below. The threat-model write-up is [THREAT_MODEL.md](THREAT_MODEL.md). +warning below. Threat model: [THREAT_MODEL.md](THREAT_MODEL.md). TUI keys: +[TUI.md](TUI.md). -The app talks to `monero-wallet-rpc` over loopback HTTP Digest only, and it can -own that process itself: +The app talks to `monero-wallet-rpc` over **loopback HTTP Digest only**, and it +can own that process itself: - hand out a receive subaddress for `/pay` invoices (`create_address`), - read incoming transfers to verify a peer's receipt (`get_transfers`), - and — only if you opted into spend — `/tip` (`transfer`). -**Prefer view-only until you actually want `/tip`.** Everything else in this -document explains why, and what breaks when you do. +**Prefer view-only until you actually want `/tip`.** + +Wallet RPC is never on clearnet and never over `.onion`. Chain traffic is off +unless you opted into a wallet and chose a source. A remote daemon is untrusted +(`--trusted-daemon` is never passed). + +## Ports (do not swap these) + +| Port | What it is | +|---|---| +| **18081** | App-owned **local** daemon unrestricted RPC (`DEFAULT_MONEROD_RPC_PORT` in `src/wallet_child.rs`). Spawned `monerod` and in-process Cuprate both bind `127.0.0.1:18081`. The wallet child dials that. | +| **18089** | A daemon's *restricted*-RPC port. It belongs only in examples of a **remote** `--daemon-address` you type. Not the app-owned local port. | +| random loopback | App-owned `monero-wallet-rpc` bind (`127.0.0.1:0`, then the port is kept). | + +A doc or config that puts the local child on 18089 is wrong. ## The app-owned wallet child -`src/wallet_child.rs` owns the child pair instead of asking you to start it and -export an env var: +`src/wallet_child.rs` owns the child pair instead of asking you to export an +env var: - **`monero-wallet-rpc`** is spawned with `--rpc-bind-ip 127.0.0.1`, a **random - free loopback port** (bind `127.0.0.1:0`, read the port, drop the listener, pass - it on — two instances on one box cannot collide), a generated `--rpc-login` - (`user:pass`, random `[a-z0-9]`, no shell or HTTP metacharacters), and - `--wallet-dir $ONIONWIRE_HOME/wallet`. -- **`monerod`** is spawned too when the chain source is *local*: + free loopback port**, a generated `--rpc-login` (`user:pass`, random + `[a-z0-9]`), and `--wallet-dir $ONIONWIRE_HOME/wallet`. +- **`monerod`** is spawned when the chain source is *local*: `--non-interactive --data-dir --rpc-bind-ip 127.0.0.1 --rpc-bind-port - 18081`. One box, one daemon: the wallet child dials it at `127.0.0.1:18081`. + 18081`. The wallet child dials `127.0.0.1:18081`. - **`arti`** is spawned as a SOCKS child only when the chain source is a - `.onion` daemon: `arti proxy -p ` (see below). -- `--trusted-daemon` is never passed. A remote daemon stays untrusted. -- The wallet dir is created `0700` and the wallet file is kept `0600` — it is a - spend authority. -- The child is watched by polling (`try_wait`); an exit is reported rather than - hidden, and `stop()` kills both children on shutdown. The next launch starts - them again. Nothing promises "always running", and Android will not. + `.onion` daemon: `arti proxy -p `. +- `--trusted-daemon` is never passed. +- Wallet dir `0700`, wallet file `0600`. +- The child is watched by polling (`try_wait`). `stop()` kills children on + shutdown. Nothing promises “always running”, and Android will not. -### Where the RPC credentials live +Generated `user:pass` is sealed with the store data key in the SQLCipher +`wallet_child` table. It never appears in `ONIONWIRE_WALLET_RPC`. -The generated `user:pass` is **sealed with the store data key and kept in the -encrypted SQLCipher store** (`wallet_child` table, AEAD with the store key on top -of whole-db encryption). It is never written to a plaintext file next to the -wallet, and it never appears in `ONIONWIRE_WALLET_RPC`. They persist across -launches, so the child restarts with the same login without asking you again. +The wallet passphrase for `create_wallet` / `restore_deterministic_wallet` is +your runtime choice, not stored by the app. -The wallet passphrase is a separate thing: the child prompts/needs it for -`create_wallet` / `restore_deterministic_wallet`, and that is your runtime choice, -not something the app stores for you. +Nothing spawns the child at boot. `Node::start_wallet_child` is the only start +path. The desktop TUI drives it from `F6`: + +| Key | Effect | +|---|---| +| `s` | Start the child, then probe it once. | +| `x` | Stop it (idempotent). | +| `p` | Probe: is wallet RPC answering, is the chain at the tip? | +| `1` / `2` / `3` | Store in-process Cuprate as mainnet-pruned / mainnet-full / testnet. | + +State shown: `off` / `connecting` / `syncing` / `ready` / `exited`, plus a +chain-source label. `ready` is never reported for a child that has died. + +Once a probe has read the daemon, the line can include `sync /` +— the **daemon's** height and the tip it is syncing towards (wallet RPC +`get_info`, or the local daemon's `get_info` when wallet RPC does not answer). +`sync 0/0` or no segment means **unknown**, not caught up. + +`start` is idempotent: a live child is reported, not respawned. ## Chain source -The wallet needs a daemon for scan, verify, and spend. You pick one; OnionWire -does not pick a public remote node for you. The four shapes are: +You pick one. OnionWire does not pick a public remote node for you. ``` ChainSource::None receive-only; no child, no daemon -ChainSource::Local { monerod_bin, datadir } the app spawns monerod on this box -ChainSource::InProcessCuprate { datadir } the daemon is inside this app +ChainSource::Local { monerod_bin, datadir } spawn monerod on this box (port 18081) +ChainSource::InProcessCuprate { datadir, … } daemon inside this app (port 18081) ChainSource::Remote { host, port } a daemon address you typed ``` -1. **Local `monerod`.** Chain traffic stays on the box. You accept disk, first - sync, and (on Android) the daemon not always running. -2. **An in-process daemon** ([Cuprate](https://github.com/Cuprate/cuprate) - running inside the OnionWire process). No `monerod` binary to install or - spawn, chain on this device, and the wallet child dials the same loopback - port. **Testnet only** in this build, and it needs the `cuprate-daemon` - feature — see *The in-process chain daemon* below. +1. **Local `monerod`.** Chain traffic stays on the box. +2. **In-process Cuprate.** No `monerod` binary. Wallet child still dials + `127.0.0.1:18081`. See below. 3. **A daemon address you supply** — becomes `--daemon-address` on the wallet child. Loopback if you already run `monerod`. `.onion` if you want chain - traffic over Tor (see *Chain traffic over Tor* below). Clearnet only if you - type it — your ISP sees Monero-node traffic; it is never a default. + traffic over Tor. Clearnet only if you type it — never a default. Restricted + RPC on `18089` is a common remote example, but you supply the port. -The port is a convention, not a constant: restricted RPC on `18089` is common, -but you supply it. +Settings live in the sealed `wallet_child` record (`ChildConfig`: `source`, +`wallet_rpc_bin`, `arti_bin`, `wallet_filename`). Core: +`Node::wallet_child_config` / `set_wallet_child_config`, then +`start_wallet_child` / `stop_wallet_child` / `wallet_child_status` / +`wallet_child_refresh`. ### The in-process chain daemon (`cuprate-daemon`) -Cuprate's chain daemon — P2P, consensus, RandomX — can run **inside the -OnionWire process** instead of as a spawned `monerod`. The wallet layer does not -change: `monero-wallet-rpc` is still a child, and it still dials the unrestricted -loopback RPC, `127.0.0.1:18081`, the same address a spawned `monerod` gets. - ``` cargo build --release --features cuprate-daemon ``` -- **Off by default.** `cuprated` is pre-1.0 and is not published to crates.io - (every Cuprate crate there is a `0.0.0-placeholder` name reservation), so it is - a git dependency pinned to a revision, behind the `cuprate-daemon` feature. A - default build does not compile it: the graph is large (RandomX, fjall, - axum/hyper, rayon) and it is a *choice*, never compiled-in. Without the feature - a stored in-process chain source can still be read back — the chain-source type - and its record do not fork on a cargo feature — but starting it fails with - `this build has no in-process chain daemon — rebuild with --features - cuprate-daemon`. -- **+11.8 MiB (12,327,768 bytes)** on a stripped `aarch64-linux-android` release - binary, measured in this repo: 24,725,704 bytes without the feature and - 37,053,472 with it (`cargo rustc --release --target aarch64-linux-android - [--features cuprate-daemon] --bin onionwire`, both linked with the NDK C++ - runtime / compiler-rt link args, then `llvm-strip`). The `+5.6 MB` figure that - circulated with the spike was an estimate and understates it. A cold build - also compiles the Cuprate graph in addition to this crate's own, so first-build - time grows accordingly. -- **Testnet only.** Cuprate is **pre-production software**. Its own user book - says *"do NOT use cuprated for any serious purposes"*, and its `monerod` RPC - parity is incomplete (Cuprate issue #278; the four gaps measured in this repo - are in `docs/cuprate-launch-spike.md` §Parity gaps). The config pins - `network = "Testnet"`; pointing a mainnet wallet at it is not something this - build claims to do. The wallet screen's chain line says so next to the source - (`testnet only — mainnet is unvalidated`). -- **No Tor in the chain path.** Cuprate's own `arti` feature is *not* enabled: - its Tor stack is `arti-client` 0.44, which cannot unify with this crate's 0.46, - and running two Tor stacks in one process is not a trade this app makes. - OnionWire's Arti is the only Tor here, and it serves the messenger. The - in-process daemon's P2P traffic is therefore **clearnet**: your ISP can see - that this device talks to Monero testnet peers, exactly as a spawned `monerod` - would. -- **Inbound connections are off** and the restricted RPC listener is disabled: - this is a wallet's daemon, not a public node (the restricted listener only - answers placeholder metrics — see below). -- **It is not a child process.** There is no pid to watch or signal: the node is - a value the app owns, and dropping it shuts the daemon down. `stop` (TUI key - `x`, or the SDK's `stop_wallet_child`) asks it to shut down with the wallet - child, and it does not outlive the app. -- **The chain lives in `$ONIONWIRE_HOME/chain`** — the same per-identity - directory a spawned `monerod` would use, so the two local sources are - interchangeable on disk. It is created `0700`. The chain database itself is - **fjall**, a separate embedded store from OnionWire's SQLCipher file: - Cuprate puts it under the datadir it is given (`/testnet/fjall`), so - it is never beside `onionwire.db`. -- **Selecting it.** The chain source is a stored setting (`ChildConfig`), and - this build has no on-screen chain-source picker on the desktop TUI — that is - true of the other three sources too; the picker is a separate, unmerged piece - of work. What selects this source today is a `ChainSource::InProcessCuprate` - record with a `datadir` written through `Node::set_wallet_child_config` (the - SDK's `ChainConfig` path), and the daemon then starts with the child when the - wallet is started. The SDK's `ChainChoice.InProcessCuprate` is that variant - over UniFFI, and `kind = "cuprate"` is the record's spelling. +- **Off by default.** `cuprated` is pre-1.0, not on crates.io (placeholder + crates), git-pinned, behind the feature. Without the feature, a stored + in-process source can still be read back, but start fails with + `this build has no in-process chain daemon — rebuild with --features cuprate-daemon`. +- **Pre-production.** Cuprate's own user book says do not use `cuprated` for + serious purposes. RPC parity is incomplete (`docs/cuprate-launch-spike.md`). +- **Mainnet is unvalidated.** The TUI can store mainnet-pruned (`F6` `1`) or + mainnet-full (`F6` `2`) or testnet (`F6` `3`). Every in-process surface still + prints `testnet only — mainnet is unvalidated` (`cuprate::TESTNET_ONLY`). + Cross-compiled is not device-proven. Pointing a mainnet wallet at it is not + something this build claims to do. +- **No Tor on the chain path.** Cuprate's `arti` feature is off (arti-client + 0.44 vs this crate's 0.46). P2P is **clearnet**. OnionWire's Arti is the + messenger only. +- **Inbound P2P off**, restricted RPC listener disabled. Unrestricted RPC is + loopback 18081. `--trusted-daemon` still never passed. +- Chain lives under `$ONIONWIRE_HOME/chain/…` (split dirs so pruned mainnet + cannot mix with full). Database is **fjall**, not SQLCipher. +- Not a child process: dropping the node shuts it down. `x` / `stop_wallet_child` + asks it to stop with the wallet child. ### Chain traffic over Tor (`.onion` daemons) -A `.onion` daemon cannot be dialled directly, and OnionWire does not fall back -to a clearnet resolve. The wallet child is an external C++ binary, so it reaches -Tor the only way it can: through a SOCKS proxy the app provides. +A `.onion` daemon cannot be dialled directly. The wallet child is an external +C++ binary, so it reaches Tor through a SOCKS proxy the app provides: -- The app runs the **bundled `arti` binary** as a child: - `arti proxy -p `. `arti-client` 0.46 has no SOCKS - listener API — the SOCKS listener lives in the `arti` *binary* — so this is a - second, separate Tor client, not the messenger's in-process one. There is no - C-tor and no system `tor`. -- The listener is **TCP loopback only**. `arti proxy -p ` binds localhost - (`127.0.0.1` and `::1`) and nothing else, and there is nothing safer to - prefer: `arti` 2.6.0 / `tor-config` 0.46 have no Unix-socket listen target - (`Listen` is IP-only; arti's own port record calls AF_UNIX future work, - arti#1965). The port is app-private in practice, but any local process with - user-level access can also use it — that is the honest statement of the - boundary, not a claim of access control. -- The wallet child is then spawned with - `--proxy socks5://127.0.0.1:` **and** `--daemon-address :`. - The `socks5://` scheme is explicit: Monero's `--proxy` defaults to SOCKS4a for - a bare `host:port` (`docs/proxies.md` in the Monero tree). The `.onion` name - goes to the proxy inside the SOCKS request — Monero's SOCKS5 client uses the - domain-name form — so **no local DNS** runs on the onion target. -- The SOCKS child gets **its own state and cache dirs** - (`$ONIONWIRE_HOME/wallet/arti-socks/{state,cache}`). The messenger's Arti - state is not shared with it. -- Starting it is gated on the same credential material as everything else: the - SOCKS child is only spawned from `WalletChild::start(&store)`, which needs the - already-unlocked store. -- The app waits **up to 20s** for the SOCKS listener to accept a connection - before it spawns the wallet child. A dead proxy is a visible error, not a - wallet screen that hangs dialling a daemon. Arti binds its listener before it - bootstraps, so this is a listener check, not a Tor-bootstrap check. -- The SOCKS child stops with the wallet child; a killed wallet child leaves no - orphaned listener behind. +- Bundled `arti` binary: `arti proxy -p `. A second + Tor client, not the messenger's in-process one. No C-tor. +- Listener is TCP loopback only. Any local process at your privilege can use it. +- Wallet child: `--proxy socks5://127.0.0.1:` and + `--daemon-address :`. The `socks5://` scheme is required (Monero + defaults to SOCKS4a for a bare `host:port`). No local DNS on the onion target. +- Own state/cache: `$ONIONWIRE_HOME/wallet/arti-socks/{state,cache}`. +- Wait up to 20s for the SOCKS listener before spawning the wallet child. +- SOCKS child stops with the wallet child. **Tor hides the transport, not the host.** The daemon operator still sees the -wallet's addresses (and the transaction set it is scanning) during sync. A -`.onion` address protects the path between you and that operator, nothing more. +wallet's addresses during sync. -The TUI copy for a chain source says this in one line -(`WalletChild::chain_copy`): `.onion` → "over Tor … the daemon operator still -sees your addresses during sync"; clearnet → "the daemon operator and your ISP -see the traffic". +### Readiness — receipt verification needs a synced daemon -### Readiness, and why it is not a guess +`chain_ready()` asks the wallet RPC `get_info` and requires +**`synchronized == true`** with `height > 0` and `height >= target_height`. A +missing field is *not ready* — fail closed. -`chain_ready()` asks the wallet RPC `get_info` and requires **`synchronized == -true`** with `height > 0` and `height >= target_height`. A missing field is -*not ready* — fail closed, never a silent pass. Until then: +Until then, **receipt verification stays `verified=0`**. An unsynced wallet +cannot see the chain. That is an honest limit, not a UI bug. -- **receipt verification stays `verified=0`** (an unsynced wallet cannot see the - tx, so a `get_transfers` miss would be a lie), and -- **spend is refused** with `wallet is not synced — spend refused until the - daemon reaches the chain tip`. +Loopback management calls (`get_address`, `query_key`, create/import) get 5s. +Calls that wait on the chain (`get_info`, `get_transfers`, `transfer`) get 60s +(`CHAIN_RPC_TIMEOUT`). -`spend_ready()` is the stricter signal the spend UI reads: chain-ready *and* -holding an unlocked balance above zero. - -That is the honest state, not a broken flow. Unsynced or unreachable → receipts -unverified and spend refused. - -### Timeouts are the backend's, not a constant - -Loopback management calls (`get_address`, `query_key`, create/import) get a 5s -budget — the child is on the same box. Calls that wait on the chain (`get_info`, -`get_transfers`, `transfer`) get 60s (`CHAIN_RPC_TIMEOUT`), because a first sync -or a remote daemon legitimately outlasts a loopback round trip; a 5s cap there is -what leaves receipts permanently unverified. - -## Env vars +## Env vars (migration path) | Variable | Meaning | |---|---| -| `ONIONWIRE_WALLET_RPC` | `http://[user:pass@]host[:port][/path]` — for an **externally run** `monero-wallet-rpc`. Unset → no wallet; chat still works and `/pay` falls back to the profile `xmr_addr`. The app-owned wallet child does not use this variable. | -| `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_RPC` | `http://[user:pass@]host[:port][/path]` for an **externally run** `monero-wallet-rpc`. Unset → no wallet; chat still works; `/pay` falls back to profile `xmr_addr`. The app-owned child does not use this. | +| `ONIONWIRE_WALLET_RPC_LOGIN` | `user:pass` when the URL has no userinfo. | +| `ONIONWIRE_WALLET_NO_SPEND` | `1` / `true` / `yes` / `on` → `/tip` refused locally before any RPC dial. | -These three are the **migration path**, not the only path: a config stored in -the encrypted store wins at boot. See *Stored wallet config* below. +Boot precedence: **stored config → env → disabled**. Stored config that cannot +be used (non-loopback, `.onion`, missing login) is reported and falls back to +env rather than dialling the bad endpoint. -`README.md` carries the operator summary; this file is the long form. +`Store::save_wallet_config` / `Node::wallet_save_config` exist. **No TUI screen +writes them.** There is no `F7`. The not-configured refusal still says +`wallet not configured — open F7 to set it up, or set ONIONWIRE_WALLET_RPC` +(`src/wallet.rs`). Live surfaces: `F6`, `F9`, or the env vars. -## Stored wallet config (no env required) +`/pay` and `/tip` run `wallet_readiness` before send: -Editing env vars is a deployment step, not a UI step. The same three fields can -be stored instead, so a deployment never needs env at all: +1. not configured → the F7-worded message above +2. `/tip` on view-only / `ONIONWIRE_WALLET_NO_SPEND` → refused **before any dial** +3. configured but not connected → `wallet not connected — check endpoint, login, daemon` +4. otherwise ready (`/pay` is fine on view-only) -| 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_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`. | +## Android / SDK -`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). +UniFFI: `set_chain_source(ChainConfig)` / `chain_source()`, +`start_wallet_child()`, `stop_wallet_child()`, `wallet_status()` (cached read: +no dial, for first paint) and `wallet_child_refresh()` (a live probe of the +same record — it dials the loopback wallet RPC, and the local daemon's +`get_info` when that RPC does not answer, so poll it on the order of seconds). +Pass absolute paths for `wallet_rpc_bin` / `arti_bin` (`nativeLibraryDir`); the +core never resolves a binary the caller named explicitly. -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 store data key and a `onionwire/wallet-config/v1` AAD on top of whole-db -encryption — the same discipline as the wallet-child creds). Save replaces the -row; clearing the URL deletes it, which is how you turn the stored wallet off -again. +`ChainChoice.InProcessCuprate` is the in-process variant. Empty +`monerod_datadir` resolves to `$ONIONWIRE_HOME/chain`. `start_wallet_child()` +launches the node *and* the wallet child. `wallet_status()` carries +`chain_in_process`, `node_available`, and `node_state`. -**Boot precedence is stored → env → disabled.** Stored config wins; the env vars -in the table above remain the migration path (and the only path for headless -runs). A stored config that cannot be used — non-loopback host, `.onion`, -missing login — is reported and then **falls back to env** rather than dialling -the bad endpoint. To override a stored config with env, clear the stored one -first. - -### Wallet status, and how fresh `connected` is - -The app keeps one `WalletStatus` snapshot for the draw path — -`configured`, `connected`, `last_error`, `balance_line`, `receive_address` — -and the TUI only ever reads it; it never dials the wallet from the render path. - -- `configured` is true when a stored **or** env config resolved to a usable - wallet. Config is not reachability: a freshly booted or freshly saved wallet - is `configured = true`, `connected = false`, with `—` readouts. -- `connected` only ever comes from a probe. One probe is `get_address` (cheap, - loopback, and the same call `/pay` invoices need) followed by `get_balance` - for the readout. A success clears `last_error`; a failure sets - `connected = false` and keeps `configured = true`. There is no background - refresh: `connected` is whatever the **last** probe said. -- `last_error` is display copy, not a log line: trimmed, capped at 120 chars, - and with the RPC password redacted (``) if a lower layer ever put it - in a message. - -Two probes exist: - -- `wallet_refresh` / the readiness guard probe the **configured** endpoint and - update the snapshot; -- `wallet_test_connection` probes an endpoint the caller is *currently typing* - (`Wallet::ping`) and returns `{ok, status, error}` without touching the live - wallet or the snapshot — testing an untyped endpoint is not the wallet the app - is running. (The F7 screen that calls it ships on `feat/wallet-create-import`.) - -### The pay/tip readiness guard - -`/tip` and `/pay` run a pre-check before the send. It never dials Tor (wallet -RPC is loopback-only), and it never dials the wallet at all when the answer is -already known locally. The order is fixed and the copy is part of the contract: - -1. **not configured** → `wallet not configured — open F7 to set it up, or set ONIONWIRE_WALLET_RPC` -2. **`/tip` on a no-spend / view-only wallet** → the existing view-only message - (`wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt - verification still work`), refused **before any dial** — this is the same rule - `transfer` applies, and it is the honest answer whether or not the wallet is - reachable. -3. **configured but not connected** → `wallet not connected — check endpoint, login, daemon` -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 -is one bounded probe (5s local budget). `wallet_readiness(is_tip)` is `async`; -the TUI calls it from its key handler on both the `/pay` and `/tip` paths before -it sends anything. - -The "open F7" wording inside the not-configured message is the copy that ships -with the F7 screen on `feat/wallet-create-import`; this stack stores the config -and exposes the guard, but no screen writes it yet. - -## 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`, `in-process 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. - -The same one-liner carries the chain's own progress once a probe has read it: - -``` -child syncing · in-process node · sync 1160/3090939 -``` - -Those are the **daemon's** height and the tip it is syncing towards — from the -wallet RPC's `get_info` when it answers, and, when the wallet RPC is *not* -answering (the `connecting` case, e.g. `Connection refused (os error 111)`) while -the chain source is `local node` or `in-process node`, from that loopback daemon -directly. `sync 0/0`, or no `sync` segment at all, means **unknown**: the child -is off or exited, the probe failed, or the daemon reported no target — which is -not the same as caught up, and is never a wallet-scan height. No percentage is -ever derived from it. `WalletChildStatus` (and the UniFFI record) carries the two -numbers as `height` / `target_height`. - -`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()` (the cached - read: no dial, for first paint) and `wallet_child_refresh()` (a live probe of - the same record — it dials the loopback wallet RPC, and the local daemon's - `get_info` when that RPC does not answer, so poll it on the order of - seconds). Pass absolute paths for `wallet_rpc_bin` / `arti_bin` (`nativeLibraryDir`); the - core never resolves a binary the caller named explicitly. `ChainChoice` has a - fourth variant, `InProcessCuprate`, for the in-process daemon: no binary path - and, with an empty `monerod_datadir`, the SDK resolves the chain directory to - `$ONIONWIRE_HOME/chain`. `start_wallet_child()` is the whole lifecycle for it - (the core launches the node *and* the wallet child in that one call), and - `wallet_status()` carries `chain_in_process` (this app's node is the source), - `node_available` (this build has `cuprate-daemon`) and `node_state` - (`off` / `starting` / `syncing` / `ready` / `exited`, empty for every other - source) beside the core's own five `state` words. - -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. +Monero ships **no Android binaries**. Any vendored blob's provenance doc must +say so. Cross-compiled is not device-proven. See `android/MONERO_BINARIES.md`. ## Create vs import -Create does **not** take a private key. `/wallet create` (TUI: F6 then `c`) asks -the RPC to generate a new spend-capable wallet (`create_wallet`), then shows the -seed **once** for backup (`query_key mnemonic`). Type `SPEND` to accept the -spend-authority warning, set a passphrase, write the seed down, type `SEEN`. +`/wallet create` (`F6` then `c`) → `create_wallet`, then seed **once** +(`query_key mnemonic`). Type `SPEND`, set a passphrase, write the seed, type +`SEEN`. -Import is the only path that takes an existing secret: `/wallet import` (F6 then -`i`) pastes the 25-word seed into `restore_deterministic_wallet`. Do not put the -seed on the composer line — it would sit in chat history. +`/wallet import` (`F6` then `i`) → `restore_deterministic_wallet` from a +25-word seed. Do not put the seed on the composer. -The RPC must be started with `--wallet-dir` (not only `--wallet-file`) or create -and import fail. The in-app filename is `onionwire`. +RPC must be started with `--wallet-dir` (not only `--wallet-file`). Filename: +`onionwire`. -## Recommended topology +## Recommended topology (view-only) ``` wallet host (this machine) @@ -419,38 +228,19 @@ and import fail. The in-app filename is `onionwire`. └──────────────────────────────────────────────────────────────┘ ``` -Loopback is the only address OnionWire will dial for **wallet RPC**. `.onion` -wallet-RPC URLs are rejected: there is no Arti dial for the wallet process, and -a remote wallet RPC would move spend authority off the box. +Loopback is the only address OnionWire will dial for **wallet RPC**. ## Create a view-only wallet -Either path produces a wallet file with the view key only. Keep the seed / -spend key on a machine that is **not** running OnionWire. - -With `monero-wallet-cli` (`--generate-from-view-key` prompts for the *standard* -address the view key belongs to, then the secret view key): +Keep the seed / spend key on a machine that is **not** running OnionWire. ```bash monero-wallet-cli --generate-from-view-key "$HOME/.onionwire-viewonly" \ --daemon-address "$YOUR_MONEROD:18089" --restore-height "$BIRTH_HEIGHT" -# Standard address: 4... -# Secret view key: ``` -Or through a running RPC that was started with `--wallet-dir` (`generate_from_keys` -without `spendkey` writes a watch-only wallet): - -```bash -curl -u onionwire:secret http://127.0.0.1:18083/json_rpc \ - -H 'Content-Type: application/json' \ - -d '{"jsonrpc":"2.0","id":"0","method":"generate_from_keys","params":{ - "filename":"viewonly","password":"walletpass", - "address":"4...","viewkey":"","restore_height":}}' -# → "Watch-only wallet has been generated successfully." -``` - -Then serve it: +`18089` here is the **remote** daemon's restricted RPC, an address you type — +not the app-owned 18081. ```bash monero-wallet-rpc --wallet-file "$HOME/.onionwire-viewonly" \ @@ -462,78 +252,36 @@ export ONIONWIRE_WALLET_RPC_LOGIN=onionwire:secret export ONIONWIRE_WALLET_NO_SPEND=1 ``` -Restore the wallet from a height *at or before* its first incoming transaction -— a view-only wallet cannot rescan cheaply from height 0. +Restore from a height at or before the first incoming transaction. ## What works, what does not | Feature | View-only | Spend-capable | |---|---|---| | `/pay ` invoice subaddress (`create_address`) | works | works | -| Receipt verification (`get_transfers`) | works | works | +| Receipt verification (`get_transfers`) | works, if daemon is synced | works, if daemon is synced | | Profile `xmr_addr` fallback when RPC is down | works | works | | `/tip ` (`transfer`) | **cannot work** | works | | OnionWire copies your spend key into its own process | never | never (it stays in the wallet file / RPC) | -With `ONIONWIRE_WALLET_NO_SPEND=1` a `/tip` is refused before the RPC is -contacted, with: +`ONIONWIRE_WALLET_NO_SPEND=1` refuses `/tip` before RPC with: ``` wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt verification still work ``` -Without the flag, `/tip` against a view-only wallet fails at the wallet and -OnionWire then asks the wallet directly whether it can spend (see below), so you -get the same sentence instead of a raw RPC error. - -## How OnionWire detects view-only over RPC - -The signal people usually reach for is `query_key` with `key_type=mnemonic`. It -works, but it is the wrong key to ask for: on a spend-capable wallet it hands -over the whole seed (full spend ability) over loopback HTTP, and it answers -`-43` for wallets that have no mnemonic at all. The spend key is narrower and -just as unambiguous: - -``` -query_key {"key_type":"spend_key"} - spend-capable → result.key = - view-only → error code -29, "The wallet is watch-only. Cannot retrieve spend key." -``` - -(`query_key key_type=mnemonic` returns `-29` for a view-only wallet too, so the -two agree — OnionWire asks for the spend key because it is the smaller secret.) - -- Method: [`query_key`](https://www.getmonero.org/resources/developer-guides/wallet-rpc.html#query_key) -- `-29` is `WALLET_RPC_ERROR_CODE_WATCH_ONLY` in - [`wallet_rpc_server_error_codes.h`](https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server_error_codes.h) -- The view-only branch is `on_query_key` in - [`wallet_rpc_server.cpp`](https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server.cpp) - -OnionWire only calls this **after** a `transfer` has already failed — it never -probes a healthy wallet — and it discards `result.key` immediately. There is no -RPC method that reports "view-only" as a plain field; `query_key` is the -documented signal and this is its only cost: a spend-capable wallet answers with -its spend key over loopback HTTP, which is one more reason to run view-only. - -Fail-closed details: if the probe cannot answer (wallet down, `--restricted-rpc` -answers `-7 DENIED` instead), OnionWire surfaces the wallet's own error -unchanged. It never guesses "view-only" from an unrelated failure. +View-only detection after a failed `transfer`: `query_key` `spend_key` → `-29` +watch-only. The spend key is discarded immediately. OnionWire never probes a +healthy wallet for this. ## Why loopback still needs authentication -`--rpc-bind-ip 127.0.0.1` keeps the port off the network; it does **not** keep it -away from other users or processes on the same machine. Any local process can -`connect(127.0.0.1:18083)`. +`--rpc-bind-ip 127.0.0.1` keeps the port off the network; it does **not** keep +it away from other processes on the same machine. -- OnionWire refuses an RPC that answers HTTP 200 without a Digest challenge, and - refuses URLs without credentials. Unset the credentials and the wallet is open - to every local process — with a spend-capable wallet file, that is a - one-curl drain of your balance. -- `--rpc-login` is HTTP Digest (MD5), so the password is not sent in cleartext, - but Digest gives no confidentiality: a local attacker who can sniff loopback - can replay it. Treat loopback as trusted-ish, not safe. -- Do not log the password, and do not put it in a shell history you share. - Prefer `ONIONWIRE_WALLET_RPC_LOGIN` over userinfo in the URL. +OnionWire refuses an RPC that answers HTTP 200 without a Digest challenge, and +refuses URLs without credentials. Prefer `ONIONWIRE_WALLET_RPC_LOGIN` over +userinfo in the URL. Do not log the password. ## The spend-authority warning @@ -543,27 +291,17 @@ local spend authority: any process that can read the RPC credentials (env var, balance, and `/tip` gives a chat peer a supported path to ask for a transfer. That is why view-only plus `ONIONWIRE_WALLET_NO_SPEND=1` is the recommended -default: +default. If you want tips, use a **separate hot wallet with a small balance**, +not your savings wallet. -- the wallet file holds no spend key, so a stolen wallet file cannot be used to - move funds; -- the RPC credentials grant only receive-address and history reads; -- `/tip` fails locally with a plain message, so nothing in the UI pretends the - spend path exists. +## Payments are one-shot -If you want tips to work, understand that you are deliberately making the -OnionWire process able to spend. Give it a **separate hot wallet with a small -balance**, not your savings wallet. +`/pay` and `/tip` fail when the peer onion is down. There is no queued invoice. +File transfer is the same rule. ## References -- Monero Wallet RPC reference: - -- `on_query_key` (view-only → `-29`): - -- `WALLET_RPC_ERROR_CODE_WATCH_ONLY = -29`: - -- `--generate-from-view-key` (incoming-only wallet): - -- `generate_from_keys` (watch-only when `spendkey` is omitted): - +- Monero Wallet RPC: +- `WALLET_RPC_ERROR_CODE_WATCH_ONLY = -29` in the Monero tree +- Spike history (not operator docs): [cuprate-launch-spike.md](cuprate-launch-spike.md), + [arti-socks-feasibility.md](arti-socks-feasibility.md) diff --git a/docs/arti-socks-feasibility.md b/docs/arti-socks-feasibility.md index 339a385..b7d05b8 100644 --- a/docs/arti-socks-feasibility.md +++ b/docs/arti-socks-feasibility.md @@ -1,5 +1,9 @@ # Arti SOCKS Feasibility Report +**Status:** shipped as Option A (bundled `arti` binary as SOCKS child for +`.onion` daemons). Living doc: [WALLET.md](WALLET.md). Verdict below is the +historical finding; do not rewrite it. + **Date:** 2026-09-13 **Scope:** Can OnionWire's in-process `arti-client` 0.46.0 expose a SOCKS5 listener for an external process (monero-wallet-rpc child) to route its daemon traffic through Tor? **Verdict:** **Not directly.** The `arti-client` library does not expose a configurable SOCKS proxy listener. See options below. diff --git a/docs/cuprate-android-spike.md b/docs/cuprate-android-spike.md index 9433ab1..0c55fc3 100644 --- a/docs/cuprate-android-spike.md +++ b/docs/cuprate-android-spike.md @@ -1,5 +1,9 @@ # Cuprate on Android aarch64 — cross-compile spike +**Status:** shipped as history. In-process Cuprate is an opt-in `cuprate-daemon` +feature; mainnet remains unvalidated. Living doc: [WALLET.md](WALLET.md). Do not +read this spike as current operator procedure. + **Question (kanban `t_8293d96d`):** do the native dependencies of the in-process Cuprate daemon (`randomx-rs`, `fjall`, sqlite, the C++ RandomX build) cross-compile for the Android NDK target `aarch64-linux-android`? If they do not, §7a's Phase 1 diff --git a/docs/cuprate-launch-spike.md b/docs/cuprate-launch-spike.md index 7ffc6c2..6c799b0 100644 --- a/docs/cuprate-launch-spike.md +++ b/docs/cuprate-launch-spike.md @@ -1,5 +1,8 @@ # Cuprate in-process launch spike (Phase 1, Spike A) +**Status:** shipped as history. Production app-owned daemon RPC is **18081**, +not the spike's 18089 unrestricted example. Living doc: [WALLET.md](WALLET.md). + **Question:** does `cuprated::Node::launch(config).await` start a real Monero chain daemon *inside the OnionWire process* on testnet, and does the resulting JSON-RPC endpoint at `127.0.0.1:18089` answer `get_info`, `get_height` and `get_block` the way `monerod` does — diff --git a/docs/option-a-recommendation.md b/docs/option-a-recommendation.md index 969099e..93e86d5 100644 --- a/docs/option-a-recommendation.md +++ b/docs/option-a-recommendation.md @@ -1,5 +1,8 @@ # Recommendation: Option A — bundle the `arti` binary as a SOCKS subprocess +**Status:** shipped. The wallet child uses `arti proxy -p` for `.onion` daemons. +Living doc: [WALLET.md](WALLET.md). This file is the decision record. + ## What Option A is Run the `arti` CLI (not `arti-client`) as a child process doing `arti proxy -p `. The wallet child points `--proxy 127.0.0.1:` at it. The messenger continues using in-process `arti-client`. Two Tor clients in one app: one in-process for the messenger, one subprocess for SOCKS. diff --git a/docs/payment-integration-plan.md b/docs/payment-integration-plan.md index ea1ecbc..27b060b 100644 --- a/docs/payment-integration-plan.md +++ b/docs/payment-integration-plan.md @@ -1,5 +1,11 @@ # OnionWire payment integration — next steps +**Status:** largely shipped (child wallet, `/pay` `/tip`, F6 create/import, F9 +menu). Still open on desktop: no TUI editor for a stored external RPC URL or a +typed remote daemon host (API exists; error copy still says “F7”). Living docs: +[WALLET.md](WALLET.md), [TUI.md](TUI.md). This file is the plan as written; do +not rewrite the conclusion. + **Audience:** dev profiles (rust-dev for core/SDK/TUI, apk-dev for Android), with CI as a cross-cutting concern. **Goal:** turn the existing `inv`/`rcp`/`tip` wire frames and the existing `monero-wallet-rpc` HTTP Digest client into a real in-app payment flow on both TUI and Android, with the wallet fully owned by the app (bundled binaries), chain backends opt-in (local pruned node, or remote onion daemon), clearnet refused, Tor for the messenger and for any remote-daemon chain traffic.