Merge pull request 'sdk: expose a live wallet-child probe over UniFFI (wallet_child_refresh)' (#132) from wt/t_0a355a62 into main
All checks were successful
android-ci / android (push) Successful in 12m2s
ci / test (push) Successful in 5m15s
ci / sdk (push) Successful in 1m7s
ci / fuzz (push) Successful in 5m3s

Reviewed-on: #132
This commit is contained in:
sirius 2026-09-20 04:32:38 +00:00
commit fa0e4b2f6c
15 changed files with 754 additions and 1646 deletions

444
README.md
View file

@ -1,71 +1,89 @@
# OnionWire # OnionWire
Lean Tor messenger: one Rust process (ratatui + Noise IK + sqlite + in-process Arti). 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 ## Install
Pick one: a CI-built binary (fastest), or build from source. Pick one: a CI-built binary, or build from source.
### Requirements ### Requirements
| Need | Notes | | Need | Notes |
|---|---| |---|---|
| Linux | x86_64 or aarch64. TUI needs a real terminal (not a pipe). | | 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. | | 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 ### 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=<that 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 ```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.14.0/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.sha256
sha256sum -c onionwire-x86_64-unknown-linux-gnu.sha256 sha256sum -c onionwire-x86_64-unknown-linux-gnu.sha256
chmod +x onionwire-x86_64-unknown-linux-gnu chmod +x onionwire-x86_64-unknown-linux-gnu
./onionwire-x86_64-unknown-linux-gnu --version ./onionwire-x86_64-unknown-linux-gnu --version
``` ```
**aarch64 (Raspberry Pi, ARM servers):** **aarch64:**
```bash ```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.14.0/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.sha256
sha256sum -c onionwire-aarch64-unknown-linux-gnu.sha256 sha256sum -c onionwire-aarch64-unknown-linux-gnu.sha256
chmod +x onionwire-aarch64-unknown-linux-gnu chmod +x onionwire-aarch64-unknown-linux-gnu
./onionwire-aarch64-unknown-linux-gnu --version ./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 ```bash
mkdir -p ~/.local/bin mkdir -p ~/.local/bin
install -m 755 onionwire-x86_64-unknown-linux-gnu ~/.local/bin/onionwire install -m 755 onionwire-x86_64-unknown-linux-gnu ~/.local/bin/onionwire
# ensure ~/.local/bin is on PATH, then:
onionwire 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. 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`
Checksum files are `sha256sum` format (`<hash> onionwire-<target>`). Download both files with `curl -O` so the names match, then `sha256sum -c`. format (`<hash> onionwire-<target>`).
### Option B — build from source ### 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 ```bash
# rustup (if you do not already have cargo)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env" source "$HOME/.cargo/env"
rustc --version # must be 1.91 or newer rustc --version # must be 1.91 or newer
@ -81,30 +99,35 @@ cargo build --release --locked
./target/release/onionwire ./target/release/onionwire
``` ```
Install the binary:
```bash ```bash
cargo install --path . --locked --force cargo install --path . --locked --force
# lands in ~/.cargo/bin/onionwire # lands in ~/.cargo/bin/onionwire
``` ```
Build needs a C toolchain plus `perl` and `make`: SQLCipher is compiled from Build needs a C toolchain plus `perl` and `make`: SQLCipher is compiled from
vendored OpenSSL sources (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`). vendored OpenSSL (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`). No
No system OpenSSL headers or `pkg-config` are required — Arti's TLS backend is system OpenSSL headers or `pkg-config` are required — Arti's TLS backend is
`rustls`, and the binaries carry no dynamic `libssl` dependency. `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 ### Two instances on one machine
Each process needs its own data dir (identity + onion + sqlite): Each process needs its own data dir:
```bash ```bash
ONIONWIRE_HOME=/tmp/ow-a ./onionwire ONIONWIRE_HOME=/tmp/ow-a ./onionwire
ONIONWIRE_HOME=/tmp/ow-b ./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 ```bash
onionwire onionwire
@ -112,22 +135,64 @@ onionwire
or `cargo run --release`. 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 ## 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) ## 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 | | Key | Action |
|---|---| |---|---|
| `Tab` / `Shift-Tab` | Cycle focus: roster → chat → composer | | `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 | | `j` `k` / `↑` `↓` | Move or scroll the focused pane |
| `g` / `G` | Jump to top / bottom of the focused pane | | `g` / `G` | Jump to top / bottom of the focused pane |
| `?` | Keybinding help (`Esc` closes) | | `?` | 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 | | `F3` | Paste a friend's invite |
| `F4` | Rotate **onion** (locator only) | | `F4` | Rotate **onion** (locator only) |
| `F5` | Selected friend's profile (`/who`) | | `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) | | `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` | | Enter | Send chat to the selected friend, or run a `/command` |
| `Esc` | Close overlay / back to Main / clear composer | | `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 | | `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 <xmr> [memo]`, `/tip <xmr> [memo]`, `/backup /path`, `/restore /path`,
`/file /path`, `/settings`, `/wallet create`, `/wallet import`.
## F2 / F3 invite ## 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=…` `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 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). - A new onion is published; the old one is hard-cut (no dual-host grace).
- Online friends get a signed `loc` frame. - Online friends get a signed `loc` frame.
- Offline friends cannot find you until they F3-paste the new invite. There is no directory. - Offline friends cannot find you until they F3-paste the new invite. There is no directory.
## Local outbox (chat) and fail closed ## Local outbox (chat) and fail closed
**Chat** to an unreachable onion is written to a local `outbox` row next to its **Chat** to an unreachable onion is written to a local `outbox` row and retried
`messages` row and retried in-process while the app runs (exponential backoff, in-process while the app runs (exponential backoff from 30s, cap 30 min, stop
cap 30 min between attempts, stop after 8 attempts or a terminal failure). There after 8 attempts or a terminal failure — `src/outbox.rs`). There is **no**
is **no** server-side queue and **no** store-and-forward relay — a queued message server-side queue and **no** store-and-forward relay — a queued message never
never leaves the device, and it dies with the device. Two consequences are real and are accepted: 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. - **Device seizure.** A pending message sits in the same SQLCipher store as the
- **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. rest of the history. Seizure *with* the passphrase reveals messages that were
never sent; seizure without it reveals nothing in this store. `/wipe` clears
Delivery markers in the TUI and Android chat UI are the store's own statuses: outbox rows with chat history; `/wipe-all` removes them with the data dir.
Neither is a forensic erase.
| Row state | Marker | - **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.
| 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.
Still **fail closed** (no queue, no retry): 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) - Arti cannot publish the onion (no C-tor fallback)
- no DHT, no name server, no hosted chat server - 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 Chat is ratcheted on top of the Noise session: each chat send is Double-Ratchet
Double-Ratchet encrypted first, and the resulting `rat ` frame is what the encrypted first, and the resulting `rat ` frame is what the one-shot Noise
one-shot Noise session carries. Forward secrecy is per chain, and a snapshot of session carries. Wire format: [docs/PROTOCOL.md](docs/PROTOCOL.md).
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).
- Per-friend state lives in the encrypted store (`ratchet_sessions`, one row per - Per-friend state lives in the encrypted store (`ratchet_sessions`). Nothing
friend). Nothing about it is transmitted, so the "no relay, no server queue" about it is transmitted.
rule is unchanged. - **Only chat is ratcheted.** `loc`, `prf`, `inv`, `rcp`, `tip`, `png`, and
- Message numbers, ratchet keys and chain state ride *inside* the Noise `fil` keep the one-shot Noise shape.
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.
- Out-of-order delivery works (bounded skipped keys: 2000 per chain jump, 2000 - 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 stored). A queued chat message re-sends the *same* `rat ` frame.
closed). A queued chat message re-sends the *same* `rat ` frame, so an outbox - `/wipe` clears chat, payments and outbox but **keeps** ratchet state. `/wipe-all`
retry never burns a second chain key. removes the data dir.
- `/wipe` clears chat, payments and outbox rows but **keeps** the ratchet state - There is no `/reset`. State drops when the friend's prekey changes (you
(roster and identity stay), so chat continues on the same epoch. `/wipe-all` `F3`-paste a refreshed invite).
removes the data dir and the state with it. - An inbound `rat ` frame that does not authenticate is logged as
- **Session reset.** There is no `/reset` command and no in-band reset in `rat dropped (<reason>)` on stderr and dropped. There is no in-app desync banner.
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 (<reason>)` 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.
## File transfer ## File transfer
`/file /path` sends a local file to the selected friend. Both must be online. `/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 Cap 1 MiB (`file::MAX_BYTES`). Fail closed: a bad chunk or hash mismatch deletes
deletes the partial (never overwrite). Files land in the partial. Files land in `$ONIONWIRE_HOME/inbox/<fingerprint>/`. Chat shows
`$ONIONWIRE_HOME/inbox/<fingerprint>/`. Chat shows `[file] name (N bytes)`, `[file] name (N bytes)`. Not covered by the chat outbox.
never raw frames. File transfer is **not** covered by the chat outbox — no
resume, no images in the TUI.
## Profile ## 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) ## Monero (opt-in)
Chat does not need a wallet. Spend is opt-in at wallet create/restore; default Chat does not need a wallet. Spend is opt-in at wallet create/restore. Optional
is no spend key, no seed on the device. Optional JSON-RPC to `monero-wallet-rpc` on JSON-RPC to `monero-wallet-rpc` on **loopback only** (you run it, or the app
loopback (you run it, or the app spawns it). Chain source is your choice: a spawns it). Chain source is your choice: spawned local `monerod`, in-process
spawned local `monerod`, or a daemon address you supply. The wallet **must** Cuprate (opt-in feature, **unvalidated on mainnet**), or a daemon address you
use `--rpc-login`; OnionWire refuses an open RPC (HTTP 200 without a Digest type. The wallet **must** use `--rpc-login`; OnionWire refuses an open RPC and
challenge) and refuses URLs with no credentials. 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 ```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 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=http://127.0.0.1:18083
export ONIONWIRE_WALLET_RPC_LOGIN=onionwire:secret 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 `ONIONWIRE_WALLET_NO_SPEND=1` until you actually want `/tip`. Details:
[docs/WALLET.md](docs/WALLET.md).
**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:
| Command | Wire frame | What it does | | Command | Wire frame | What it does |
|---|---|---| |---|---|---|
| `/pay <xmr> [memo]` | `inv ` | Invoice to receive. We want to be paid. Uses a wallet subaddress if RPC is up, else the profile `xmr_addr`. | | `/pay <xmr> [memo]` | `inv ` | Invoice to receive. Subaddress if RPC is up, else profile `xmr_addr`. |
| `/tip <xmr> [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`. | | `/tip <xmr> [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). Peer onion down → `/pay` and `/tip` fail. A queued invoice does not exist.
- `/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.
## In-app wallet (create / import) `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.
`/wallet create` (F6 then `c`) generates a new spend-capable wallet on the RPC Type `SPEND` then `SEEN` on create. The in-app filename is `onionwire`; the RPC
(`create_wallet`), then shows the 25-word seed **once** for backup must be started with `--wallet-dir`.
(`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/<pid>/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.
## Backup / restore ## Backup / restore
Losing `identity_sk` loses every friend relationship. 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). - `/backup /path` — type `BACKUP`, passphrase twice. Writes `owbak1` (Argon2id +
- `/restore /path` — type `RESTORE`, passphrase. Overwrites self keys. **Does not rewrite the roster** — you may become a different person talking to old friends. ChaCha20-Poly1305). Onion is **not** in the file.
- `/restore /path` — type `RESTORE`, passphrase. Overwrites self keys. **Does not
Treat the backup file like the sqlite db. rewrite the roster.**
## 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.
## Wipe ## 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. Not a forensic erase (SSD wear-leveling). Esc cancels.
- `/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.
## Uninstall ## Uninstall
```bash ```bash
# binary (whichever you used)
rm -f ~/.local/bin/onionwire ~/.cargo/bin/onionwire 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 rm -rf ~/.local/share/onionwire
``` ```
@ -326,117 +353,76 @@ If you set `ONIONWIRE_HOME`, delete that directory instead.
## Seized laptop ## 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. Threat model: [docs/THREAT_MODEL.md](docs/THREAT_MODEL.md).
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).
## Android (SDK + APK) ## 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-<version>.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. - **SDK** — `onionwire-sdk-<version>.aar`. UniFFI Kotlin over the same Rust crate
- **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). the TUI runs. See [crates/onionwire-sdk/README.md](crates/onionwire-sdk/README.md).
- **APK** — `onionwire-<version>-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. - **APK** — `onionwire-<version>-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 The APK build is amd64-only. After the Linux `release` workflow finishes,
amd64-only — the Pi runner is aarch64 Linux and cannot produce an APK. dispatch `android-release` with that tag so the APK/AAR attach to the same
[`.forgejo/workflows/android-release.yml`](.forgejo/workflows/android-release.yml) Forgejo release.
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.
```bash ```bash
# one-time: sdkmanager platform 36 / build-tools 36.0.0 / ndk 28.2.13676358, scripts/build-android-local.sh # -> dist/, with .sha256
# rustup target add aarch64-linux-android, cargo install cargo-ndk PUBLISH_TAG=v0.14.0 scripts/build-android-local.sh # + upload to that release
scripts/build-android-local.sh # -> dist/, with .sha256 files
PUBLISH_TAG=v0.2.1 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 (maintainers)
Releases are **manual and batched**: no merge publishes anything, and neither Manual and batched: no merge publishes anything, and neither does a tag push.
does a tag push. Cut one when a batch of work has reached a stopping point — Full procedure: [docs/RELEASING.md](docs/RELEASING.md).
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.
Actions → release → Run workflow: Actions → **release** → Run workflow:
| Input | Meaning | | Input | Meaning |
|---|---| |---|---|
| `dry_run` | build + checksum both Linux binaries, no tag, no publish. Run this first. | | `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`. | | `bump` | `patch` / `minor` / `major` off the newest `v*.*.*` tag. Default `minor`. |
| `version` | explicit `X.Y.Z` (or `vX.Y.Z`) — overrides `bump`. | | `version` | explicit `X.Y.Z` — overrides `bump`. |
| `tag` | rebuild / re-publish an existing tag instead of minting one. | | `tag` | rebuild / re-publish an existing tag. |
Pass `tag` **or** `version`, not both; an unparseable version is rejected Then dispatch **android-release** with `tag=<that tag>` to attach the APK + AAR.
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-<target>`
+ `.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.
```bash ```bash
# optional: keep Cargo.toml in sync with the tag the workflow will mint FORGEJO_TOKEN=<pat> scripts/build-release-local.sh v0.14.0
# (the workflow does not edit Cargo.toml)
# offline x86_64 fallback (idempotent — safe to re-run)
FORGEJO_TOKEN=<pat> scripts/build-release-local.sh v0.2.1
``` ```
Workflows (Forgejo Actions, `.forgejo/workflows/`): Do not run `cargo publish`; `publish = false`.
- [`.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.
## Troubleshooting ## Troubleshooting
| Symptom | What to do | | Symptom | What to do |
|---|---| |---|---|
| `GLIBC_… not found` | Binary is newer than your libc. Build from source (Option B). | | `GLIBC_… not found` | Build from source (Option B). |
| `sha256sum: FAILED` | Re-download both the binary and `.sha256`; run the check in the same directory. | | `sha256sum: FAILED` | Re-download binary and `.sha256`; 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. | | Hang on `bootstrapping Arti…` | Outbound network required. Fail closed after 360s. No C-tor fallback. |
| `onionwire: unknown argument` | No subcommands. Flags are `--version` / `--help` only, then the TUI. | | `onionwire: unknown argument` | No subcommands. `--version` / `--help` only, then the TUI. |
| Blank / broken TUI | Run in a real terminal emulator, not `nohup` / systemd without a TTY. | | Blank / broken TUI | Real terminal emulator, not `nohup` / systemd without a TTY. |
| Two chats, same laptop | Separate `ONIONWIRE_HOME` per process. | | 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 ## 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 ## License
MIT MIT

View file

@ -651,6 +651,32 @@ impl Wire {
Ok(child_status(node.wallet_child_status(), &source)) Ok(child_status(node.wallet_child_status(), &source))
} }
/// One live probe of the app-owned wallet child, returning the same record
/// [`Wire::wallet_status`] reports — from a snapshot that was just taken
/// rather than one left behind by the last start.
///
/// It dials: the child's loopback wallet RPC, and the configured local
/// daemon's `get_info` when the wallet RPC does not answer. That is what
/// makes the chain's height and target move between calls.
///
/// It never spawns and never starts a child: a node with no child is not
/// launched for this call.
///
/// Safe to call from a UI refresh loop, but not free — it makes network
/// calls, so a caller should poll on the order of seconds rather than every
/// frame. [`Wire::wallet_status`] stays the cheap, non-dialing read for
/// first paint.
///
/// The honest limit: with no live child, the core short-circuits and returns
/// the cached `off` / `exited` snapshot, so this can never invent `ready` or
/// any other live state for a child that is not there. `WireError.Stopped`
/// after `shutdown`.
pub async fn wallet_child_refresh(&self) -> WResult<WalletChildStatus> {
let node = self.node()?;
let source = node.wallet_child_config().source;
Ok(child_status(node.wallet_child_refresh().await, &source))
}
/// The chain-source + binary settings the child spawns with, as stored. /// The chain-source + binary settings the child spawns with, as stored.
/// Returns the defaults (receive-only, binaries by name) when nothing was /// Returns the defaults (receive-only, binaries by name) when nothing was
/// ever set, so a settings screen can prefill from it safely. /// ever set, so a settings screen can prefill from it safely.
@ -1997,4 +2023,68 @@ mod tests {
assert_eq!(status.height, 0); assert_eq!(status.height, 0);
assert_eq!(status.target_height, 0); assert_eq!(status.target_height, 0);
} }
/// A live probe on a node with no child is `off` — the same record the
/// cheap read reports — never an error and never an invented state.
///
/// This crate cannot build the node half of that: `open_wire` is the only
/// constructor of `Wire` and it bootstraps Arti and publishes an onion
/// service, so there is no offline `Node` for a test to hold. What is
/// pinned here is the half the SDK owns — both exported reads hand the same
/// core snapshot to the same `child_status` mapper — plus the record shape,
/// written as an exhaustive literal so a new field on `WalletChildStatus`
/// stops this test compiling. The core's own short-circuit (`wallet_child`
/// is `None` ⇒ return the cached snapshot) is what `src/node.rs`'s tests
/// exercise.
#[test]
fn an_unprobed_child_is_off_whichever_read_reports_it() {
let core = onionwire::wallet_child::WalletChildStatus {
state: WalletChildState::Off,
running: false,
configured: false,
chain_source: "receive-only".to_string(),
height: 0,
target_height: 0,
last_error: None,
};
let source = ChainSource::None;
let want = WalletChildStatus {
state: "off".to_string(),
running: false,
configured: false,
chain_source: "receive-only".to_string(),
chain_in_process: false,
node_available: onionwire::cuprate::available(),
node_state: String::new(),
height: 0,
target_height: 0,
last_error: None,
};
// `wallet_status` maps it once, `wallet_child_refresh` maps the same
// snapshot the same way: one mapper, no second state machine.
for got in [
child_status(core.clone(), &source),
child_status(core, &source),
] {
assert_eq!(got.state, want.state);
assert_eq!(got.running, want.running);
assert_eq!(got.configured, want.configured);
assert_eq!(got.chain_source, want.chain_source);
assert_eq!(got.chain_in_process, want.chain_in_process);
assert_eq!(got.node_available, want.node_available);
assert_eq!(got.node_state, want.node_state);
assert_eq!(got.height, want.height);
assert_eq!(got.target_height, want.target_height);
assert_eq!(got.last_error, want.last_error);
}
}
/// The live probe is an error, not a panic, once the handle is shut down:
/// it goes through the same `node()` accessor as every other call.
#[test]
fn wallet_child_refresh_on_a_stopped_handle_is_stopped_error() {
let err = block_on(stopped_wire().wallet_child_refresh()).expect_err("must fail");
assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}");
}
} }

View file

@ -46,8 +46,7 @@ notes / the crate's own `rust-version`, then raise it in the same PR:
* `rust-version` in `Cargo.toml`, * `rust-version` in `Cargo.toml`,
* `RUST_IMAGE` in `.forgejo/workflows/ci.yml` **and** `.forgejo/workflows/release.yml`, * `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 * the "Rust 1.91+" line in `README.md`.
when that lands, or ask the owner).
## How this gets noticed ## 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 descriptor upload, not a hang), probe-connect against a live HS, a byte pipe
in both directions, restart, and the dormant/offline path. in both directions, restart, and the dormant/offline path.
7. Confirm the fail-closed path by hand if the publish wait changed at all: 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 with the publish wait still 360s, if Arti cannot publish the onion the
send. There is no outbox in v1 — the message must not be silently queued. 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 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 is less about exercising a non-default feature than about proving the default
still cross-compiles where OpenSSL does not exist: 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. the plaintext should appear in Arti's state directory.
10. Open a PR against `main` describing: crates bumped, MSRV, the live-test 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 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 ## Rolling back

