Compare commits

...
Author SHA1 Message Date
agent
67fb572962
store: widen payments.kind to accept 'tip' so tips are stored
Some checks failed
android-ci / android (pull_request) Successful in 9m49s
ci / test (pull_request) Successful in 5m2s
ci / sdk (pull_request) Successful in 1m10s
ci / fuzz (pull_request) Failing after 1m9s
insert_payment has allowed kind = "tip" since the tip path landed, but the
payments table's CHECK only permitted invoice/receipt, so every tip insert
failed ("CHECK constraint failed: kind IN ('invoice','receipt')"). That made
the outbound tip row impossible and silently broke the inbound path too:
ingest_tip returned early and neither the row nor the [tip] chat line was
written.

- recreate the table with the widened CHECK on open, copying rows verbatim
  (new stores get it from the schema directly)
- outbound tip() records kind = "tip" with the tip's memo, matching ingest_tip
- tests: outbound row, inbound round trip, pre-tip store migration

Refs kanban t_ecf204ad
2026-09-17 21:43:26 -04:00
24b5c93c43 Merge pull request 't_2fb507c6: F8 rotate prekey (Node::rotate_prekey + invite re-encode)' (#101) from wt/t_2fb507c6 into main
Some checks failed
android-ci / android (push) Successful in 8m28s
ci / test (push) Has been cancelled
ci / sdk (push) Has been cancelled
ci / fuzz (push) Has been cancelled
Reviewed-on: #101
2026-09-18 01:21:45 +00:00
724e0427b0 Merge pull request 'tls: default to Arti's rustls backend (drop OpenSSL from TLS)' (#100) from wt/t_17e3d3cf-rustls-default into main
Some checks failed
android-ci / android (push) Successful in 9m42s
ci / test (push) Successful in 4m42s
ci / sdk (push) Successful in 1m1s
ci / fuzz (push) Failing after 59s
Reviewed-on: #100
2026-09-18 01:20:35 +00:00
049b612169 Merge branch 'main' into wt/t_17e3d3cf-rustls-default
Some checks failed
android-ci / android (pull_request) Successful in 8m17s
ci / test (pull_request) Successful in 4m50s
ci / sdk (pull_request) Successful in 1m6s
ci / fuzz (pull_request) Failing after 58s
2026-09-18 01:05:55 +00:00
407b11f2f8 Merge pull request 'docs+tui: reachability stance (no sealed mailbox) and peer-unreachable queued footer' (#99) from wt/t_d662c8a6 into main
Some checks failed
android-ci / android (push) Successful in 8m31s
ci / test (push) Successful in 4m57s
ci / sdk (push) Successful in 1m5s
ci / fuzz (push) Failing after 36s
Reviewed-on: #99
2026-09-18 01:02:21 +00:00
deaa8a7cfa Merge pull request 'ci: nightly cargo-fuzz job for fuzz/ (PR #103 harness)' (#104) from wt/t_16e835ef into main
Some checks failed
ci / test (push) Successful in 4m41s
ci / sdk (push) Successful in 58s
ci / fuzz (push) Failing after 1m11s
Reviewed-on: #104
2026-09-18 01:00:39 +00:00
agent
bfbbdbf14f
ci: nightly cargo-fuzz job for fuzz/ (PR #103 harness)
Some checks failed
ci / test (pull_request) Successful in 4m47s
ci / sdk (pull_request) Successful in 57s
ci / fuzz (pull_request) Failing after 1m8s
Add a  job to .forgejo/workflows/ci.yml that builds the four
libFuzzer targets on nightly (ratchet_frame, qr_decode,
dispatch_classify, file_decode) and runs each for 15s. Own registry
and target volumes (onionwire-cargo-registry-fuzz /
onionwire-target-ci-fuzz), TMPDIR=/target/tmp, own concurrency group
(onionwire-ci-pi-fuzz) so the ~12min cold build does not serialize the
test/sdk jobs. Path allowlist extended with fuzz/** and
scripts/run-fuzz.sh so fuzz-only PRs actually trigger it.

Job is a no-op until PR #103 lands on main; the fuzz/ crate is a
detached workspace that root cargo test/clippy never sees.
2026-09-17 20:57:50 -04:00
4a06d794f1 Merge pull request 'ratchet: freeze the v1 state/frame wire format with guard tests' (#98) from wt/t_0ffa68d2 into main
All checks were successful
ci / test (push) Successful in 4m50s
ci / sdk (push) Successful in 55s
Reviewed-on: #98
2026-09-18 00:50:37 +00:00
ba3c39cfe1 Merge branch 'main' into wt/t_0ffa68d2
All checks were successful
ci / test (pull_request) Successful in 4m59s
ci / sdk (pull_request) Successful in 1m7s
2026-09-18 00:50:24 +00:00
fa53237968 Merge pull request 'tests: assert the DH ratchet step in lockstep on a bidirectional burst' (#97) from wt/t_d686a78c into main
Some checks failed
ci / test (push) Has been cancelled
ci / sdk (push) Has been cancelled
Reviewed-on: #97
2026-09-18 00:49:29 +00:00
rust-dev
6827b87a29
tui: F8 rotate prekey + Node::rotate_prekey (hard cut, drops ratchet state)
All checks were successful
ci / test (pull_request) Successful in 5m0s
ci / sdk (pull_request) Successful in 1m11s
android-ci / android (pull_request) Successful in 8m36s
The signed prekey was set at invite creation and never rotated: a long-lived
static is a long-lived forward-secrecy window. F8 now rotates it.

- Node::rotate_prekey(): new X25519 keypair, written through the existing
  replace_identity_keys prekey columns (no store change needed), live Keys
  updated, new pubkey returned for the invite re-encode. Identity untouched.
- It drops every stored ratchet session: the bootstrap epoch is derived from
  the prekey DH, so each friend has to F3-paste the new invite. Nothing is
  pushed to peers \u2014 there is no in-band prekey update.
- TUI: F8 on Main opens the confirm screen (type ROTATE, same prompt as F4),
  then re-opens the F2 share path with the new invite; help overlay + footer
  hint list it.
- Docs: THREAT_MODEL gains a section on the F8 hard cut and the prekey-bound
  epoch bullet; README key table and PROTOCOL 'Roles and keys' follow.

Tests: node-level rotation test (identity/pk/stored row/ratchet drop/invite),
tests/rotate.rs screen text + prompt, tui_chrome help needs F8.
2026-09-17 20:48:10 -04:00
Hermes rust-dev
69672809ab
tls: default to Arti's rustls backend (drop OpenSSL from TLS)
All checks were successful
ci / test (pull_request) Successful in 6m47s
android-ci / android (pull_request) Successful in 8m21s
ci / sdk (pull_request) Successful in 1m25s
Arti's TLS backends are non-additive; the root crate defaulted to
`native-tls` (OpenSSL). Switch `default = ["rustls"]` and pin the `rustls`
crate with its `ring` feature — `tor-rtcompat` pulls rustls in with
`default-features = false`, so without that pin the backend compiles with no
`CryptoProvider` and the first TLS config fails (same reason already recorded
in crates/onionwire-sdk/Cargo.toml).

`native-tls` stays as an opt-in feature. SQLCipher still builds vendored
OpenSSL (`bundled-sqlcipher-vendored-openssl`); that is unrelated to TLS.

- tests/tls_backend.rs: compile-time pin that the default features select
  rustls, plus a runtime check that rustls resolves a provider with no manual
  install.
- ci.yml: the root `test` job no longer installs pkg-config/libssl-dev (the
  SDK job keeps it).
- docs: README build deps, ARTI_UPGRADE backend table, release-body and the
  SDK README now describe the rustls default; the false "binaries link
  libssl.so.3 dynamically" claim is corrected.
- crates/onionwire-sdk/Cargo.lock: regenerated for the root crate's new
  dependency (separate workspace, --locked would otherwise fail).
2026-09-17 20:48:05 -04:00
agent
dff37fe00e
docs+tui: reachability stance (no sealed mailbox) and peer-unreachable queued footer
Some checks failed
ci / test (pull_request) Has been cancelled
ci / sdk (pull_request) Has been cancelled
android-ci / android (pull_request) Has been cancelled
Add a Reachability section to docs/THREAT_MODEL.md: no sealed mailbox or
server-side message store, the chat outbox is local-device retry only, and
there is no mutual-online indicator — a send is a one-shot Noise IK session
and an unanswered dial queues locally with the retry clock shown.

OutboxSummary now carries the outstanding row's attempt count and soonest
retry, so the footer reads 'peer unreachable, queued (n/8, retry 45s)'
instead of a bare 'n queued'. Tests updated to the real outbox wording; the
Android KDoc note stops claiming the footer copy is mirrored (Android shows
per-row 'queued (try n/8, retry …)' via OutboxDetail).
2026-09-17 20:44:28 -04:00
agent
1aec007601
ratchet: freeze the v1 state/frame wire format with guard tests
All checks were successful
ci / test (pull_request) Successful in 4m47s
ci / sdk (pull_request) Successful in 57s
The persisted ratchet state had a version byte and typed errors but no
test that a format change would actually be caught. Add two dedicated
guards to tests/ratchet.rs that assert the frozen shape as literals
(0x01, 210-byte prefix) rather than via STATE_VERSION, so a bump breaks
them visibly, and pin that any foreign version byte is rejected with
Error::UnsupportedStateVersion before any field is read.

Document the frozen v1 state layout, the rat frame layout, and the
migration path a v2 must follow in references/ratchet-wire-frozen.md.

Verified by flipping STATE_VERSION to 2: both guards fail
("the frozen version byte changed"), then revert.
2026-09-17 20:43:31 -04:00
agent
6f267a6aba
tests: assert the DH ratchet step in lockstep on a bidirectional burst
All checks were successful
ci / test (pull_request) Successful in 4m51s
ci / sdk (pull_request) Successful in 58s
`round_trip_across_two_dh_ratchet_steps` only asserts that neither sending
ratchet key stayed put; it would still pass if the two sides stepped onto
unconnected epochs, and it never checks that either peer adopted the key the
other advertised. The new test reads dh_pub out of the wire header and pins the
adoption per step across an A->B / B->A burst:

- round 1 rotates only the lower-key (establishing) peer, so one round cannot
  lockstep both sides -- the intermediate state is asserted, not assumed;
- rounds 2 and 3 step each side in turn, asserting each receiver adopts exactly
  the key the frame advertised;
- the three-frame burst each way asserts chain reads (not extra steps), zero
  skipped keys, and that the peer that received last is keyed to the other's
  current key.

tests/ratchet.rs only; no src change, no new dependency.
2026-09-17 20:41:48 -04:00
21 changed files with 923 additions and 60 deletions

View file

@ -17,6 +17,8 @@ on:
- "Cargo.toml"
- "Cargo.lock"
- ".forgejo/workflows/ci.yml"
- "fuzz/**"
- "scripts/run-fuzz.sh"
pull_request:
paths:
- "src/**"
@ -25,6 +27,8 @@ on:
- "Cargo.toml"
- "Cargo.lock"
- ".forgejo/workflows/ci.yml"
- "fuzz/**"
- "scripts/run-fuzz.sh"
workflow_dispatch:
# One cargo job on the Pi at a time. Overlapping PR+main runs shared the
@ -39,11 +43,19 @@ env:
CARGO_REGISTRY_VOLUME: onionwire-cargo-registry
CARGO_TARGET_VOLUME: onionwire-target-ci
BUILD_CONTAINER: onionwire-ci-${{ github.run_id }}
# The SDK job gets its own target volume: it resolves the root crate with
# `rustls` instead of `native-tls`, so sharing a target dir would thrash both
# jobs' feature-unified artifacts.
# The SDK job gets its own target volume: `crates/onionwire-sdk` is a
# separate cargo workspace with its own lockfile and its own crate set, so
# sharing a target dir with the root job would thrash both.
SDK_CARGO_TARGET_VOLUME: onionwire-target-ci-sdk
SDK_BUILD_CONTAINER: onionwire-ci-sdk-${{ github.run_id }}
# The fuzz job builds on nightly with a release profile + debug=line-tables-only;
# it must not thrash the test/sdk target volumes and needs its own registry cache.
FUZZ_REGISTRY_VOLUME: onionwire-cargo-registry-fuzz
FUZZ_TARGET_VOLUME: onionwire-target-ci-fuzz
FUZZ_BUILD_CONTAINER: onionwire-ci-fuzz-${{ github.run_id }}
# libFuzzer writes its -fork dir into TMPDIR; point it at the target volume so
# a host tmpfs quota can't OOM-kill the builder.
FUZZ_TMP_DIR: /target/tmp
jobs:
test:
@ -65,13 +77,12 @@ jobs:
-e CARGO_TARGET_DIR=/target \
-e CARGO_BUILD_JOBS=2 \
-e CARGO_TERM_COLOR=never \
-e TMPDIR=/target/tmp \
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
-v "$CARGO_TARGET_VOLUME":/target \
-w /src \
"$RUST_IMAGE" \
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
&& apt-get update \
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
&& rustup component add clippy \
&& cargo test --locked \
&& cargo clippy --locked --all-targets -- -D warnings'
@ -80,12 +91,19 @@ jobs:
docker rm -f "$BUILD_CONTAINER" > /dev/null
# `crates/onionwire-sdk` is a SEPARATE cargo workspace: its own Cargo.lock and
# a path dependency on the root crate, resolved with `rustls` instead of
# `native-tls`. The `test` job above therefore never compiles it, so a
# root-crate signature change (`Node::send` gaining the outbox result, the
# SQLCipher passphrase entry points) breaks the Android SDK — and the tagged
# release AAR, since android-release.yml only builds on `v*.*.*` — while both
# the root suites and local `cargo test` stay green. Build it here.
# a path dependency on the root crate. The `test` job above therefore never
# compiles it, so a root-crate signature change (`Node::send` gaining the
# outbox result, the SQLCipher passphrase entry points) breaks the Android SDK
# — and the tagged release AAR, since android-release.yml only builds on
# `v*.*.*` — while both the root suites and local `cargo test` stay green.
# Build it here.
#
# The root `test` job no longer installs `pkg-config`/`libssl-dev` — the root
# crate defaults to Arti's rustls backend, so TLS needs no system OpenSSL.
# The `rusqlite` `bundled-sqlcipher-vendored-openssl` feature that both jobs
# use compiles OpenSSL from source, which needs `perl` and `make` (present in
# the `rust:*-bookworm` image), not the `-dev` headers. This job keeps the
# install: the Android SDK build is unchanged by the root crate's TLS default.
sdk:
runs-on: docker
timeout-minutes: 120
@ -105,6 +123,7 @@ jobs:
-e CARGO_TARGET_DIR=/target \
-e CARGO_BUILD_JOBS=2 \
-e CARGO_TERM_COLOR=never \
-e TMPDIR=/target/tmp \
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
-v "$SDK_CARGO_TARGET_VOLUME":/target \
-w /src \
@ -119,3 +138,82 @@ jobs:
--exclude=./crates/onionwire-sdk/target . \
| docker start -a -i "$SDK_BUILD_CONTAINER"
docker rm -f "$SDK_BUILD_CONTAINER" > /dev/null
# Nightly cargo-fuzz harness. The `fuzz/` crate (PR #103) is a detached
# workspace with four libFuzzer targets over the untrusted-input parsers —
# RatchetState::from_bytes/decrypt, qr::decode, dispatch::classify, file::decode.
# Nothing in CI ever compiles this crate, so the targets bit-rot silently: this
# job catches it. It only does something useful after PR #103 merges to main.
fuzz:
runs-on: docker
timeout-minutes: 120
# The cold fuzz build (~12 min locally for the full Arti + SQLCipher +
# vendored-OpenSSL graph) can SERIALIZE other PRs with the same concurrency
# group. Give it its own group so a long fuzz build does not block the test/sdk
# jobs and the PRs that trigger them.
concurrency:
group: onionwire-ci-pi-fuzz
cancel-in-progress: false
steps:
- name: Checkout
uses: https://code.forgejo.org/actions/checkout@v4
- name: nightly toolchain + cargo-fuzz
run: |
set -euo pipefail
cd "${GITHUB_WORKSPACE}"
echo "workspace: $GITHUB_WORKSPACE"
docker volume create "$FUZZ_REGISTRY_VOLUME" > /dev/null
docker volume create "$FUZZ_TARGET_VOLUME" > /dev/null
docker rm -f "$FUZZ_BUILD_CONTAINER" > /dev/null 2>&1 || true
docker create --name "$FUZZ_BUILD_CONTAINER" -i \
-e CARGO_TARGET_DIR=/target \
-e CARGO_BUILD_JOBS=2 \
-e CARGO_TERM_COLOR=never \
-e TMPDIR=/target/tmp \
-e RUSTUP_HOME=/usr/local/rustup \
-e CARGO_HOME=/usr/local/cargo \
-v "$FUZZ_REGISTRY_VOLUME":/usr/local/cargo/registry \
-v "$FUZZ_TARGET_VOLUME":/target \
-w /src \
"$RUST_IMAGE" \
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
&& apt-get update \
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
&& rustup toolchain install nightly --profile minimal \
&& rustup default nightly \
&& cargo install cargo-fuzz --locked \
&& export PATH="/usr/local/cargo/bin:$PATH" \
&& cd /src/fuzz \
&& cargo +nightly fuzz build \
&& cargo +nightly fuzz list'
tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees . \
| docker start -a -i "$FUZZ_BUILD_CONTAINER"
- name: run each fuzz target for 15s
run: |
set -euo pipefail
cd "${GITHUB_WORKSPACE}"
docker volume create "$FUZZ_REGISTRY_VOLUME" > /dev/null
docker volume create "$FUZZ_TARGET_VOLUME" > /dev/null
docker rm -f "$FUZZ_BUILD_CONTAINER" > /dev/null 2>&1 || true
docker create --name "$FUZZ_BUILD_CONTAINER" -i \
-e CARGO_TARGET_DIR=/target \
-e CARGO_BUILD_JOBS=2 \
-e CARGO_TERM_COLOR=never \
-e TMPDIR=/target/tmp \
-e RUSTUP_HOME=/usr/local/rustup \
-e CARGO_HOME=/usr/local/cargo \
-e FUZZ_SECS=15 \
-e FUZZ_JOBS=2 \
-v "$FUZZ_REGISTRY_VOLUME":/usr/local/cargo/registry \
-v "$FUZZ_TARGET_VOLUME":/target \
-w /src \
"$RUST_IMAGE" \
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
&& export PATH="/usr/local/cargo/bin:$PATH" \
&& cd /src/fuzz \
&& bash /src/scripts/run-fuzz.sh'
tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees . \
| docker start -a -i "$FUZZ_BUILD_CONTAINER"
docker rm -f "$FUZZ_BUILD_CONTAINER" > /dev/null

2
Cargo.lock generated
View file

@ -2645,6 +2645,7 @@ dependencies = [
"ratatui",
"rpassword",
"rusqlite",
"rustls",
"safelog",
"serde_json",
"sha2",
@ -3500,6 +3501,7 @@ checksum = "6725596c3f2c3a0aef021139e145d4eafe314a6623e4680ca83852b2c67ab2ba"
dependencies = [
"log",
"once_cell",
"ring",
"rustls-pki-types",
"rustls-webpki",
"subtle",

View file

@ -8,16 +8,16 @@ license = "MIT"
publish = false
repository = "https://github.com/sirius0xdev/onionwire"
# The Linux TUI build is unchanged: `default` keeps Arti's native-tls
# (OpenSSL) backend exactly as before, and ratatui remains a normal
# dependency so `src/tui.rs` is untouched.
# TLS backend: `rustls` by default, `native-tls` (OpenSSL) opt-in.
#
# Android has no OpenSSL in the NDK, so the SDK crate depends on this crate
# with `default-features = false, features = ["rustls"]`. Arti marks these two
# backends non-additive, so exactly one may be selected per build graph — hence
# exposing them as crate features.
# Arti marks these two backends non-additive, so exactly one may be selected per
# build graph — hence exposing them as crate features. rustls is the default
# because Android has no OpenSSL in the NDK and the Linux TUI/release build does
# not need a system OpenSSL for TLS either. (OpenSSL is still *compiled* into
# every build by rusqlite's `bundled-sqlcipher-vendored-openssl`, vendored and
# static: that is the SQLCipher layer, not Arti's TLS.)
[features]
default = ["native-tls"]
default = ["rustls"]
native-tls = ["arti-client/native-tls"]
rustls = ["arti-client/rustls"]
@ -37,6 +37,12 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-util", "ti
tor-cell = "0.46"
tor-hsservice = "0.46"
tor-rtcompat = { version = "0.46", features = ["tokio"] }
# Direct dependency only to select rustls's crypto provider: Arti pulls rustls in
# through `tor-rtcompat` with `default-features = false`, and rustls 0.23
# resolves its provider from its OWN `ring`/`aws-lc-rs` features, so without this
# line the rustls backend compiles with no provider at all and the first TLS
# config fails. Same reasoning (and pin) as `crates/onionwire-sdk/Cargo.toml`.
rustls = { version = "0.23", default-features = false, features = ["ring"] }
ratatui = { version = "0.30.2", default-features = false, features = ["crossterm"] }
x25519-dalek = { version = "2", features = ["static_secrets"] }
snow = "0.10"

View file

@ -88,8 +88,10 @@ cargo install --path . --locked --force
# lands in ~/.cargo/bin/onionwire
```
Build needs `pkg-config` and OpenSSL 3 headers (`libssl-dev` / `openssl-devel`) —
the released binaries link `libssl.so.3` dynamically.
Build needs a C toolchain plus `perl` and `make`: SQLCipher is compiled from
vendored OpenSSL sources (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`).
No system OpenSSL headers or `pkg-config` are required — Arti's TLS backend is
`rustls`, and the binaries carry no dynamic `libssl` dependency.
### Two instances on one machine
@ -134,6 +136,7 @@ Focus starts on the composer so typing works immediately. `Tab` cycles panes; `j
| `F4` | Rotate **onion** (locator only) |
| `F5` | Selected friend's profile (`/who`) |
| `F6` | Wallet screen (receive QR, balance, transfers) |
| `F8` | Rotate **prekey** (hard cut: every friend re-pastes the invite) |
| Enter | Send chat to the selected friend, or run a `/command` |
| `Esc` | Close overlay / back to Main / clear composer |
| `Ctrl-Q` | Quit: type `CLEAR`+Enter to wipe history, `QUIT`+Enter to leave it, Esc to stay |
@ -403,7 +406,7 @@ FORGEJO_TOKEN=<pat> scripts/build-release-local.sh v0.2.1
Workflows (Forgejo Actions, `.forgejo/workflows/`):
- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — two jobs on the Pi runner (`docker` label), serialized by `onionwire-ci-pi`. `test`: `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` at the repo root. `sdk`: the same for `crates/onionwire-sdk` (separate cargo workspace — own `Cargo.lock`, root crate by path, `rustls` instead of `native-tls` — 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/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).

View file

@ -130,8 +130,13 @@ fun parseDelivery(direction: String, delivery: String?): Delivery? {
/**
* Chat-level delivery summary derived from the rendered rows.
*
* Mirrors `src/tui.rs::OutboxSummary`: `Queued` + `Sending` are "still coming",
* `Failed` is terminal and keeps a fail-closed statement on screen.
* The *counting* rule mirrors `src/tui.rs::OutboxSummary`: `Queued` + `Sending`
* are "still coming", `Failed` is terminal and keeps a fail-closed statement on
* screen. The TUI's footer wording for an outstanding row also carries the
* reachability statement and retry clock (`peer unreachable, queued (n/8, retry
* 45s)`); on Android that per-row detail already lives in the row's own
* `queued (try n/8, retry …)` marker (`OutboxDetail.kt`), so the summary stays
* the short count form instead of repeating it.
*/
data class OutboxSummary(
val queued: Int = 0,

View file

@ -2776,6 +2776,7 @@ dependencies = [
"ratatui",
"rpassword",
"rusqlite",
"rustls",
"safelog",
"serde_json",
"sha2",

View file

@ -7,11 +7,8 @@ description = "OnionWire Android/Kotlin SDK: in-process Arti onion transport, No
license = "MIT"
publish = false
# Standalone workspace on purpose.
# Arti's TLS backends (`native-tls` vs `rustls`) are non-additive: exactly one
# may be enabled per feature resolution. The Linux TUI crate keeps native-tls,
# Android has no OpenSSL in the NDK and needs rustls. Two separate workspaces
# keep the two resolutions from colliding — this crate path-depends on the
# Standalone workspace on purpose: the SDK carries its own lockfile and its own
# crate set (Android: `static-sqlite`, rustls TLS), so it path-depends on the
# root package without joining its feature graph.
[workspace]
resolver = "2"

View file

@ -126,7 +126,7 @@ output.
## Why this crate has its own Cargo workspace
Arti's TLS backends are **non-additive**: exactly one of `native-tls` and
`rustls` may be enabled in a given feature resolution. The Linux TUI keeps
`native-tls` (OpenSSL, as it always has). Android has no OpenSSL in the NDK, so
this crate selects `rustls` plus `static-sqlite` (no system `libsqlite3` on
Android). Two separate workspaces keep the two resolutions from colliding.
`rustls` may be enabled in a given feature resolution. The root crate defaults
to `rustls` (Linux TUI and releases), so this crate does not differ from the
root on TLS; it does add `static-sqlite`, because Android has no system
`libsqlite3`. Two separate workspaces keep the two resolutions from colliding.

View file

@ -23,9 +23,11 @@ part of a Tor upgrade.
Two crate features re-expose Arti's TLS backends, which Arti marks
**non-additive** — exactly one may be selected per build graph:
* `native-tls` (default) → Linux TUI build, via OpenSSL.
* `rustls` → the Android SDK crate (`crates/onionwire-sdk`), because the NDK has
no OpenSSL.
* `rustls` (**default**) → every build: the Linux TUI, the released binaries and
the Android SDK. No system OpenSSL is needed for TLS; the root `Cargo.toml`
pins rustls's `ring` feature so the crypto provider resolves from crate
features (without it the rustls backend compiles with no provider).
* `native-tls` → opt-in only, via OpenSSL.
Published Arti releases move all four crates together in lockstep. Bump them as
**one set**. A mixed set (e.g. `arti-client` 0.47 with `tor-hsservice` 0.46) is
@ -118,8 +120,9 @@ issue the watcher files.
7. Confirm the fail-closed path by hand if the publish wait changed at all:
with the write timeout still 360s, a peer whose onion is down must fail the
send. There is no outbox in v1 — the message must not be silently queued.
8. Rebuild the Android target — Arti's TLS backends are non-additive, and this
is the build that exercises the `rustls` feature:
8. Rebuild the Android target. The root crate defaults to `rustls` now, so this
is less about exercising a non-default feature than about proving the default
still cross-compiles where OpenSSL does not exist:
```
scripts/build-android-local.sh
```

View file

@ -32,7 +32,8 @@ Each install holds:
- **Identity** — ed25519 keypair. The 32-byte public key **is** the person.
Roster primary key. Displayed as 64 lowercase hex chars (the fingerprint).
- **Prekey** — x25519 keypair. This is the Noise IK *static*. It is long-lived
in v1. Rotating the onion (`F4`) does **not** rotate it.
in v1 — rotate it with `F8`, which hard-cuts every stored session. Rotating
the onion (`F4`) does **not** rotate it.
- **Onion** — Tor v3 address. Locator only. Disposable.
A friend is `{identity_pk, current_onion, current_prekey_pk}`. Pasting the same

View file

@ -16,6 +16,10 @@ A signed `loc` frame (`onion`, `ts`, `sig`) rewrites a friend’s locator **only
`F4` changes the locator only. The identity key is unchanged. Anyone who already has your pubkey can still prove they are talking to you, and a later invite paste with the same `k` updates their row. To become a new person, `/wipe-all` (new identity key). There is no in-band unfriend/revoke in v1.
## Rotating the prekey is a hard cut, and it is wider than F4
`F8` rotates the long-lived signed prekey. The identity key and the onion are unchanged, but the prekey is our Noise static **and** the seed of the bootstrap ratchet epoch, so once it moves nothing is reachable any more: a friend's dial uses the prekey they pinned from your invite, and their stored epoch is derived from the old one. There is no push path for a prekey — it only travels inside a signed invite — so every friend, online or offline, has to F3-paste the new invite before chat works in either direction again. F8 therefore also drops the local ratchet state for every friend, exactly as a peer's own prekey change does. Rotating the prekey shrinks the forward-secrecy window of the long-lived static; it is not a revocation (the old invite holder still learns nothing new, but they also cannot talk to you).
## Your store is encrypted
The sqlite store is SQLCipher (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`).
@ -66,6 +70,16 @@ A chat send to an unreachable onion is written to an `outbox` row next to its `m
The queue is bounded in scope: chat only. File transfer and `rcp` frames are one-shot, so a failed payment claim does not sit in the store being retried forever.
## Reachability: there is no sealed mailbox, and no mutual-online indicator
**No sealed mailbox.** OnionWire does not implement a server-side message store, a sealed mailbox, or any store-and-forward drop. There is no address a peer can write a message to when you are offline, and nothing that holds a message on your behalf after your device is gone. A mailbox of that kind needs a persistent process that accepts and later replays ciphertext for an absent recipient — exactly the hosted store-and-forward server this threat model rules out (“Tor relays are not a chat server”, “Out of v1”). A sealed box whose key never leaves the user's device is still a server holding the traffic pattern and the ciphertext, and it is still a third party that can be compelled, logged, or silently serve a stale box. That is the design decision, and it is not planned as a follow-up.
**The chat outbox is local-device retry only.** A message to an unreachable peer is written to the local `outbox` row and re-dialed from this device. It dies with the device: no relay, no friend, no other install ever holds it. Nothing in the outbox is a delivery guarantee.
**No mutual-online indicator.** OnionWire has no presence, no "peer is online" dot, and no shared online state. Every send is a one-shot Noise IK session to the peer's onion and is closed after one application frame; the peer's availability is only learned from whether *this* dial succeeded. A roster row we have not reached is marked `stale` (from the last connect attempt, `last_connect_ok`) and the footer states the consequence instead of implying presence: `peer unreachable, queued (n/8, retry …)` while an outbox row is outstanding. "They are offline right now" and "they have never been online since my last attempt" are indistinguishable to OnionWire, and the UI does not pretend otherwise.
**What this costs, stated plainly.** Two devices that are never online at the same time cannot talk, and there is no queue that changes that — the sender's own device is the only queue. Anyone who needs offline delivery must run their own always-on OnionWire install (their own identity, their own onion) to hold the messages, which is a hosted server *they* own and operate, not a service OnionWire provides.
## Chat is ratcheted on top of the one-shot Noise session
The Noise IK session is still the transport: handshake, **one** application
@ -118,7 +132,9 @@ device.
- *No one-time prekeys.* The bootstrap epoch uses the long-lived signed prekey
only, so there is no per-session prekey consumption. A peer prekey change
drops the state locally and the next chat frame re-bootstraps; there is no
in-band reset and no key confirmation.
in-band reset and no key confirmation. The same is true of your **own**
prekey: `F8` rotates it, drops every stored state, and each friend has to
re-paste your invite, because a new prekey is never pushed.
- *A compromised endpoint is out of scope.* The ratchet state lives in the same
SQLCipher file as the chat log, under the same passphrase. Anyone who opens
the store holds the roots, both chain keys, the skipped keys and the plaintext
@ -234,7 +250,8 @@ the peer already knows the plaintext they sent.
## Out of v1
Prosody, XMPP, s2s, MAM, carbons, a **server-side** outbox / store-and-forward
relay, multi-device, DHT / name server, A/V. The local retry queue of the
previous section is not an outbox in the XMPP sense: it never leaves the device.
Prosody, XMPP, s2s, MAM, carbons, a **sealed mailbox**, a **server-side**
outbox / store-and-forward relay, multi-device, DHT / name server, A/V. The
local retry queue of the previous section is not an outbox in the XMPP sense: it
never leaves the device, and it is not a mailbox either — see “Reachability”.

View file

@ -0,0 +1,101 @@
# Ratchet wire format — frozen at v1
Status: **frozen**. A change to the persisted ratchet state layout, or to the
`rat ` frame layout, is a wire-format break and needs a migration path (see
"Changing the format" below). The guard tests that enforce this live in
`tests/ratchet.rs`:
- `ratchet_state_blob_is_frozen_at_version_v1`
- `ratchet_state_foreign_version_is_rejected_not_misread`
Both are written to fail visibly on a version bump or a field insertion:
they assert the literal byte `0x01` and the literal 210-byte prefix length,
not the `STATE_VERSION` constant, so a bump cannot quietly follow them.
## Persisted state (`ratchet_sessions.state`)
Written by `RatchetState::to_bytes`, read by `RatchetState::from_bytes`
(`src/ratchet.rs`). The store treats the blob as opaque
(`Store::load_ratchet` / `Store::save_ratchet`, `src/store.rs`; the row is
`ratchet_sessions(state BLOB NOT NULL)` keyed by `friend_id`). There is no
public `decode_state` function in the crate: the persisted blob is decoded by
`RatchetState::from_bytes`, reached from `ratchet_for` in `src/node.rs`, and
the resulting version error is reported as `Error::UnsupportedStateVersion`.
Layout — version `0x01`:
```
0 version byte 0x01 (STATE_VERSION)
1..33 root_key
33..65 local ratchet secret
65..97 local ratchet public
97..129 remote ratchet public
129..161 sending chain key
161..165 send_n u32 BE
165..197 receiving chain key
197..201 recv_n u32 BE
201..205 prev_send_len u32 BE
205 established (0 or 1)
206..210 skipped-key count u32 BE
210.. per skipped key, in insertion order: dh_pub[32] || n u32 BE || key[32]
```
The fixed prefix is **210 bytes** (pinned as `STATE_PREFIX_LEN` in the test);
the skipped-key tail is `68` bytes per key, capped at `MAX_SKIPPED_KEYS`
(2000). The blob contains secret key material — the caller owns wiping it.
`from_bytes` is fail-closed on every malformed input it can see: a foreign
version byte returns `Error::UnsupportedStateVersion(byte)` *before* any field
is read, so a blob from another version is never decoded under the v1 layout;
empty, truncated, trailing-byte, bad-`established`-flag, bad skipped-count and
secret-does-not-match-its-public-key inputs return `Error::BadState(&str)`.
None of them panic or partially apply.
## Frames (`rat ` chat frames)
Written by `RatchetState::encrypt`, parsed by `Frame::parse`
(`src/ratchet.rs`). Framing constants: `FRAME_PREFIX = b"rat "`,
`FRAME_VERSION = 0x01`, `HEADER_LEN = 40`, `HEADER_OFFSET = 5`.
```
0..4 b"rat "
4 version byte 0x01 (FRAME_VERSION)
5..45 header: dh_pub[32] || N u32 BE || PN u32 BE
45..57 nonce[12]
57.. ciphertext || Poly1305 tag[16] (ChaCha20-Poly1305)
```
The 40-byte header is also the AEAD associated data, so any header edit fails
authentication rather than being silently ignored. `Frame::parse` checks the
prefix, then the minimum length (`HEADER_OFFSET + HEADER_LEN + 12 + 16 = 73`),
then the version byte; a sub-73-byte frame is a length error whatever its
version byte says, and a frame of 73 bytes or more with a foreign version is a
version error. Rejected frames leave the state byte-identical.
## Changing the format
There is **no migration code today**, and a version bump must not silently
re-bootstrap a session: replacing an unreadable stored session with a fresh
bootstrap produces traffic the peer cannot decrypt and loses the established
epoch. The required shape for a v2 is:
1. Bump `STATE_VERSION` and make `from_bytes` keep the v1 decoder reachable
(match on the version byte, decode old blobs with the old layout, then
re-serialize as v2).
2. Do **not** let an older build read a newer blob: it must keep rejecting
anything that is not its own version with `UnsupportedStateVersion`, never
decode it under the old layout. That is what the current code does, and it
is why only the *newer* build may convert a blob in place.
3. Surface the refusal to the user. Today the message only reaches a log:
an outbound `Node::send` fails closed with `Err(String)`
(`ratchet state: unsupported ratchet state version N`, from
`ratchet_for`), and an inbound frame is dropped with
`eprintln!("rat dropped ({e})")` in `Node::handle_incoming`'s
`Kind::Ratchet` arm. There is no dialog and no automatic recovery; a v2
must add the user-visible message rather than rely on stderr.
4. Keep the freeze tests green only by updating the pinned literals in
`tests/ratchet.rs` *and* the layout docs in this file in the same change.
An additive change with no version bump is not an option: the skipped-key tail
is read by count, so appending a field changes what the tail means for every
stored blob.

View file

@ -18,7 +18,8 @@ chmod +x onionwire-x86_64-unknown-linux-gnu
./onionwire-<target> --version
```
Keep the asset filenames so `sha256sum -c` matches. Both binaries link OpenSSL 3
dynamically (`libssl.so.3`), which is standard on Debian 12+/Ubuntu 24.04+.
Keep the asset filenames so `sha256sum -c` matches. The TLS stack is rustls and
OpenSSL (for SQLCipher) is compiled in from vendored sources, so the binaries
have no dynamic `libssl` dependency.
Building from source is covered in the README install guide.

View file

@ -8,6 +8,7 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use futures::StreamExt;
use futures::io::{AsyncRead, AsyncWrite};
use hkdf::Hkdf;
use rand::rngs::OsRng;
use sha2::Sha256;
use tor_cell::relaycell::msg::Connected;
use tor_hsservice::{RunningOnionService, handle_rend_requests};
@ -623,7 +624,7 @@ impl Node {
}
/// Pay selected friend via wallet RPC, then signed receipt.
pub async fn tip(&self, friend_pk: &[u8], atomic: &str, _memo: &str) -> Result<(), String> {
pub async fn tip(&self, friend_pk: &[u8], atomic: &str, memo: &str) -> Result<(), String> {
if !self.wallet.configured() {
return Err("wallet not connected — set ONIONWIRE_WALLET_RPC".into());
}
@ -645,20 +646,23 @@ impl Node {
.map_err(|e| e.to_string())?;
let rcp = self.sign_receipt(&txid, atomic, &address)?;
let rcp_pt = pay::encode_receipt(&rcp);
let tip = self.sign_tip(&txid, atomic, &address, _memo)?;
let tip = self.sign_tip(&txid, atomic, &address, memo)?;
let tip_pt = pay::encode_tip(&tip);
self.send_once(friend_pk, &rcp_pt).await?;
self.send_once(friend_pk, &tip_pt).await?;
let store = self.store.lock().map_err(|e| e.to_string())?;
// The user just *spent* this money: the row is a tip, matching the
// inbound `ingest_tip` direction. The receipt frame above is the
// recipient's copy of the payment, not the local one.
store
.insert_payment(
friend_pk,
PaymentWrite {
dir: "out",
kind: "receipt",
kind: "tip",
amount_atomic: atomic,
address: &address,
memo: "",
memo,
txid: Some(&txid),
verified: true,
},
@ -678,7 +682,7 @@ impl Node {
.append_message(
friend_pk,
"out",
pay::tip_chat_line(atomic, _memo, false).as_bytes(),
pay::tip_chat_line(atomic, memo, false).as_bytes(),
)
.map_err(|e| e.to_string())?;
Ok(())
@ -877,6 +881,34 @@ impl Node {
})
}
/// Rotate the long-lived signed prekey (F8). Hard cut, like the locator
/// rotate: the prekey is our Noise static and the bootstrap ratchet epoch is
/// derived from the prekey DH, so every stored session is dead the moment
/// this returns and every friend has to F3-paste the new invite. Nothing is
/// pushed to peers — a new prekey only travels inside a signed invite. The
/// identity key (and therefore the fingerprint) does not move; the caller
/// re-encodes the F2 invite around the returned pubkey.
pub fn rotate_prekey(&self) -> Result<[u8; 32], String> {
let mut k = self.keys()?;
let sk = StaticSecret::random_from_rng(OsRng);
let pk = X25519Public::from(&sk).to_bytes();
{
let store = self.store.lock().map_err(|e| e.to_string())?;
// `replace_identity_keys` rewrites the prekey columns too; the
// identity values passed back are the ones already stored.
store
.replace_identity_keys(&k.identity_sk, &k.identity_pk, &sk.to_bytes(), &pk)
.map_err(|e| e.to_string())?;
for f in store.list_friends().map_err(|e| e.to_string())? {
store.clear_ratchet(&f.pubkey).map_err(|e| e.to_string())?;
}
}
k.prekey_sk = sk.to_bytes();
k.prekey_pk = pk;
*self.keys.lock().map_err(|e| e.to_string())? = k;
Ok(pk)
}
/// One-shot file to a friend. Fail closed; no outbox, no resume.
/// Chunks are paced (`file::CHUNK_PACE`) with bounded per-chunk retry so
/// a 1 MiB transfer fits the receiver's rendezvous token bucket.
@ -1823,5 +1855,134 @@ mod tests {
"the sender's chat must show the tip they just paid"
);
}
/// F8: rotate the long-lived signed prekey. The identity must not move, the
/// stored/dialed prekey must, every prekey-bound ratchet epoch must be
/// dropped, and the F2 invite must be re-encodable around the new prekey.
#[tokio::test]
async fn rotating_the_prekey_keeps_identity_and_drops_stale_ratchet_state() {
let dir = tempfile::tempdir().unwrap();
let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial));
let peer = Keys::generate();
let old_identity = node.identity_pk();
let old_prekey = node_prekey(&node);
*node.onion.lock().unwrap() = format!("{}.onion", "a".repeat(56));
{
let store = node.store.lock().unwrap();
befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion");
store
.save_ratchet(&peer.identity_pk, b"epoch-bound-to-the-old-prekey")
.expect("seed ratchet state");
}
let new_prekey = node.rotate_prekey().expect("rotate prekey");
assert_ne!(new_prekey, old_prekey, "the prekey must actually change");
assert_eq!(node_prekey(&node), new_prekey, "the live keys follow");
assert_eq!(
node.identity_pk(),
old_identity,
"identity = pubkey, it stays"
);
{
let store = node.store.lock().unwrap();
assert_eq!(
store.self_identity().unwrap().prekey_pk,
new_prekey.to_vec(),
"the self row carries the new prekey"
);
assert!(
store.load_ratchet(&peer.identity_pk).unwrap().is_none(),
"the bootstrap epoch is prekey-bound, so the stored state is stale"
);
}
let payload = qr::decode(&node.qr_payload().expect("re-encode the invite"))
.expect("the re-encoded invite decodes");
assert_eq!(payload.signed_prekey, new_prekey.to_vec());
assert_eq!(
payload.pubkey,
old_identity.to_vec(),
"the new invite still names the same identity"
);
}
/// An outbound tip must be recorded as a *tip*. The receipt row is the
/// recipient's view of a receipt frame; for money the user just spent the
/// wallet history wants the tip they paid. `ingest_tip` already stores
/// `kind = "tip"` for the inbound direction.
#[tokio::test]
async fn outbound_tip_records_a_tip_payment_row() {
let dir = tempfile::tempdir().unwrap();
let node = offline_node_with_wallet(
&dir.path().join("bob"),
Arc::new(DialOk),
mock_wallet().await,
);
let peer = Keys::generate();
let addr = xmr_addr();
{
let store = node.store.lock().unwrap();
befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion");
let prf = crate::profile::sign(&peer.identity_sk, "peer", "", &addr, 1)
.expect("sign peer profile");
assert!(store.apply_profile(&peer.identity_pk, &prf).unwrap());
}
node.tip(&peer.identity_pk, "500000000000", "lunch")
.await
.expect("tip");
let store = node.store.lock().unwrap();
let rows = store.list_payments(&peer.identity_pk).expect("payments");
assert_eq!(rows.len(), 1, "one row for one outbound tip");
assert_eq!(rows[0].dir, "out");
assert_eq!(rows[0].kind, "tip", "an outbound tip is stored as a tip");
assert_eq!(rows[0].amount_atomic, "500000000000");
assert_eq!(rows[0].txid.as_deref(), Some("abc123"));
assert_eq!(rows[0].memo, "lunch");
}
/// Same storage for the other direction: a tip signed by the peer lands as
/// a `kind = "tip"` row plus the `[tip]` line. This is the path the
/// payments CHECK constraint had been rejecting.
#[tokio::test]
async fn an_inbound_tip_is_recorded_and_shown() {
let dir = tempfile::tempdir().unwrap();
let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial));
let peer = Keys::generate();
befriend(
&node.store.lock().unwrap(),
&peer.identity_pk,
&peer.prekey_pk,
"peer.onion",
);
let tip = pay::sign_tip(
&peer.identity_sk,
"abc123",
"500000000000",
&xmr_addr(),
"lunch",
1,
)
.expect("sign peer tip");
node.ingest_tip(&peer.identity_pk, &pay::encode_tip(&tip))
.await
.expect("inbound tip must be stored");
assert_eq!(
chat_lines(&node, &peer),
vec![(
"in".to_string(),
"[tip] 0.5 XMR — lunch (pending)".to_string()
)],
"the receiver's chat shows the tip that arrived"
);
let rows = node.store.lock().unwrap().list_payments(&peer.identity_pk);
let rows = rows.expect("payments");
assert_eq!(rows.len(), 1, "one row for one inbound tip");
assert_eq!(rows[0].dir, "in");
assert_eq!(rows[0].kind, "tip");
}
}

View file

@ -261,7 +261,7 @@ impl Store {
id INTEGER PRIMARY KEY,
friend_id INTEGER NOT NULL REFERENCES friends(id),
dir TEXT NOT NULL CHECK(dir IN ('in','out')),
kind TEXT NOT NULL CHECK(kind IN ('invoice','receipt')),
kind TEXT NOT NULL CHECK(kind IN ('invoice','receipt','tip')),
amount_atomic TEXT NOT NULL,
address TEXT NOT NULL,
memo TEXT NOT NULL DEFAULT '',
@ -365,6 +365,51 @@ impl Store {
"payload",
"ALTER TABLE outbox ADD COLUMN payload BLOB",
)?;
// `insert_payment` has accepted `kind = "tip"` since the tip path
// landed, but the table's CHECK only allowed invoice/receipt, so every
// tip insert (inbound *and* outbound) failed the constraint and the
// frame was dropped. SQLite cannot alter a CHECK, so rebuild.
self.widen_payment_kinds()?;
Ok(())
}
/// Widen `payments.kind` to accept `'tip'` on stores created before the
/// tip path. The table is rebuilt in place because SQLite has no
/// `ALTER TABLE ... DROP CONSTRAINT`; ids and rows are preserved verbatim.
fn widen_payment_kinds(&self) -> Result<()> {
let schema: Option<String> = self
.conn
.query_row(
"SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'payments'",
[],
|row| row.get(0),
)
.optional()?;
let Some(schema) = schema else {
return Ok(());
};
if schema.contains("'tip'") {
return Ok(());
}
self.conn.execute_batch(
"ALTER TABLE payments RENAME TO payments_pre_tip;
CREATE TABLE payments (
id INTEGER PRIMARY KEY,
friend_id INTEGER NOT NULL REFERENCES friends(id),
dir TEXT NOT NULL CHECK(dir IN ('in','out')),
kind TEXT NOT NULL CHECK(kind IN ('invoice','receipt','tip')),
amount_atomic TEXT NOT NULL,
address TEXT NOT NULL,
memo TEXT NOT NULL DEFAULT '',
txid TEXT,
verified INTEGER NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL
);
INSERT INTO payments (id, friend_id, dir, kind, amount_atomic, address, memo, txid, verified, created_at)
SELECT id, friend_id, dir, kind, amount_atomic, address, memo, txid, verified, created_at
FROM payments_pre_tip;
DROP TABLE payments_pre_tip;",
)?;
Ok(())
}
@ -1940,6 +1985,56 @@ mod at_rest {
}
}
/// The old `payments.kind` CHECK allowed only invoice/receipt, so every
/// `kind = "tip"` insert (inbound and outbound) failed the constraint.
/// Opening an existing store must widen it without losing the rows in it.
#[test]
fn a_store_predating_tip_payments_is_widened_on_open() {
const ADDR: &str = "4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYTRj5UzqtReoS44qo9mtmXCqY45DJ852K5Jv2684Rge";
let dir = tempfile::tempdir().unwrap();
let db_path = dir.path().join("onionwire.db");
write_legacy_plaintext_store(&db_path, "tip-pass");
{
let conn = Connection::open(&db_path).unwrap();
let schema: String = conn
.query_row(
"SELECT sql FROM sqlite_master WHERE name = 'payments'",
[],
|r| r.get(0),
)
.unwrap();
assert!(!schema.contains("'tip'"), "fixture is the pre-tip table");
conn.execute(
"INSERT INTO payments (friend_id, dir, kind, amount_atomic, address, memo, txid, verified, created_at)
VALUES (1, 'out', 'invoice', '1000000000000', ?1, 'm', NULL, 0, 7)",
params![ADDR],
)
.unwrap();
}
let store = Store::open_at_with_passphrase(dir.path(), "tip-pass").expect("open+upgrade");
let rows = store.list_payments(&LEGACY_FRIEND_PK).unwrap();
assert_eq!(rows.len(), 1, "the pre-tip row survives the rebuild");
assert_eq!(rows[0].kind, "invoice");
assert_eq!(rows[0].amount_atomic, "1000000000000");
assert_eq!(rows[0].created_at, 7, "rows are copied verbatim");
store
.insert_payment(
&LEGACY_FRIEND_PK,
PaymentWrite {
dir: "in",
kind: "tip",
amount_atomic: "500000000000",
address: ADDR,
memo: "lunch",
txid: Some("abc123"),
verified: false,
},
)
.expect("a migrated store accepts the tip kind");
}
/// `ratchet_sessions` keys on `friend_id`, and nothing in the crate deletes
/// friends yet, so the cascade is exercised with the raw statement a future
/// friend-removal path would run.

View file

@ -204,11 +204,22 @@ pub struct OutboxSummary {
pub failed: usize,
/// First terminal failure, for the fail-closed footer copy.
pub first_error: Option<String>,
/// Highest attempt count across outstanding rows (0 when nothing is
/// outstanding). With `DEFAULT_MAX_ATTEMPTS` this is the `n` in `(n/8)`.
pub attempts: u32,
/// Seconds until the earliest scheduled retry, relative to the render
/// `now`. `None` while nothing is outstanding.
pub next_in_secs: Option<i64>,
}
impl OutboxSummary {
/// Footer note, or `None` when nothing is outstanding. Any terminal failure
/// keeps a `send failed` statement so the fail-closed copy stays visible.
///
/// An outstanding row is a reachability statement, not just a count: the
/// peer's onion did not answer *this* dial, so the note names that and the
/// retry it is waiting on (`peer unreachable, queued (n/8, retry 45s)`).
/// There is no mutual-online indicator to fall back on.
pub fn note(&self) -> Option<String> {
let reason = || {
short_send_reason(
@ -216,12 +227,19 @@ impl OutboxSummary {
FAIL_REASON_BUDGET,
)
};
let queued = || {
format!(
"peer unreachable, queued ({}/{DEFAULT_MAX_ATTEMPTS}, {})",
self.attempts,
retry_in_text(self.next_in_secs.unwrap_or(0))
)
};
match (self.queued, self.failed) {
(0, 0) => None,
(queued, 0) => Some(format!("{queued} queued")),
(0, 1) => Some(format!("send failed: {}", reason())),
(0, failed) => Some(format!("send failed: {} ({failed} failed)", reason())),
(queued, _) => Some(format!("{queued} queued, send failed: {}", reason())),
(_, 0) => Some(queued()),
(_, _) => Some(format!("{}, send failed: {}", queued(), reason())),
}
}
}
@ -244,7 +262,17 @@ pub fn chat_with_delivery(
summary.failed += 1;
summary.first_error.get_or_insert_with(|| why.clone());
}
_ => summary.queued += 1,
_ => {
summary.queued += 1;
// The note is the reachability statement for the selected
// friend: highest attempt count, soonest scheduled retry.
summary.attempts = summary.attempts.max(entry.attempts);
let secs = entry.next_attempt_at - now;
summary.next_in_secs = Some(match summary.next_in_secs {
Some(prev) => prev.min(secs),
None => secs,
});
}
}
}
if msgs.is_empty() {
@ -463,6 +491,17 @@ Offline friends CANNOT find you until they F3-paste your new invite.\n\
Type ROTATE to confirm Esc to cancel"
}
/// F8. Hard cut like the locator rotate: the prekey is our Noise static and the
/// ratchet bootstrap is derived from the prekey DH, so nothing short of a fresh
/// invite re-syncs a friend.
pub fn prekey_screen_text() -> &'static str {
"Rotate prekey?\n\
Your identity and onion stay the same.\n\
Every friend must F3-paste your new invite to pick up the new prekey,\n\
or you cannot reach them and they cannot reach you.\n\
Type ROTATE to confirm Esc to cancel"
}
pub fn quit_screen_text() -> &'static str {
"Quit OnionWire?\n\
Message history can be cleared; identity and friends stay.\n\
@ -507,6 +546,7 @@ OnionWire keys\n\
F4 rotate onion locator\n\
F5 selected friend's profile (/who)\n\
F6 wallet (receive QR, create/import)\n\
F8 rotate prekey\n\
/profile edit name, bio, Monero address\n\
/pay <xmr> [memo] invoice to receive\n\
/tip <xmr> [memo] pay selected friend\n\
@ -1157,6 +1197,9 @@ enum Screen {
Rotate {
prompt: RotatePrompt,
},
RotatePrekey {
prompt: RotatePrompt,
},
Wipe {
kind: WipeKind,
prompt: WipePrompt,
@ -1296,6 +1339,11 @@ impl App {
}
KeyCode::F(5) => self.who_open = true,
KeyCode::F(6) => self.open_wallet()?,
KeyCode::F(8) => {
self.screen = Screen::RotatePrekey {
prompt: RotatePrompt::new(),
};
}
KeyCode::Esc => self.composer.clear(),
KeyCode::Backspace => {
if self.focus == Pane::Composer {
@ -1415,6 +1463,18 @@ impl App {
}
_ => {}
},
Screen::RotatePrekey { prompt } => match key.code {
KeyCode::Esc => self.screen = Screen::Main,
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
if prompt.on_char(c) == RotateDecision::Confirm {
self.confirm_rotate_prekey()?;
}
}
KeyCode::Backspace => {
prompt.on_char('\u{8}');
}
_ => {}
},
Screen::Wipe { kind, prompt } => {
let kind = *kind;
match key.code {
@ -1687,6 +1747,24 @@ impl App {
}
}
/// F8. Local and synchronous: nothing is pushed to peers — the new prekey
/// only travels inside a fresh signed invite — so the screen goes straight
/// to that invite (the F2 share path) for the user to hand out.
fn confirm_rotate_prekey(&mut self) -> Result<(), String> {
match self.node.rotate_prekey() {
Ok(_) => {
self.status_note =
Some("prekey rotated · friends must F3-paste your new invite".into());
self.open_share()
}
Err(e) => {
self.alert = Some(e);
self.screen = Screen::Main;
Ok(())
}
}
}
fn open_share(&mut self) -> Result<(), String> {
let payload = self.node.qr_payload()?;
self.screen = Screen::Share { payload };
@ -2064,6 +2142,7 @@ impl App {
Screen::Paste { buf, err } => draw_paste(f, buf, err.as_deref()),
Screen::Approve { payload } => draw_approve(f, payload),
Screen::Rotate { prompt } => draw_rotate(f, prompt.typed()),
Screen::RotatePrekey { prompt } => draw_rotate_prekey(f, prompt.typed()),
Screen::Wipe { kind, prompt } => draw_wipe(f, *kind, prompt.typed()),
Screen::Profile { editor } => draw_profile(f, editor),
Screen::ConfirmKeys { kind, prompt, .. } => draw_confirm_keys(f, *kind, prompt.typed()),
@ -2382,6 +2461,7 @@ match screen {
Screen::Paste { .. } => "Enter submit Esc back ? help",
Screen::Approve { .. } => "y accept n reject ? help",
Screen::Rotate { .. } => "type ROTATE Esc cancel ? help",
Screen::RotatePrekey { .. } => "type ROTATE Esc cancel ? help",
Screen::Wipe { kind, .. } => match kind {
WipeKind::Messages => "type WIPE Esc cancel ? help",
WipeKind::All => "type WIPEALL Esc cancel ? help",
@ -2482,6 +2562,17 @@ fn draw_rotate(f: &mut Frame, typed: &str) {
);
}
fn draw_rotate_prekey(f: &mut Frame, typed: &str) {
let body = format!("{}\n\n{typed}", prekey_screen_text());
f.render_widget(
Paragraph::new(body)
.style(style_text())
.wrap(Wrap { trim: false })
.block(themed_block("(o) rotate prekey")),
f.area(),
);
}
fn draw_wipe(f: &mut Frame, kind: WipeKind, typed: &str) {
let title = match kind {
WipeKind::Messages => "(o) wipe",

View file

@ -147,6 +147,130 @@ fn round_trip_across_two_dh_ratchet_steps() {
assert_eq!(a.decrypt(&m4).expect("decrypt m4"), b"m4");
}
/// The ratchet key a frame advertises: `dh_pub[0..32]` of the header.
fn dh_pub(frame: &[u8]) -> [u8; 32] {
header_at(frame)[..32].try_into().expect("32")
}
/// Lockstep on a bidirectional burst: every frame after a peer has stepped
/// carries the key that peer is now sending with, and the receiver *adopts
/// exactly that key* before its sending chain rekeys.
///
/// `round_trip_across_two_dh_ratchet_steps` only asserts that neither sending
/// ratchet stayed put; it would still pass if the two sides stepped onto
/// unconnected epochs, and it never checks that either side adopted the key the
/// other advertised. This test reads the key out of the wire header and asserts
/// the adoption, per step, on a burst in both directions.
///
/// The bootstrap tie-break means one A→B/B→A round cannot step both sides: only
/// the lower-key peer rotates its sending chain on establishment, and the other
/// peer has still only ever seen bootstrap keys. The burst therefore drives the
/// second and third rounds, and pins the intermediate state at each one.
#[test]
fn bidirectional_burst_keeps_the_dh_ratchet_in_lockstep() {
let (mut a, mut b) = peers();
let (a0, b0) = (a.public(), b.public());
assert_eq!(a.remote_pub(), b0, "a starts keyed to b's bootstrap key");
assert_eq!(b.remote_pub(), a0, "b starts keyed to a's bootstrap key");
// Round 1 — A→B then B→A. Only a rotates here (it sorts lower).
let m1 = a.encrypt(b"a/1").expect("encrypt");
assert_eq!(
dh_pub(&m1),
a0,
"a's first frame advertises its bootstrap key"
);
assert_eq!(b.decrypt(&m1).expect("b decrypts a/1"), b"a/1");
assert_eq!(b.public(), b0, "b has no new key to adopt yet");
assert_eq!(b.remote_pub(), a0);
let m2 = b.encrypt(b"b/1").expect("encrypt");
assert_eq!(
dh_pub(&m2),
b0,
"b's first frame advertises its bootstrap key"
);
assert_eq!(a.decrypt(&m2).expect("a decrypts b/1"), b"b/1");
let a1 = a.public();
assert_ne!(a1, a0, "round 1 must rotate a's sending ratchet key");
assert_eq!(a.remote_pub(), b0, "a is keyed to the key b advertised");
// Round 2 — a's fresh key reaches b, which is the step the one-round
// exchange never takes.
let m3 = a.encrypt(b"a/2").expect("encrypt");
assert_eq!(dh_pub(&m3), a1, "a advertises the key it just ratcheted to");
assert_eq!(b.decrypt(&m3).expect("b decrypts a/2"), b"a/2");
let b1 = b.public();
assert_ne!(b1, b0, "b must DH-ratchet on a's new key");
assert_eq!(b.remote_pub(), a1, "b adopted exactly the key a advertised");
// Round 3 — the mirror image: b's fresh key reaches a.
let m4 = b.encrypt(b"b/2").expect("encrypt");
assert_eq!(dh_pub(&m4), b1, "b advertises the key it just ratcheted to");
assert_eq!(a.decrypt(&m4).expect("a decrypts b/2"), b"b/2");
let a2 = a.public();
assert_ne!(a2, a1, "a stepped onto a fresh key of its own");
assert_eq!(a.remote_pub(), b1, "a adopted exactly the key b advertised");
// The burst proper: three frames each way on the epoch both sides now hold.
let to_b: Vec<Vec<u8>> = (0..3)
.map(|i| {
a.encrypt(format!("a/burst{i}").as_bytes())
.expect("encrypt")
})
.collect();
for frame in &to_b {
assert_eq!(dh_pub(frame), a2, "the burst stays on a's current key");
}
for (i, frame) in to_b.iter().enumerate() {
assert_eq!(
b.decrypt(frame).expect("burst a→b"),
format!("a/burst{i}").as_bytes()
);
}
let b2 = b.public();
assert_ne!(
b2, b1,
"b's first burst frame is a full step, not a chain read"
);
assert_eq!(b.remote_pub(), a2, "b adopted a's burst key");
assert_eq!(b.recv_index(), 3, "all three burst frames were consumed");
assert_eq!(b.skipped_len(), 0, "in-order burst skipped nothing");
let to_a: Vec<Vec<u8>> = (0..3)
.map(|i| {
b.encrypt(format!("b/burst{i}").as_bytes())
.expect("encrypt")
})
.collect();
for frame in &to_a {
assert_eq!(dh_pub(frame), b2, "the burst stays on b's current key");
}
for (i, frame) in to_a.iter().enumerate() {
assert_eq!(
a.decrypt(frame).expect("burst b→a"),
format!("b/burst{i}").as_bytes()
);
}
// Lockstep after the burst: the peer that received last is keyed to the
// other's *current* key, and the sender's own key is the one its burst
// advertised. (b's view of a is a2 — a's step generated a3, which has not
// been sent yet; that lag is the ratchet's normal one-header asymmetry.)
assert_eq!(a.remote_pub(), b2);
assert_eq!(a.remote_pub(), b.public(), "a is keyed to b's current key");
assert_eq!(b.remote_pub(), a2, "b is keyed to a's last advertised key");
assert_ne!(a.public(), a2, "a stepped again on b's burst");
assert_ne!(a.public(), a0, "a never ratcheted across the whole burst");
assert_ne!(b.public(), b0, "b never ratcheted across the whole burst");
assert_eq!(a.skipped_len(), 0);
assert_eq!(a.recv_index(), 3);
// And the conversation still flows on the epoch the burst left behind.
let after = a.encrypt(b"a/after").expect("encrypt");
assert_eq!(b.decrypt(&after).expect("a/after"), b"a/after");
}
#[test]
fn out_of_order_within_one_chain() {
let (mut a, mut b) = peers();
@ -372,6 +496,81 @@ fn state_round_trips_and_rejects_garbage() {
assert!(RatchetState::from_bytes(&huge_count).is_err());
}
/// Fixed size of a v1 state blob's prefix: the version byte, the root key, the
/// local secret and public, the remote public, both chain keys, both counters,
/// `prev_send_len`, the established flag and the skipped-key count.
/// Documented in `src/ratchet.rs`'s `to_bytes` layout.
const STATE_PREFIX_LEN: usize = 1 + 32 + 32 + 32 + 32 + 32 + 4 + 32 + 4 + 4 + 1 + 4;
/// Freeze guard for the persisted wire format. A stored session is only
/// meaningful if both sides agree byte for byte on the layout, so a version
/// bump or a field insertion must break this test on purpose.
///
/// `0x01` is asserted as a literal: asserting `STATE_VERSION` would silently
/// follow a bump instead of catching it, which is the whole point of the
/// guard.
#[test]
fn ratchet_state_blob_is_frozen_at_version_v1() {
let local = RatchetKeyPair::from_secret([0x11u8; 32]);
let remote = RatchetKeyPair::from_secret([0x22u8; 32]);
let state = RatchetState::bootstrap(ROOT, local, remote.public());
let bytes = state.to_bytes();
assert_eq!(
STATE_VERSION, 1,
"the frozen version byte changed: this is a wire-format break, not a refactor"
);
assert_eq!(
bytes[0], 0x01,
"a state blob must start with the v1 version byte"
);
assert_eq!(
bytes.len(),
STATE_PREFIX_LEN,
"the fixed part of the v1 layout changed (a field was added, removed or resized)"
);
assert_eq!(
bytes.len(),
210,
"the documented v1 prefix is 210 bytes; a different number means the \
format moved and stored sessions need a migration path"
);
}
/// A blob written by another version must come back as a typed
/// `UnsupportedStateVersion`, never as a panic and never as a state decoded
/// under the wrong layout. The guard must also not be over-eager: the
/// untouched v1 blob still loads.
#[test]
fn ratchet_state_foreign_version_is_rejected_not_misread() {
let (mut a, mut b) = peers();
// Decrypting m2 first leaves m0/m1 in the skipped store, so the blob is
// longer than the fixed prefix and the check cannot pass by luck.
let frames: Vec<Vec<u8>> = (0..3)
.map(|i| a.encrypt(format!("m{i}").as_bytes()).expect("encrypt"))
.collect();
assert_eq!(b.decrypt(&frames[2]).expect("m2"), b"m2");
let bytes = b.to_bytes();
assert!(
bytes.len() > STATE_PREFIX_LEN,
"expected skipped keys in the blob, got {} bytes",
bytes.len()
);
for version in [0x00u8, 0x02, 0x7f, 0xff] {
let mut foreign = bytes.clone();
foreign[0] = version;
assert_eq!(
RatchetState::from_bytes(&foreign).expect_err("a foreign version must be rejected"),
Error::UnsupportedStateVersion(version),
"version {version:#04x} must be rejected under its own code, not misread or panicked on"
);
}
let reloaded = RatchetState::from_bytes(&bytes).expect("the untouched v1 blob still loads");
assert_eq!(reloaded.to_bytes(), bytes, "v1 round trip is not stable");
}
/// Mirrors the private `MIN_FRAME_LEN` in `src/ratchet.rs`
/// (`HEADER_OFFSET + HEADER_LEN + NONCE_LEN + TAG_LEN`), which the crate does
/// not export.

View file

@ -130,3 +130,27 @@ fn rotate_prompt_text_matches_spec() {
assert!(t.contains("Type ROTATE to confirm"));
assert!(t.contains("Esc to cancel"));
}
#[test]
fn f8_prekey_rotation_screen_text_matches_spec() {
let t = onionwire::tui::prekey_screen_text();
assert!(t.contains("Rotate prekey?"));
assert!(t.contains("Your identity and onion stay the same."));
assert!(
t.contains("F3-paste"),
"the re-paste requirement is the whole point of the screen"
);
assert!(t.contains("Type ROTATE to confirm"));
assert!(t.contains("Esc to cancel"));
}
#[test]
fn f8_reuses_the_type_rotate_confirm_prompt() {
let mut p = RotatePrompt::new();
assert_eq!(p.on_esc(), RotateDecision::Cancel);
for c in "ROTA".chars() {
assert_eq!(p.on_char(c), RotateDecision::Pending);
}
assert_eq!(p.on_char('T'), RotateDecision::Pending);
assert_eq!(p.on_char('E'), RotateDecision::Confirm);
}

36
tests/tls_backend.rs Normal file
View file

@ -0,0 +1,36 @@
//! Pin the crate's default TLS backend to Arti's `rustls` feature.
//!
//! The TUI/release build and the Android SDK are the same crate compiled with
//! different feature sets, and Arti's two TLS backends are non-additive. The
//! default must be `rustls` so no build pulls OpenSSL in for TLS (Android has
//! no OpenSSL in the NDK, and the released binaries should not need a system
//! OpenSSL).
// The default feature set must select `rustls`, not `native-tls`.
//
// Pinned at compile time: this test target is built with the crate's default
// features, so it stops compiling if `default` ever moves back off Arti's
// rustls backend.
const _: () = assert!(cfg!(feature = "rustls"));
const _: () = assert!(!cfg!(feature = "native-tls"));
/// Building a `rustls` config the way Arti does works with no manual provider
/// install, straight from the process default.
///
/// This is the load-bearing half: `tor-rtcompat` depends on rustls with
/// `default-features = false`, so unless *this* crate turns on rustls's `ring`
/// feature the TLS backend compiles with no `CryptoProvider` and Arti dies the
/// first time it builds a TLS config.
#[test]
fn rustls_resolves_a_crypto_provider_from_crate_features() {
assert!(
rustls::crypto::CryptoProvider::get_default().is_none(),
"another test in this binary installed a CryptoProvider first"
);
let _ = rustls::ClientConfig::builder();
assert!(
rustls::crypto::CryptoProvider::get_default().is_some(),
"rustls resolved no CryptoProvider — the crate feature that selects one \
(`ring`) is missing from the dependency graph"
);
}

View file

@ -46,6 +46,7 @@ fn help_overlay_lists_core_bindings() {
"F4",
"F5",
"F6",
"F8",
"send chat",
"/profile",
"/pay",

View file

@ -531,7 +531,10 @@ fn identical_bodies_join_by_message_id_not_body() {
"delivered row (id 8) must keep its mark: {:?}",
lines[1]
);
assert_eq!(summary.note().as_deref(), Some("1 queued"));
assert_eq!(
summary.note().as_deref(),
Some("peer unreachable, queued (1/8, retry 30s)")
);
}
#[test]
@ -621,13 +624,19 @@ fn footer_summary_counts_queued_and_keeps_fail_closed() {
queued: 2,
failed: 0,
first_error: None,
attempts: 3,
next_in_secs: Some(45),
};
assert_eq!(queued.note().as_deref(), Some("2 queued"));
assert_eq!(
queued.note().as_deref(),
Some("peer unreachable, queued (3/8, retry 45s)")
);
let failed = OutboxSummary {
queued: 0,
failed: 1,
first_error: Some("connect peer.onion:80: connection timed out".into()),
..OutboxSummary::default()
};
let note = failed.note().expect("failed rows must produce a note");
assert!(note.starts_with("send failed:"), "{note:?}");
@ -637,9 +646,15 @@ fn footer_summary_counts_queued_and_keeps_fail_closed() {
queued: 3,
failed: 1,
first_error: Some("connect peer.onion:80: connection timed out".into()),
attempts: 2,
next_in_secs: Some(60),
};
let mixed_note = mixed.note().expect("mixed rows must produce a note");
assert!(mixed_note.contains("3 queued"), "{mixed_note:?}");
assert!(
mixed_note.contains("queued (2/8, retry 1m)"),
"{mixed_note:?}"
);
assert!(mixed_note.starts_with("peer unreachable"), "{mixed_note:?}");
assert!(mixed_note.contains("send failed"), "{mixed_note:?}");
// Fail-closed copy stays visible in the real footer at the 80-col floor.
@ -653,7 +668,10 @@ fn footer_summary_counts_queued_and_keeps_fail_closed() {
assert!(line.contains("TOR") && line.contains("? help"), "{line:?}");
let queued_line = status_footer(80, FP, ONION, queued.note().as_deref(), main_footer_hints());
assert!(queued_line.contains("2 queued"), "{queued_line:?}");
assert!(
queued_line.contains("queued (3/8, retry 45s)"),
"{queued_line:?}"
);
assert!(queued_line.chars().count() <= 80);
// `! ` ornament (colour off) still lands on the derived failing note.
@ -731,7 +749,7 @@ fn chat_and_footer_rows_fit_80x24_and_wrap_instead_of_clipping() {
"long row was clipped, not wrapped:\n{screen}"
);
assert!(
screen.contains("1 queued"),
screen.contains("peer unreachable, queued (3/8, retry 45s)"),
"footer summary missing:\n{screen}"
);
println!("===== AFTER outbox 80x24 (real draw_chat + status_footer) =====\n{screen}");
@ -789,7 +807,10 @@ async fn renders_a_queued_row_from_a_real_outbox_send() {
"real outbox row did not render: {:?}",
lines[0]
);
assert_eq!(summary.note().as_deref(), Some("1 queued"));
assert_eq!(
summary.note().as_deref(),
Some("peer unreachable, queued (1/8, retry 45s)")
);
// And once a send crosses the circuit the row is gone, so the same message
// renders as delivered.