View file

@ -4,7 +4,7 @@ This is the wire protocol. A second implementation should be able to
interoperate from this document without reading the Rust. interoperate from this document without reading the Rust.
It is **not** an IETF RFC. It describes what this repository speaks today 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. third-party audit. Arti onion services are experimental upstream.
Related: [threat model](THREAT_MODEL.md), [audit notes](SECURITY_AUDIT.md). Related: [threat model](THREAT_MODEL.md), [audit notes](SECURITY_AUDIT.md).
@ -46,7 +46,7 @@ not on the wire.
## Transport ## Transport
1. Each peer publishes a Tor v3 onion service (in-process Arti in this tree). 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, 3. The sender opens a Tor circuit to `(friend.onion, 80)`, runs the handshake,
sends **one** application frame, and drops the circuit. sends **one** application frame, and drops the circuit.
4. File transfer is N independent sessions (one handshake per chunk). There is 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 store-and-forward relay: each attempt is a fresh handshake straight to
`(friend.onion, 80)`, exactly as above. Retries fire on a timer, on `(friend.onion, 80)`, exactly as above. Retries fire on a timer, on
unlock/foreground, and whenever that peer is heard from (successful handshake or unlock/foreground, and whenever that peer is heard from (successful handshake or
`connect_onion()`). A protocol failure — signature mismatch, unknown frame, a connect to that onion). A protocol failure — signature mismatch, unknown
oversize — is not a transport failure and is never queued. 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 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 **not** queued. The locator-push path retries for 180 seconds and then gives up.
gives up.
Incoming rendezvous accepts are token-bucket limited: 30 per 60s, burst 10. Incoming rendezvous accepts are token-bucket limited: 30 per 60s, burst 10.
Excess is dropped before handshake. That is availability, not anonymity. 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 1. **IK msg 1** — initiator → responder (framed). Responder’s Noise static is
the invite `spk`. 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. Unknown prekey → close. This is how the answerer learns who is calling.
3. **IK msg 2** — responder → initiator (framed). 3. **IK msg 2** — responder → initiator (framed).
4. Both sides enter transport mode. Handshake hash `h` is 32 bytes (BLAKE2s). 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 | | Prefix (4 bytes) | Kind | If unknown / invalid |
|---|---|---| |---|---|---|
| `rat ` | Double Ratchet chat frame (see Ratchet) | drop |
| `loc ` | locator update | drop | | `loc ` | locator update | drop |
| `prf ` | profile | drop | | `prf ` | profile | drop |
| `inv ` | Monero invoice | drop | | `inv ` | Monero invoice | drop |
| `rcp ` | Monero receipt claim | 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 | | `fil ` | file chunk | drop |
| `rat ` | Double Ratchet chat frame (see Ratchet) | drop |
| `[a-z][a-z][a-z] ` | unknown typed frame | **drop** (not chat) | | `[a-z][a-z][a-z] ` | unknown typed frame | **drop** (not chat) |
| anything else | chat | store as a chat line | | 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. upgrade both sides.
A peer that does not implement a typed prefix MUST still drop A peer that does not implement a typed prefix MUST still drop
`[a-z]{3}<space>…` rather than render it as chat. Mixed-version 0.1.2 clients `[a-z]{3}<space>…` rather than render it as chat.
that stored those as chat are obsolete; upgrade both sides.
Chat MUST NOT begin with three lowercase ASCII letters and a space. (Inside a 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.) `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. form and, for mixed-version peers, the legacy untagged LF-joined layout.
Anything else fails closed. Do not emit the legacy 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). The invite string is separate and keeps `onionwire-invite-v1` (see Invite).
Older builds verify only the untagged bytes, so they reject tagged signatures 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 accepted on verify. New invoices MUST use the domain-separated form. Do not
emit legacy. 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) ### `rcp ` — receipt claim (we paid)
@ -279,8 +282,32 @@ emit legacy.
Signature proves which friend sent the claim. It does **not** prove money 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 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` one transfer row with the same non-empty `txid`, `amount`, and `address`
(conjunction, not OR). RPC down → stay unverified. Wallet RPC is loopback (conjunction, not OR). RPC down or an unsynced daemon → stay unverified.
HTTP Digest; it is not this protocol. 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 <txid>\n<amount_atomic>\n<address>\n<memo>\n<ts>\n<sig_hex>
```
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 ### `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 The sender is responsible for fitting the receiver's documented rendezvous
budget (30 accepts / 60s, burst 10). Chunks MUST be paced so the average 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 interval between send attempts stays at least 3s. A sender MAY retry an
refill; pacing at exactly 2s sits on the refill boundary and drains under individual chunk a bounded number of times (this tree: 3). Exhausting retries
jitter. A sender MAY retry an individual chunk a bounded number of times. fails the transfer. No outbox, no resume, no continuation under a new
Exhausting retries fails the transfer. No outbox, no resume, no continuation `xfer_id`.
under a new `xfer_id`.
``` ```
fil <xfer_id_hex>\n<filename>\n<sha256_hex>\n<idx>/<total>\n<raw bytes> fil <xfer_id_hex>\n<filename>\n<sha256_hex>\n<idx>/<total>\n<raw bytes>
@ -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 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 (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 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 UTF-8 is not enforced for chat text: invalid bytes become U+FFFD (the
implementation does not drop the row). Control and bidi formatting 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. session.
The ratchet header is **inside** the Noise transport message, never in clear on 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 wire. A plaintext header (`dh_pub || N || PN`) would hand an observer
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
per-message counters and ratchet-key changes for no benefit — the Noise session 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 already hides the frame, so the header is authenticated as AEAD associated data
instead. instead.
@ -386,9 +410,8 @@ KDF_CK(chain_key):
next_chain_key = HMAC-SHA256(chain_key, 0x02) next_chain_key = HMAC-SHA256(chain_key, 0x02)
``` ```
`HKDF` is RFC 5869 with SHA-256 (`hkdf` 0.12), `HMAC` is SHA-256 (`hmac` `HKDF` is RFC 5869 with SHA-256, `HMAC` is SHA-256. Each side of an epoch
0.12). Each side of an epoch derives its chains from one shared DH output with derives its chains from one shared DH output with `KDF_RK` called **twice**:
`KDF_RK` called **twice**:
``` ```
epoch_chains(root, shared) -> (new_root, ck_lo, ck_hi): 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 `ratchet_sessions` in the SQLCipher store: one row per friend
(`friend_id` primary key, `FOREIGN KEY` → `friends.id` `ON DELETE CASCADE`, (`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 `state BLOB NOT NULL`, `updated_at`). The blob is version byte `0x01` followed by
the implementation's serialized `RatchetState` (root, keypairs, both chain keys the implementation's serialized ratchet state. The state is device-local: it is
and counters, `established`, and the skipped-key store). The state is **never** transmitted, and its layout is not part of this wire protocol. The
device-local: it is **never** transmitted, and its layout is not part of this store is encrypted as a whole, so the blob is ciphertext on disk.
wire protocol. The store is encrypted as a whole, so the blob is ciphertext on
disk.
### Not ratcheted ### Not ratcheted
@ -570,8 +591,13 @@ Unknown `k`: prompt. Same `k`: update onion and prekey only.
## What v1 will not grow into ## What v1 will not grow into
No DHT, no hosted server, no XMPP, no store-and-forward, no multi-device, no No DHT, no directory server, no hosted/server-side outbox, no XMPP/Prosody, no
A/V, no STUN/ICE/WebRTC, no SOCKS/C-tor fallback, no system DNS for friends. 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 Those are how Tox-over-Tor leaks (UDP DHT, mixed clearnet, “just one direct
path”). They are out of scope, not postponed. path”). They are out of scope, not postponed.

View file

@ -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 3. **[SECURITY_AUDIT.md](SECURITY_AUDIT.md)** — in-house review notes and
which findings are still open. **Not** a public third-party audit. which findings are still open. **Not** a public third-party audit.
Operator / product docs stay in the [root README](../README.md). Android Operator / product docs:
build notes: [android/README.md](../android/README.md). SDK:
- **[../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). [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)

View file

@ -1,7 +1,10 @@
# Releasing OnionWire # Releasing OnionWire
Policy and procedure for cutting a release. Read How a maintainer cuts a release. This is **not** automatic: a merge to `main`
[`README.md`](../README.md#releases-maintainers) for the short version. 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 ## Policy: manual, batched releases

View file

@ -2,7 +2,7 @@
**This is not a public third-party audit.** It is an in-house review of **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 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). 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). - 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. - 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). - Invite decode still accepts the legacy concat signature (compatibility).
- Rate limit is availability, not traffic-analysis defense. - Rate limit is availability, not traffic-analysis defense.
- One-shot sessions: no channel binding across file chunks beyond “same Noise peer.” - 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) ## Verified correct (original pass, still the protocol)

View file

@ -1,8 +1,10 @@
# OnionWire threat model (v1) # OnionWire threat model (v1)
OnionWire is a two-party chat over Tor onion services. There is no chat server. 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: Identity is an ed25519 pubkey; the onion is a locator only (`F4` rotates the
[SECURITY_AUDIT.md](SECURITY_AUDIT.md) — **not** a public third-party audit. 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 ## 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 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 (Cuprate issue #278). This is why the source is an opt-in build feature and
a stored user choice, never a default. 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, - 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 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 traffic is **clearnet**: your ISP sees that this device talks to Monero

File diff suppressed because it is too large Load diff

View file

@ -8,402 +8,214 @@ receipt checks (`get_transfers`). `/tip` is off.
**Spend is opt-in** at wallet create or restore (seed-backed). That makes **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 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 The app talks to `monero-wallet-rpc` over **loopback HTTP Digest only**, and it
own that process itself: can own that process itself:
- hand out a receive subaddress for `/pay` invoices (`create_address`), - hand out a receive subaddress for `/pay` invoices (`create_address`),
- read incoming transfers to verify a peer's receipt (`get_transfers`), - read incoming transfers to verify a peer's receipt (`get_transfers`),
- and — only if you opted into spend — `/tip` (`transfer`). - and — only if you opted into spend — `/tip` (`transfer`).
**Prefer view-only until you actually want `/tip`.** Everything else in this **Prefer view-only until you actually want `/tip`.**
document explains why, and what breaks when you do.
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 ## The app-owned wallet child
`src/wallet_child.rs` owns the child pair instead of asking you to start it and `src/wallet_child.rs` owns the child pair instead of asking you to export an
export an env var: env var:
- **`monero-wallet-rpc`** is spawned with `--rpc-bind-ip 127.0.0.1`, a **random - **`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 free loopback port**, a generated `--rpc-login` (`user:pass`, random
it on — two instances on one box cannot collide), a generated `--rpc-login` `[a-z0-9]`), and `--wallet-dir $ONIONWIRE_HOME/wallet`.
(`user:pass`, random `[a-z0-9]`, no shell or HTTP metacharacters), and - **`monerod`** is spawned when the chain source is *local*:
`--wallet-dir $ONIONWIRE_HOME/wallet`.
- **`monerod`** is spawned too when the chain source is *local*:
`--non-interactive --data-dir <datadir> --rpc-bind-ip 127.0.0.1 --rpc-bind-port `--non-interactive --data-dir <datadir> --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 - **`arti`** is spawned as a SOCKS child only when the chain source is a
`.onion` daemon: `arti proxy -p <port>` (see below). `.onion` daemon: `arti proxy -p <port>`.
- `--trusted-daemon` is never passed. A remote daemon stays untrusted. - `--trusted-daemon` is never passed.
- The wallet dir is created `0700` and the wallet file is kept `0600` — it is a - Wallet dir `0700`, wallet file `0600`.
spend authority. - The child is watched by polling (`try_wait`). `stop()` kills children on
- The child is watched by polling (`try_wait`); an exit is reported rather than shutdown. Nothing promises “always running”, and Android will not.
hidden, and `stop()` kills both children on shutdown. The next launch starts
them again. 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 The wallet passphrase for `create_wallet` / `restore_deterministic_wallet` is
encrypted SQLCipher store** (`wallet_child` table, AEAD with the store key on top your runtime choice, not stored by the app.
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 is a separate thing: the child prompts/needs it for Nothing spawns the child at boot. `Node::start_wallet_child` is the only start
`create_wallet` / `restore_deterministic_wallet`, and that is your runtime choice, path. The desktop TUI drives it from `F6`:
not something the app stores for you.
| 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 <height>/<target>`
— 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 ## Chain source
The wallet needs a daemon for scan, verify, and spend. You pick one; OnionWire You pick one. OnionWire does not pick a public remote node for you.
does not pick a public remote node for you. The four shapes are:
``` ```
ChainSource::None receive-only; no child, no daemon ChainSource::None receive-only; no child, no daemon
ChainSource::Local { monerod_bin, datadir } the app spawns monerod on this box ChainSource::Local { monerod_bin, datadir } spawn monerod on this box (port 18081)
ChainSource::InProcessCuprate { datadir } the daemon is inside this app ChainSource::InProcessCuprate { datadir, … } daemon inside this app (port 18081)
ChainSource::Remote { host, port } a daemon address you typed ChainSource::Remote { host, port } a daemon address you typed
``` ```
1. **Local `monerod`.** Chain traffic stays on the box. You accept disk, first 1. **Local `monerod`.** Chain traffic stays on the box.
sync, and (on Android) the daemon not always running. 2. **In-process Cuprate.** No `monerod` binary. Wallet child still dials
2. **An in-process daemon** ([Cuprate](https://github.com/Cuprate/cuprate) `127.0.0.1:18081`. See below.
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.
3. **A daemon address you supply** — becomes `--daemon-address` on the wallet 3. **A daemon address you supply** — becomes `--daemon-address` on the wallet
child. Loopback if you already run `monerod`. `.onion` if you want chain 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 traffic over Tor. Clearnet only if you type it — never a default. Restricted
type it — your ISP sees Monero-node traffic; it is never a default. 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, Settings live in the sealed `wallet_child` record (`ChildConfig`: `source`,
but you supply it. `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`) ### 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 cargo build --release --features cuprate-daemon
``` ```
- **Off by default.** `cuprated` is pre-1.0 and is not published to crates.io - **Off by default.** `cuprated` is pre-1.0, not on crates.io (placeholder
(every Cuprate crate there is a `0.0.0-placeholder` name reservation), so it is crates), git-pinned, behind the feature. Without the feature, a stored
a git dependency pinned to a revision, behind the `cuprate-daemon` feature. A in-process source can still be read back, but start fails with
default build does not compile it: the graph is large (RandomX, fjall, `this build has no in-process chain daemon — rebuild with --features cuprate-daemon`.
axum/hyper, rayon) and it is a *choice*, never compiled-in. Without the feature - **Pre-production.** Cuprate's own user book says do not use `cuprated` for
a stored in-process chain source can still be read back — the chain-source type serious purposes. RPC parity is incomplete (`docs/cuprate-launch-spike.md`).
and its record do not fork on a cargo feature — but starting it fails with - **Mainnet is unvalidated.** The TUI can store mainnet-pruned (`F6` `1`) or
`this build has no in-process chain daemon — rebuild with --features mainnet-full (`F6` `2`) or testnet (`F6` `3`). Every in-process surface still
cuprate-daemon`. prints `testnet only — mainnet is unvalidated` (`cuprate::TESTNET_ONLY`).
- **+11.8 MiB (12,327,768 bytes)** on a stripped `aarch64-linux-android` release Cross-compiled is not device-proven. Pointing a mainnet wallet at it is not
binary, measured in this repo: 24,725,704 bytes without the feature and something this build claims to do.
37,053,472 with it (`cargo rustc --release --target aarch64-linux-android - **No Tor on the chain path.** Cuprate's `arti` feature is off (arti-client
[--features cuprate-daemon] --bin onionwire`, both linked with the NDK C++ 0.44 vs this crate's 0.46). P2P is **clearnet**. OnionWire's Arti is the
runtime / compiler-rt link args, then `llvm-strip`). The `+5.6 MB` figure that messenger only.
circulated with the spike was an estimate and understates it. A cold build - **Inbound P2P off**, restricted RPC listener disabled. Unrestricted RPC is
also compiles the Cuprate graph in addition to this crate's own, so first-build loopback 18081. `--trusted-daemon` still never passed.
time grows accordingly. - Chain lives under `$ONIONWIRE_HOME/chain/…` (split dirs so pruned mainnet
- **Testnet only.** Cuprate is **pre-production software**. Its own user book cannot mix with full). Database is **fjall**, not SQLCipher.
says *"do NOT use cuprated for any serious purposes"*, and its `monerod` RPC - Not a child process: dropping the node shuts it down. `x` / `stop_wallet_child`
parity is incomplete (Cuprate issue #278; the four gaps measured in this repo asks it to stop with the wallet child.
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 (`<datadir>/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.
### Chain traffic over Tor (`.onion` daemons) ### Chain traffic over Tor (`.onion` daemons)
A `.onion` daemon cannot be dialled directly, and OnionWire does not fall back A `.onion` daemon cannot be dialled directly. The wallet child is an external
to a clearnet resolve. The wallet child is an external C++ binary, so it reaches C++ binary, so it reaches Tor through a SOCKS proxy the app provides:
Tor the only way it can: through a SOCKS proxy the app provides.
- The app runs the **bundled `arti` binary** as a child: - Bundled `arti` binary: `arti proxy -p <random free loopback port>`. A second
`arti proxy -p <random free loopback port>`. `arti-client` 0.46 has no SOCKS Tor client, not the messenger's in-process one. No C-tor.
listener API — the SOCKS listener lives in the `arti` *binary* — so this is a - Listener is TCP loopback only. Any local process at your privilege can use it.
second, separate Tor client, not the messenger's in-process one. There is no - Wallet child: `--proxy socks5://127.0.0.1:<port>` and
C-tor and no system `tor`. `--daemon-address <onion>:<port>`. The `socks5://` scheme is required (Monero
- The listener is **TCP loopback only**. `arti proxy -p <port>` binds localhost defaults to SOCKS4a for a bare `host:port`). No local DNS on the onion target.
(`127.0.0.1` and `::1`) and nothing else, and there is nothing safer to - Own state/cache: `$ONIONWIRE_HOME/wallet/arti-socks/{state,cache}`.
prefer: `arti` 2.6.0 / `tor-config` 0.46 have no Unix-socket listen target - Wait up to 20s for the SOCKS listener before spawning the wallet child.
(`Listen` is IP-only; arti's own port record calls AF_UNIX future work, - SOCKS child stops with the wallet child.
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:<port>` **and** `--daemon-address <onion>:<port>`.
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.
**Tor hides the transport, not the host.** The daemon operator still sees the **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 wallet's addresses during sync.
`.onion` address protects the path between you and that operator, nothing more.
The TUI copy for a chain source says this in one line ### Readiness — receipt verification needs a synced daemon
(`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, 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 == Until then, **receipt verification stays `verified=0`**. An unsynced wallet
true`** with `height > 0` and `height >= target_height`. A missing field is cannot see the chain. That is an honest limit, not a UI bug.
*not ready* — fail closed, never a silent pass. Until then:
- **receipt verification stays `verified=0`** (an unsynced wallet cannot see the Loopback management calls (`get_address`, `query_key`, create/import) get 5s.
tx, so a `get_transfers` miss would be a lie), and Calls that wait on the chain (`get_info`, `get_transfers`, `transfer`) get 60s
- **spend is refused** with `wallet is not synced — spend refused until the (`CHAIN_RPC_TIMEOUT`).
daemon reaches the chain tip`.
`spend_ready()` is the stricter signal the spend UI reads: chain-ready *and* ## Env vars (migration path)
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
| Variable | Meaning | | 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` | `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 you do not want the password in the URL. Ignored if the URL carries userinfo. | | `ONIONWIRE_WALLET_RPC_LOGIN` | `user:pass` when the URL has no userinfo. |
| `ONIONWIRE_WALLET_NO_SPEND` | `1` / `true` / `yes` / `on` → view-only deployment: `/tip` is refused locally, before any RPC dial. `/pay` and receipt verification keep working. | | `ONIONWIRE_WALLET_NO_SPEND` | `1` / `true` / `yes` / `on` → `/tip` refused locally before any RPC dial. |
These three are the **migration path**, not the only path: a config stored in Boot precedence: **stored config → env → disabled**. Stored config that cannot
the encrypted store wins at boot. See *Stored wallet config* below. 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 1. not configured → the F7-worded message above
be stored instead, so a deployment never needs env at all: 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 | ## Android / SDK
|---|---|
| `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`. |
`Store::save_wallet_config` / `Store::load_wallet_config` are the read/write UniFFI: `set_chain_source(ChainConfig)` / `chain_source()`,
pair, and `Node::wallet_save_config` re-reads the live wallet after a save so `start_wallet_child()`, `stop_wallet_child()`, `wallet_status()` (cached read:
`configured` / the readouts follow without a restart. **No screen in this no dial, for first paint) and `wallet_child_refresh()` (a live probe of the
repository calls them yet**: the TUI wallet config screen (F7) and its endpoint same record — it dials the loopback wallet RPC, and the local daemon's
entry, test-connection button and save path ship on `get_info` when that RPC does not answer, so poll it on the order of seconds).
`feat/wallet-create-import`, which is not part of this change — see Pass absolute paths for `wallet_rpc_bin` / `arti_bin` (`nativeLibraryDir`); the
*Starting and stopping the app-owned child* below for what this stack does core never resolves a binary the caller named explicitly.
expose. Until that lands, set the stored config programmatically (or use the env
vars above).
They live in the **encrypted SQLCipher store** (`wallet_config` table, one row: `ChainChoice.InProcessCuprate` is the in-process variant. Empty
the URL and the flag in the clear inside the encrypted db, the login sealed with `monerod_datadir` resolves to `$ONIONWIRE_HOME/chain`. `start_wallet_child()`
the store data key and a `onionwire/wallet-config/v1` AAD on top of whole-db launches the node *and* the wallet child. `wallet_status()` carries
encryption — the same discipline as the wallet-child creds). Save replaces the `chain_in_process`, `node_available`, and `node_state`.
row; clearing the URL deletes it, which is how you turn the stored wallet off
again.
**Boot precedence is stored → env → disabled.** Stored config wins; the env vars Monero ships **no Android binaries**. Any vendored blob's provenance doc must
in the table above remain the migration path (and the only path for headless say so. Cross-compiled is not device-proven. See `android/MONERO_BINARIES.md`.
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 (`<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()`. 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.
## Create vs import ## Create vs import
Create does **not** take a private key. `/wallet create` (TUI: F6 then `c`) asks `/wallet create` (`F6` then `c`) → `create_wallet`, then seed **once**
the RPC to generate a new spend-capable wallet (`create_wallet`), then shows the (`query_key mnemonic`). Type `SPEND`, set a passphrase, write the seed, type
seed **once** for backup (`query_key mnemonic`). Type `SPEND` to accept the `SEEN`.
spend-authority warning, set a passphrase, write the seed down, type `SEEN`.
Import is the only path that takes an existing secret: `/wallet import` (F6 then `/wallet import` (`F6` then `i`) → `restore_deterministic_wallet` from a
`i`) pastes the 25-word seed into `restore_deterministic_wallet`. Do not put the 25-word seed. Do not put the seed on the composer.
seed on the composer line — it would sit in chat history.
The RPC must be started with `--wallet-dir` (not only `--wallet-file`) or create RPC must be started with `--wallet-dir` (not only `--wallet-file`). Filename:
and import fail. The in-app filename is `onionwire`. `onionwire`.
## Recommended topology ## Recommended topology (view-only)
``` ```
wallet host (this machine) wallet host (this machine)
@ -416,38 +228,19 @@ and import fail. The in-app filename is `onionwire`.
└──────────────────────────────────────────────────────────────┘ └──────────────────────────────────────────────────────────────┘
``` ```
Loopback is the only address OnionWire will dial for **wallet RPC**. `.onion` Loopback is the only address OnionWire will dial for **wallet RPC**.
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.
## Create a view-only wallet ## Create a view-only wallet
Either path produces a wallet file with the view key only. Keep the seed / Keep the seed / spend key on a machine that is **not** running OnionWire.
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):
```bash ```bash
monero-wallet-cli --generate-from-view-key "$HOME/.onionwire-viewonly" \ monero-wallet-cli --generate-from-view-key "$HOME/.onionwire-viewonly" \
--daemon-address "$YOUR_MONEROD:18089" --restore-height "$BIRTH_HEIGHT" --daemon-address "$YOUR_MONEROD:18089" --restore-height "$BIRTH_HEIGHT"
# Standard address: 4...
# Secret view key: <hex>
``` ```
Or through a running RPC that was started with `--wallet-dir` (`generate_from_keys` `18089` here is the **remote** daemon's restricted RPC, an address you type —
without `spendkey` writes a watch-only wallet): not the app-owned 18081.
```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":"<hex>","restore_height":<height>}}'
# → "Watch-only wallet has been generated successfully."
```
Then serve it:
```bash ```bash
monero-wallet-rpc --wallet-file "$HOME/.onionwire-viewonly" \ monero-wallet-rpc --wallet-file "$HOME/.onionwire-viewonly" \
@ -459,78 +252,36 @@ export ONIONWIRE_WALLET_RPC_LOGIN=onionwire:secret
export ONIONWIRE_WALLET_NO_SPEND=1 export ONIONWIRE_WALLET_NO_SPEND=1
``` ```
Restore the wallet from a height *at or before* its first incoming transaction Restore from a height at or before the first incoming transaction.
— a view-only wallet cannot rescan cheaply from height 0.
## What works, what does not ## What works, what does not
| Feature | View-only | Spend-capable | | Feature | View-only | Spend-capable |
|---|---|---| |---|---|---|
| `/pay <xmr>` invoice subaddress (`create_address`) | works | works | | `/pay <xmr>` 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 | | Profile `xmr_addr` fallback when RPC is down | works | works |
| `/tip <xmr>` (`transfer`) | **cannot work** | works | | `/tip <xmr>` (`transfer`) | **cannot work** | works |
| OnionWire copies your spend key into its own process | never | never (it stays in the wallet file / RPC) | | 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 `ONIONWIRE_WALLET_NO_SPEND=1` refuses `/tip` before RPC with:
contacted, with:
``` ```
wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt verification still work 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 View-only detection after a failed `transfer`: `query_key` `spend_key` → `-29`
OnionWire then asks the wallet directly whether it can spend (see below), so you watch-only. The spend key is discarded immediately. OnionWire never probes a
get the same sentence instead of a raw RPC error. healthy wallet for this.
## 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 = <hex secret spend 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.
## Why loopback still needs authentication ## Why loopback still needs authentication
`--rpc-bind-ip 127.0.0.1` keeps the port off the network; it does **not** keep it `--rpc-bind-ip 127.0.0.1` keeps the port off the network; it does **not** keep
away from other users or processes on the same machine. Any local process can it away from other processes on the same machine.
`connect(127.0.0.1:18083)`.
- OnionWire refuses an RPC that answers HTTP 200 without a Digest challenge, and 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 refuses URLs without credentials. Prefer `ONIONWIRE_WALLET_RPC_LOGIN` over
to every local process — with a spend-capable wallet file, that is a userinfo in the URL. Do not log the password.
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.
## The spend-authority warning ## The spend-authority warning
@ -540,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. 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 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 ## Payments are one-shot
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.
If you want tips to work, understand that you are deliberately making the `/pay` and `/tip` fail when the peer onion is down. There is no queued invoice.
OnionWire process able to spend. Give it a **separate hot wallet with a small File transfer is the same rule.
balance**, not your savings wallet.
## References ## References
- Monero Wallet RPC reference: - Monero Wallet RPC: <https://www.getmonero.org/resources/developer-guides/wallet-rpc.html>
<https://www.getmonero.org/resources/developer-guides/wallet-rpc.html> - `WALLET_RPC_ERROR_CODE_WATCH_ONLY = -29` in the Monero tree
- `on_query_key` (view-only → `-29`): - Spike history (not operator docs): [cuprate-launch-spike.md](cuprate-launch-spike.md),
<https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server.cpp> [arti-socks-feasibility.md](arti-socks-feasibility.md)
- `WALLET_RPC_ERROR_CODE_WATCH_ONLY = -29`:
<https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server_error_codes.h>
- `--generate-from-view-key` (incoming-only wallet):
<https://github.com/monero-project/monero/blob/master/src/simplewallet/simplewallet.cpp>
- `generate_from_keys` (watch-only when `spendkey` is omitted):
<https://www.getmonero.org/resources/developer-guides/wallet-rpc.html#generate_from_keys>

View file

@ -1,5 +1,9 @@
# Arti SOCKS Feasibility Report # 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 **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? **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. **Verdict:** **Not directly.** The `arti-client` library does not expose a configurable SOCKS proxy listener. See options below.

View file

@ -1,5 +1,9 @@
# Cuprate on Android aarch64 — cross-compile spike # 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 **Question (kanban `t_8293d96d`):** do the native dependencies of the in-process
Cuprate daemon (`randomx-rs`, `fjall`, sqlite, the C++ RandomX build) cross-compile 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 for the Android NDK target `aarch64-linux-android`? If they do not, §7a's Phase 1

View file

@ -1,5 +1,8 @@
# Cuprate in-process launch spike (Phase 1, Spike A) # 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 **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 *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 — `127.0.0.1:18089` answer `get_info`, `get_height` and `get_block` the way `monerod` does —

View file

@ -1,5 +1,8 @@
# Recommendation: Option A — bundle the `arti` binary as a SOCKS subprocess # 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 ## What Option A is
Run the `arti` CLI (not `arti-client`) as a child process doing `arti proxy -p <port>`. The wallet child points `--proxy 127.0.0.1:<port>` 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. Run the `arti` CLI (not `arti-client`) as a child process doing `arti proxy -p <port>`. The wallet child points `--proxy 127.0.0.1:<port>` 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.

View file

@ -1,5 +1,11 @@
# OnionWire payment integration — next steps # 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. **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. **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.