diff --git a/.forgejo/workflows/android-ci.yml b/.forgejo/workflows/android-ci.yml deleted file mode 100644 index 5032ff1..0000000 --- a/.forgejo/workflows/android-ci.yml +++ /dev/null @@ -1,339 +0,0 @@ -name: android-ci - -# Android changes had no CI at all: ci.yml's path allowlist (src/**, crates/**, -# tests/**, Cargo.toml, Cargo.lock, ci.yml) never matches android/**, and -# android-release.yml is dispatch/tag-driven — so an android-only PR ran zero -# jobs and merged on an empty check list. This is the android side of CI. -# -# It builds the same gradle targets the release builds through the same script -# android-release.yml calls (scripts/build-android-local.sh): `:sdk:assembleRelease` -# + `:app:assembleRelease`, Rust for aarch64-linux-android via cargo-ndk, UniFFI -# bindings, APK packaging with the .so. The only difference from a release is -# signing: ONIONWIRE_REQUIRE_RELEASE_KEY=false and no release keystore, so -# Gradle falls back to the debug key. Nothing here is signed for release, -# nothing is published, no tag is touched. -# -# Why a separate workflow instead of android/** added to ci.yml: the only way -# to keep the Rust jobs from running on android-only diffs is job-level change -# detection, and a gate that mis-detects hands out a green check for a suite -# that never ran. Here the runner's own paths filter decides — same mechanism -# ci.yml already uses. -# -# The two triggers differ on purpose, and the asymmetry is the whole point of -# the `src/**` entry below: -# -# pull_request — the client and the SDK binding surface. NOT `src/**`. A -# Rust-only PR does change the bytes in `libonionwire_sdk.so`, but proving -# that costs a ~11 minute full APK build, and 95 of 143 recorded runs -# touched no `android/` file at all. The in-APK checks that actually earn -# their keep (the `target_max_memory` marker gate, the `.so` listing, the -# sha256 round-trip) still run on every merge via the push trigger, so -# nothing reaches a release untested — a Rust PR just finds out at merge -# instead of before it. If a Rust change ever breaks the Android build -# specifically, add its path here rather than re-adding all of `src/**`. -# -# push: [main] — every Rust or Android change, every merge. This is the -# safety net, and it is why the trigger cannot simply mirror the PR one. -on: - push: - branches: [main] - paths: - - "android/**" - - "crates/**" - - "src/**" - - "Cargo.toml" - - "Cargo.lock" - - "scripts/build-android-local.sh" - - ".forgejo/workflows/android-ci.yml" - pull_request: - paths: - - "android/**" - - "crates/onionwire-sdk/**" - - "Cargo.toml" - - "Cargo.lock" - - "scripts/build-android-local.sh" - - ".forgejo/workflows/android-ci.yml" - workflow_dispatch: - -# Deliberately the SAME group and the SAME volumes as android-release.yml: the -# APK build is ~9 min with warm volumes (SDK/NDK, cargo registry, cargo target, -# Gradle cache) and a cold copy of those is over a gigabyte of downloads per -# runner. Serializing the two workflows by group name is what keeps them off -# each other's volumes. -concurrency: - group: onionwire-android-release-v2 - cancel-in-progress: false - -env: - CARGO_TERM_COLOR: never - CARGO_BUILD_JOBS: "1" - ONIONWIRE_ANDROID_ABI: arm64-v8a - ANDROID_IMAGE: debian:bookworm - ANDROID_CMDLINE_TOOLS_URL: https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip - # Same floor as ci.yml and release.yml (`rust:1.98-bookworm`). The cuprated - # graph needs >= 1.93 (`tapes` calls `VecDeque::pop_front_if`); 1.91 dies with - # `error[E0658]: use of unstable library feature 'vec_deque_pop_if'`. 1.98 is - # the stable release this graph is built and tested with. - RUST_TOOLCHAIN: "1.98" - DOCKER_STATIC_URL: https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz - # Distinct container prefix: run ids are per-workflow, so this workflow and - # android-release.yml can both be holding a container named "-". - BUILD_CONTAINER: onionwire-android-ci-${{ github.run_id }} - SDK_VOLUME: onionwire-android-sdk - CARGO_VOLUME: onionwire-android-cargo-registry - TARGET_VOLUME: onionwire-android-target - GRADLE_VOLUME: onionwire-android-gradle - -jobs: - android: - runs-on: docker-amd64 - timeout-minutes: 120 - steps: - - name: Checkout - uses: https://code.forgejo.org/actions/checkout@v4 - - - name: Skip superseded run - id: staleness - run: | - set -uo pipefail - # Same gate as ci.yml: a newer commit on this branch while this run - # sat in the shared android concurrency queue makes the ~11 minute - # APK build a proof of nothing. `origin` is anonymously readable - # here, and a failed lookup runs the job rather than skipping it. - ref="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:-}}" - remote="" - if [ -n "$ref" ]; then - remote="$(git ls-remote origin "refs/heads/$ref" 2>/dev/null | cut -f1)" - fi - if [ -n "$remote" ] && [ "$remote" != "$GITHUB_SHA" ]; then - echo "::notice::superseded: refs/heads/$ref is at ${remote:0:12}, this run is ${GITHUB_SHA:0:12} — skipping" - echo "skip=true" >> "$GITHUB_OUTPUT" - else - echo "tip=${remote:-unknown} sha=${GITHUB_SHA} ref=${ref:-none} — running" - echo "skip=false" >> "$GITHUB_OUTPUT" - fi - - - name: Record runner resources - if: steps.staleness.outputs.skip != 'true' - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - echo "workspace=$GITHUB_WORKSPACE hostname=$(hostname) arch=$(uname -m)" - nproc || true - free -h || true - df -h || true - ls -l /var/run/docker.sock || true - - - name: Ensure docker CLI - if: steps.staleness.outputs.skip != 'true' - run: | - set -euo pipefail - if ! command -v docker >/dev/null 2>&1; then - echo "docker CLI missing in job image; fetching static client" - curl -fsSL "$DOCKER_STATIC_URL" -o /tmp/docker.tgz - tar -xzf /tmp/docker.tgz -C /tmp - install -m 755 /tmp/docker/docker /usr/local/bin/docker - fi - export DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}" - docker version - docker info >/tmp/docker-info.txt - grep -E 'Server Version|Operating System|Total Memory|Name' /tmp/docker-info.txt || true - - - name: Build APK + AAR (debug-signed) in bookworm container - id: build - if: steps.staleness.outputs.skip != 'true' - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - export DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}" - start=$(date +%s) - cat > .ci-android-verify.sh <<'INNER' - #!/usr/bin/env bash - set -euo pipefail - export DEBIAN_FRONTEND=noninteractive - apt-get update - # `cmake` is for RandomX, the C++ half of the in-process chain daemon: - # without it `randomx-rs`'s build script panics with "failed to execute - # command: No such file or directory … is `cmake` not installed?" and the - # Gradle task dies on "cargo finished with non-zero exit value 101". - apt-get install -y --no-install-recommends \ - openjdk-17-jdk-headless python3 unzip curl ca-certificates file build-essential pkg-config git \ - cmake - if [ ! -x /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager ]; then - mkdir -p /opt/android-sdk/cmdline-tools - curl -fsSL "$ANDROID_CMDLINE_TOOLS_URL" -o /tmp/cmdline-tools.zip - rm -rf /tmp/cmdline-tools - unzip -q /tmp/cmdline-tools.zip -d /tmp/cmdline-tools - mkdir -p /opt/android-sdk/cmdline-tools/latest - cp -a /tmp/cmdline-tools/cmdline-tools/. /opt/android-sdk/cmdline-tools/latest/ - fi - yes | /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=/opt/android-sdk --licenses >/tmp/sdk-licenses.log || true - /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=/opt/android-sdk \ - "platform-tools" "platforms;android-36" "build-tools;36.0.0" "ndk;28.2.13676358" - test -d /opt/android-sdk/ndk/28.2.13676358 - export ANDROID_HOME=/opt/android-sdk ANDROID_SDK_ROOT=/opt/android-sdk - export ANDROID_NDK_HOME=/opt/android-sdk/ndk/28.2.13676358 - export PATH="$ANDROID_HOME/build-tools/36.0.0:$ANDROID_HOME/platform-tools:$PATH" - if [ ! -x /cargo/bin/rustup ]; then - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN" --no-modify-path --profile minimal - fi - export PATH="/cargo/bin:$PATH" - rustup toolchain install "$RUST_TOOLCHAIN" - rustup default "$RUST_TOOLCHAIN" - rustup target add aarch64-linux-android - command -v cargo-ndk >/dev/null || cargo install cargo-ndk --locked - echo "=== toolchain ===" - java -version - rustc --version - cargo ndk --version - du -sh /opt/android-sdk /cargo /cargo-target /gradle || true - # Shared /gradle volume: a killed container leaves journal-1.lock. - # android/gradle.properties also sets org.gradle.parallel=true, which - # is how two JVMs (PIDs ~5 apart) show up on one lock. Drop the - # stale locks and force one Gradle process for this container. - find /gradle -name '*.lock' -type f -delete 2>/dev/null || true - export GRADLE_OPTS="${GRADLE_OPTS:-} -Dorg.gradle.parallel=false -Dorg.gradle.daemon=false" - # No keystore here on purpose: this is a verification build, not a - # release build. The script warns that Gradle fell back to the debug - # key; that warning is expected in this job. - scripts/build-android-local.sh - version="$(python3 - <<'PY' - import re, pathlib - t = pathlib.Path('android/app/build.gradle.kts').read_text() - m = re.search(r'versionName\s*=.*?:\s*"([^"]+)"', t) - print(m.group(1) if m else '') - PY - )" - abi="${ONIONWIRE_ANDROID_ABI:-arm64-v8a}" - apk="dist/onionwire-$version-android-$abi.apk" - aar="dist/onionwire-sdk-$version.aar" - { - echo "=== file ===" - file "$apk" "$aar" - echo "=== unzip lib ===" - unzip -l "$apk" | grep -E 'lib/.+\.so' || true - unzip -l "$apk" | grep "lib/$abi/libonionwire_sdk.so" - # `unzip -l` shows the uncompressed size only; the *deflated* entry is - # what the download actually costs, and it is not visible anywhere else - # (v0.7.0's SDK lib was 33,481,336 B raw / 12,210,154 B deflated, which - # is the ratio a reader wants when this one grows). - echo "=== native lib entries (length / method / deflated) ===" - unzip -v "$apk" | grep -E 'lib/.+\.so$' - echo "=== in-process chain daemon (cuprate-daemon) is IN this APK ===" - # The build log's "features=cuprate-daemon" line says the feature was - # *requested*; this says it is *in the artifact*. `target_max_memory` is - # a rodata literal from src/cuprate.rs's config TOML, compiled only under - # `#[cfg(feature = "cuprate-daemon")]` — v0.7.0's libonionwire_sdk.so - # contains zero occurrences of it (checked), so its presence is the - # difference between a build that carries the daemon and one that only - # claims to. A missing marker fails the job: an APK whose on-device node - # can only fail is the regression this gate exists to catch. - unzip -p "$apk" "lib/$abi/libonionwire_sdk.so" > /tmp/libonionwire_sdk.so - # `grep -c`, deliberately not `grep -q`: under `set -o pipefail` a `-q` - # match closes the pipe early, `strings` dies on SIGPIPE (141), and the - # pipeline then reports failure even though the marker was there — this - # gate failed its own green build once that way. - marker="$(strings -a /tmp/libonionwire_sdk.so | grep -c 'target_max_memory' || true)" - echo "target_max_memory occurrences: ${marker:-0}" - if [ "${marker:-0}" -lt 1 ]; then - echo "lib/$abi/libonionwire_sdk.so carries no cuprated config string: the cuprate-daemon feature is NOT in this APK" >&2 - exit 1 - fi - echo "=== classes.dex + Compose entrypoints ===" - unzip -l "$apk" | grep -E 'classes[0-9]*\.dex' | head -n3 - echo "=== sha256 ===" - # `sha256sum -c` proves each artifact matches the digest the build - # recorded, but prints neither number. The digest *is* the artifact's - # identity, and an APK is not byte-reproducible across machines, so it - # cannot be derived from the tree afterwards — echo both. - cat "dist/onionwire-$version-android-$abi.apk.sha256" "dist/onionwire-sdk-$version.aar.sha256" - ( cd dist && sha256sum -c "onionwire-$version-android-$abi.apk.sha256" "onionwire-sdk-$version.aar.sha256" ) - echo "=== apksigner (expect debug cert: this is a verification build) ===" - apksigner verify --print-certs "$apk" | sed -n '1,6p' - echo "=== aapt ===" - aapt dump badging "$apk" | sed -n '1,20p' || true - echo "=== sizes ===" - wc -c "$apk" "$aar" - # The cross-compile volume this build just grew. The cuprated graph is - # ~152 crates plus a C++ RandomX build, so the number is the disk cost - # of the feature on the runner, next to the wall clock above. - echo "=== cargo target volume (after this build) ===" - du -sh /cargo-target 2>/dev/null || true - du -sh /cargo-target/aarch64-linux-android/release 2>/dev/null || true - } | tee dist/android-ci-verify.log - INNER - chmod +x .ci-android-verify.sh - docker volume create "$SDK_VOLUME" >/dev/null - docker volume create "$CARGO_VOLUME" >/dev/null - docker volume create "$TARGET_VOLUME" >/dev/null - docker volume create "$GRADLE_VOLUME" >/dev/null - # Cancelled jobs never reach the trailing `docker rm`, so a previous - # onionwire-android-* container can still hold GRADLE_VOLUME. The next - # Gradle then dies LockTimeoutException on /gradle/caches/journal-1 - # (owner PID vs our PID a few numbers apart — two JVMs, one volume). - trap 'docker rm -f "$BUILD_CONTAINER" >/dev/null 2>&1 || true' EXIT - docker ps -aq --filter name=onionwire-android- | xargs -r docker rm -f || true - docker rm -f "$BUILD_CONTAINER" >/dev/null 2>&1 || true - docker pull "$ANDROID_IMAGE" - # 2 GB of Gradle heap, not 1: the only budget in this build that is close - # is the single-use daemon's heap, which now has to package a 55 MB SDK - # lib (plus RandomX's 1.1 MB) through AGP's in-daemon packaging. Run 414 - # died in `:app:packageRelease` with the cause hidden inside - # `PackageAndroidArtifact$IncrementalSplitterRunnable` — no "Caused by" - # line, nothing in the log — so give it room instead of guessing again. - # The runner has 15 GB and the job's peak RSS is ~3 GB. - docker create --name "$BUILD_CONTAINER" -i \ - -e CARGO_TERM_COLOR=never \ - -e CARGO_BUILD_JOBS="$CARGO_BUILD_JOBS" \ - -e CARGO_HOME=/cargo \ - -e CARGO_TARGET_DIR=/cargo-target \ - -e GRADLE_USER_HOME=/gradle \ - -e ANDROID_HOME=/opt/android-sdk \ - -e ANDROID_SDK_ROOT=/opt/android-sdk \ - -e ANDROID_NDK_HOME=/opt/android-sdk/ndk/28.2.13676358 \ - -e ONIONWIRE_ANDROID_ABI="$ONIONWIRE_ANDROID_ABI" \ - -e ONIONWIRE_REQUIRE_RELEASE_KEY=false \ - -e RUST_TOOLCHAIN="$RUST_TOOLCHAIN" \ - -e ANDROID_CMDLINE_TOOLS_URL="$ANDROID_CMDLINE_TOOLS_URL" \ - -e GRADLE_OPTS="-Dorg.gradle.daemon=false -Dorg.gradle.parallel=false -Dorg.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8" \ - -v "$SDK_VOLUME":/opt/android-sdk \ - -v "$CARGO_VOLUME":/cargo \ - -v "$TARGET_VOLUME":/cargo-target \ - -v "$GRADLE_VOLUME":/gradle \ - -w /src \ - "$ANDROID_IMAGE" \ - bash -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src && bash /src/.ci-android-verify.sh' - tar czf - \ - --exclude=./target --exclude=./.git --exclude=./.worktrees \ - --exclude=./android/.gradle --exclude=./android/app/build \ - --exclude=./android/sdk/build --exclude=./dist \ - --exclude=./crates/onionwire-sdk/target \ - . \ - | docker start -a -i "$BUILD_CONTAINER" - mkdir -p dist - docker cp "$BUILD_CONTAINER:/src/dist/." dist/ - end=$(date +%s) - echo "build_wall_clock_seconds=$((end - start))" - echo "wall_clock_seconds=$((end - start))" >> "$GITHUB_OUTPUT" - docker rm -f "$BUILD_CONTAINER" >/dev/null || true - ls -l dist/ - - - name: Verify artifacts - if: steps.staleness.outputs.skip != 'true' - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - abi="$ONIONWIRE_ANDROID_ABI" - ls -l dist/ - apk="$(ls dist/onionwire-*-android-$abi.apk)" - aar="$(ls dist/onionwire-sdk-*.aar)" - [ -s "$apk" ] || { echo "missing or empty $apk" >&2; exit 1; } - [ -s "$aar" ] || { echo "missing or empty $aar" >&2; exit 1; } - echo "apk=$apk bytes=$(wc -c < "$apk")" - echo "aar=$aar bytes=$(wc -c < "$aar")" - ( cd dist && sha256sum -c ./*.sha256 ) - echo "=== android-ci-verify.log (from build container) ===" - cat dist/android-ci-verify.log - echo "=== resources after build ===" - free -h || true - df -h || true diff --git a/.forgejo/workflows/android-release.yml b/.forgejo/workflows/android-release.yml deleted file mode 100644 index 1e34c17..0000000 --- a/.forgejo/workflows/android-release.yml +++ /dev/null @@ -1,483 +0,0 @@ -name: android-release - -# Build the Android APK + SDK AAR on docker-amd64 and attach them to the -# Forgejo release for the computed (or requested) tag. -# -# The runner job image is node:20-bullseye (EOL). Do not apt-get there. -# toolchain runs in a sibling debian:bookworm container, -# the same stdin-tar + docker cp pattern as .forgejo/workflows/ci.yml. -# -# Publish is a separate job on the Pi runner (`docker`). POST /releases from -# the amd64 dind egress returns 422 with an empty body (core run 116); -# core's publish job on the Pi (run 135) is the proven path. -# -# First automated version with zero tags: v0.1.0. Afterwards, patch+1 from the -# latest v*.*.* tag UNLESS that tag's release is missing the Android assets — -# then join it (core owns tag creation). Never move or delete a tag. -# -# No automatic trigger, on purpose. Two candidate decoupled triggers were -# tried and both dead-end on Forgejo 10.0.3 (see docs/RELEASING.md): -# - `push: tags: ['v*.*.*']` — a tag created by release.yml (API or git push) -# does not fire it: pushes made with the CI's token are Actions-user events -# and Forgejo deliberately does not dispatch those back into Actions. -# Verified: the v0.2.0 and v0.2.1 tags produced no run, while hand-pushed -# tags did historically. -# - `workflow_call` from release.yml — reusable workflows only exist from -# Forgejo 12; this instance is 10.0.3. -# So a release is two dispatches: release.yml, then this one with `tag=`. The core's run leaves the tag; this attaches -# the APK + AAR to it. - -on: - workflow_dispatch: - inputs: - tag: - description: Existing tag to (re)build and attach (empty = next version) - required: false - type: string - dry_run: - description: Build and checksum without creating a tag or publishing (true/false) - required: false - type: string - default: "false" - workflow_call: - inputs: - tag: - required: false - type: string - dry_run: - required: false - type: string - default: "false" - -concurrency: - group: onionwire-android-release-v2 - cancel-in-progress: false - -env: - CARGO_TERM_COLOR: never - CARGO_BUILD_JOBS: "1" - ONIONWIRE_ANDROID_ABI: arm64-v8a - ONIONWIRE_REQUIRE_RELEASE_KEY: "true" - ANDROID_IMAGE: debian:bookworm - ANDROID_CMDLINE_TOOLS_URL: https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip - # Same floor as ci.yml (`rust:1.98-bookworm`): the cuprated graph needs >= 1.93 - # (`tapes` uses `VecDeque::pop_front_if`), and 1.98 is what this graph is built with. - RUST_TOOLCHAIN: "1.98" - DOCKER_STATIC_URL: https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz - BUILD_CONTAINER: onionwire-android-${{ github.run_id }} - SDK_VOLUME: onionwire-android-sdk - CARGO_VOLUME: onionwire-android-cargo-registry - TARGET_VOLUME: onionwire-android-target - GRADLE_VOLUME: onionwire-android-gradle - -jobs: - android: - runs-on: docker-amd64 - timeout-minutes: 90 - outputs: - version: ${{ steps.version.outputs.version }} - tag: ${{ steps.version.outputs.tag }} - version_code: ${{ steps.version.outputs.version_code }} - dry_run: ${{ steps.version.outputs.dry_run }} - steps: - - name: Checkout - uses: https://code.forgejo.org/actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.inputs.tag || inputs.tag || github.sha }} - - - name: Record runner resources - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - echo "workspace=$GITHUB_WORKSPACE hostname=$(hostname) arch=$(uname -m)" - nproc || true - free -h || true - df -h || true - ls -l /var/run/docker.sock || true - - - name: Compute version - id: version - env: - INPUT_TAG: ${{ github.event.inputs.tag || inputs.tag }} - INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }} - CALL_DRY_RUN: ${{ inputs.dry_run }} - FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} - REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - echo "INPUT_DRY_RUN='${INPUT_DRY_RUN:-}' CALL_DRY_RUN='${CALL_DRY_RUN:-}' EVENT=${GITHUB_EVENT_NAME:-}" - git fetch --tags --force origin || true - input_tag="${INPUT_TAG:-}" - dry_run=false - case "${INPUT_DRY_RUN:-}" in true|TRUE|True|1|yes|YES) dry_run=true ;; esac - case "${CALL_DRY_RUN:-}" in true|TRUE|True|1|yes|YES) dry_run=true ;; esac - if [ -n "$input_tag" ]; then - ver="${input_tag#v}" - else - latest="$(git tag -l 'v*.*.*' --sort=-v:refname | head -n1 || true)" - if [ -z "$latest" ]; then - ver="0.1.0" - else - # Core owns tag creation. If the latest tag's release is missing - # the Android APK, join that version instead of minting patch+1. - join=0 - if [ -n "${FORGEJO_TOKEN:-}" ]; then - http=$(curl -sS --http1.1 -o /tmp/latest-rel.json -w '%{http_code}' \ - -u "sirius:${FORGEJO_TOKEN}" \ - "$REPO_API/releases/tags/$latest" || true) - if [ "$http" != "200" ]; then - join=1 - echo "latest tag $latest has no release (http $http); joining" - elif node -e 'const d=require("/tmp/latest-rel.json"); const n=(d.assets||[]).some(a=>/onionwire-.*-android-.*\\.apk$/.test(a.name)); process.exit(n?0:1)'; then - echo "latest tag $latest already has an Android APK; patch+1" - else - join=1 - echo "latest tag $latest release is missing Android APK; joining" - fi - else - echo "FORGEJO_TOKEN unset; cannot inspect release assets, joining $latest" - join=1 - fi - if [ "$join" = "1" ]; then - ver="${latest#v}" - else - ver="${latest#v}" - major="${ver%%.*}" - rest="${ver#*.}" - minor="${rest%%.*}" - patch="${rest#*.}" - patch=$((patch + 1)) - ver="${major}.${minor}.${patch}" - fi - fi - fi - echo "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || { - echo "not a MAJOR.MINOR.PATCH version: $ver" >&2 - exit 1 - } - major="${ver%%.*}" - rest="${ver#*.}" - minor="${rest%%.*}" - patch="${rest#*.}" - code=$((major * 10000 + minor * 100 + patch)) - tag="v$ver" - { - echo "version=$ver" - echo "tag=$tag" - echo "version_code=$code" - echo "dry_run=$dry_run" - } >> "$GITHUB_OUTPUT" - echo "version=$ver tag=$tag versionCode=$code dry_run=$dry_run" - - - name: Decode release keystore - env: - ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} - ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} - ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} - ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - : "${ANDROID_KEYSTORE_BASE64:?ANDROID_KEYSTORE_BASE64 secret is missing}" - : "${ANDROID_KEYSTORE_PASSWORD:?ANDROID_KEYSTORE_PASSWORD secret is missing}" - : "${ANDROID_KEY_ALIAS:?ANDROID_KEY_ALIAS secret is missing}" - : "${ANDROID_KEY_PASSWORD:?ANDROID_KEY_PASSWORD secret is missing}" - mkdir -p "$HOME/.android" - chmod 700 "$HOME/.android" - ks="$HOME/.android/onionwire-release.jks" - envf="$HOME/.android/onionwire-release.env" - printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 -d > "$ks" - chmod 600 "$ks" - test -s "$ks" - umask 077 - printf 'ANDROID_KEYSTORE_FILE=%s\nANDROID_KEYSTORE_PASSWORD=%s\nANDROID_KEY_ALIAS=%s\nANDROID_KEY_PASSWORD=%s\n' \ - "/root/.android/onionwire-release.jks" "$ANDROID_KEYSTORE_PASSWORD" "$ANDROID_KEY_ALIAS" "$ANDROID_KEY_PASSWORD" > "$envf" - chmod 600 "$envf" - echo "keystore bytes=$(wc -c < "$ks") staged for the build container" - - - name: Ensure docker CLI - run: | - set -euo pipefail - if ! command -v docker >/dev/null 2>&1; then - echo "docker CLI missing in job image; fetching static client" - curl -fsSL "$DOCKER_STATIC_URL" -o /tmp/docker.tgz - tar -xzf /tmp/docker.tgz -C /tmp - install -m 755 /tmp/docker/docker /usr/local/bin/docker - fi - export DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}" - docker version - docker info >/tmp/docker-info.txt - grep -E 'Server Version|Operating System|Total Memory|Name' /tmp/docker-info.txt || true - - - name: Build APK + AAR in bookworm container - id: build - env: - VERSION: ${{ steps.version.outputs.version }} - VERSION_CODE: ${{ steps.version.outputs.version_code }} - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - export DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}" - start=$(date +%s) - cat > .ci-android-build.sh <<'INNER' - #!/usr/bin/env bash - set -euo pipefail - export DEBIAN_FRONTEND=noninteractive - apt-get update - # `cmake` is for RandomX, the C++ half of the in-process chain daemon - # (`cuprate-daemon`, built into the SDK): without it `randomx-rs`'s build - # script panics with "is `cmake` not installed?" and the Gradle task dies - # on "cargo finished with non-zero exit value 101". Same as android-ci.yml. - apt-get install -y --no-install-recommends \ - openjdk-17-jdk-headless python3 unzip curl ca-certificates file build-essential pkg-config git \ - cmake - mkdir -p /root/.android - cp /src/.ci-android/onionwire-release.jks /root/.android/onionwire-release.jks - cp /src/.ci-android/onionwire-release.env /root/.android/onionwire-release.env - chmod 600 /root/.android/onionwire-release.jks /root/.android/onionwire-release.env - # shellcheck disable=SC1091 - set -a - source /root/.android/onionwire-release.env - set +a - if [ ! -x /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager ]; then - mkdir -p /opt/android-sdk/cmdline-tools - curl -fsSL "$ANDROID_CMDLINE_TOOLS_URL" -o /tmp/cmdline-tools.zip - rm -rf /tmp/cmdline-tools - unzip -q /tmp/cmdline-tools.zip -d /tmp/cmdline-tools - mkdir -p /opt/android-sdk/cmdline-tools/latest - cp -a /tmp/cmdline-tools/cmdline-tools/. /opt/android-sdk/cmdline-tools/latest/ - fi - yes | /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=/opt/android-sdk --licenses >/tmp/sdk-licenses.log || true - /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=/opt/android-sdk \ - "platform-tools" "platforms;android-36" "build-tools;36.0.0" "ndk;28.2.13676358" - test -d /opt/android-sdk/ndk/28.2.13676358 - export ANDROID_HOME=/opt/android-sdk ANDROID_SDK_ROOT=/opt/android-sdk - export ANDROID_NDK_HOME=/opt/android-sdk/ndk/28.2.13676358 - export PATH="$ANDROID_HOME/build-tools/36.0.0:$ANDROID_HOME/platform-tools:$PATH" - if [ ! -x /cargo/bin/rustup ]; then - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN" --no-modify-path --profile minimal - fi - export PATH="/cargo/bin:$PATH" - rustup toolchain install "$RUST_TOOLCHAIN" - rustup default "$RUST_TOOLCHAIN" - rustup target add aarch64-linux-android - command -v cargo-ndk >/dev/null || cargo install cargo-ndk --locked - echo "=== toolchain ===" - java -version - rustc --version - cargo ndk --version - du -sh /opt/android-sdk /cargo /cargo-target /gradle || true - find /gradle -name '*.lock' -type f -delete 2>/dev/null || true - export GRADLE_OPTS="${GRADLE_OPTS:-} -Dorg.gradle.parallel=false -Dorg.gradle.daemon=false" - scripts/build-android-local.sh "$ONIONWIRE_VERSION" - version="$ONIONWIRE_VERSION" - abi="${ONIONWIRE_ANDROID_ABI:-arm64-v8a}" - apk="dist/onionwire-$version-android-$abi.apk" - aar="dist/onionwire-sdk-$version.aar" - { - echo "=== file ===" - file "$apk" "$aar" - echo "=== unzip lib ===" - unzip -l "$apk" | grep -E 'lib/.+\.so|AndroidManifest.xml' || true - unzip -l "$apk" | grep "lib/$abi/libonionwire_sdk.so" - echo "=== sha256 ===" - ( cd dist && sha256sum -c "onionwire-$version-android-$abi.apk.sha256" "onionwire-sdk-$version.aar.sha256" ) - echo "=== apksigner ===" - apksigner verify --print-certs "$apk" - echo "=== aapt ===" - aapt dump badging "$apk" | sed -n '1,20p' || true - echo "=== sizes ===" - wc -c "$apk" "$aar" - } | tee dist/ci-verify.log - INNER - chmod +x .ci-android-build.sh - docker volume create "$SDK_VOLUME" >/dev/null - docker volume create "$CARGO_VOLUME" >/dev/null - docker volume create "$TARGET_VOLUME" >/dev/null - docker volume create "$GRADLE_VOLUME" >/dev/null - # Same shared GRADLE_VOLUME as android-ci.yml. A cancelled job leaves - # the build container running and journal-1.lock held. - trap 'docker rm -f "$BUILD_CONTAINER" >/dev/null 2>&1 || true' EXIT - docker ps -aq --filter name=onionwire-android- | xargs -r docker rm -f || true - docker rm -f "$BUILD_CONTAINER" >/dev/null 2>&1 || true - docker pull "$ANDROID_IMAGE" - # 2 GB of Gradle heap, not 1: the only budget in this build that is close - # is the single-use daemon's heap, which now has to package a 55 MB SDK - # lib (plus RandomX's 1.1 MB) through AGP's in-daemon packaging. Run 414 - # died in `:app:packageRelease` with the cause hidden inside - # `PackageAndroidArtifact$IncrementalSplitterRunnable` — no "Caused by" - # line, nothing in the log — so give it room instead of guessing again. - # The runner has 15 GB and the job's peak RSS is ~3 GB. - docker create --name "$BUILD_CONTAINER" -i \ - -e CARGO_TERM_COLOR=never \ - -e CARGO_BUILD_JOBS="$CARGO_BUILD_JOBS" \ - -e CARGO_HOME=/cargo \ - -e CARGO_TARGET_DIR=/cargo-target \ - -e GRADLE_USER_HOME=/gradle \ - -e ANDROID_HOME=/opt/android-sdk \ - -e ANDROID_SDK_ROOT=/opt/android-sdk \ - -e ANDROID_NDK_HOME=/opt/android-sdk/ndk/28.2.13676358 \ - -e ONIONWIRE_ANDROID_ABI="$ONIONWIRE_ANDROID_ABI" \ - -e ONIONWIRE_REQUIRE_RELEASE_KEY=true \ - -e ONIONWIRE_VERSION_CODE="$VERSION_CODE" \ - -e ONIONWIRE_VERSION="$VERSION" \ - -e RUST_TOOLCHAIN="$RUST_TOOLCHAIN" \ - -e ANDROID_CMDLINE_TOOLS_URL="$ANDROID_CMDLINE_TOOLS_URL" \ - -e GRADLE_OPTS="-Dorg.gradle.daemon=false -Dorg.gradle.parallel=false -Dorg.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8" \ - -v "$SDK_VOLUME":/opt/android-sdk \ - -v "$CARGO_VOLUME":/cargo \ - -v "$TARGET_VOLUME":/cargo-target \ - -v "$GRADLE_VOLUME":/gradle \ - -w /src \ - "$ANDROID_IMAGE" \ - bash -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src && bash /src/.ci-android-build.sh' - # Staging dir is included in the tar as .ci-android/ (gitignored paths). - mkdir -p .ci-android - cp "$HOME/.android/onionwire-release.jks" .ci-android/onionwire-release.jks - cp "$HOME/.android/onionwire-release.env" .ci-android/onionwire-release.env - tar czf - \ - --exclude=./target --exclude=./.git --exclude=./.worktrees \ - --exclude=./android/.gradle --exclude=./android/app/build \ - --exclude=./android/sdk/build --exclude=./dist \ - --exclude=./crates/onionwire-sdk/target \ - . \ - | docker start -a -i "$BUILD_CONTAINER" - mkdir -p dist - docker cp "$BUILD_CONTAINER:/src/dist/." dist/ - end=$(date +%s) - echo "build_wall_clock_seconds=$((end - start))" - echo "wall_clock_seconds=$((end - start))" >> "$GITHUB_OUTPUT" - docker rm -f "$BUILD_CONTAINER" >/dev/null || true - rm -rf .ci-android - ls -l dist/ - - - name: Verify artifacts - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - version="${{ steps.version.outputs.version }}" - abi="$ONIONWIRE_ANDROID_ABI" - apk="dist/onionwire-$version-android-$abi.apk" - aar="dist/onionwire-sdk-$version.aar" - [ -s "$apk" ] || { echo "missing or empty $apk" >&2; exit 1; } - [ -s "$aar" ] || { echo "missing or empty $aar" >&2; exit 1; } - apk_bytes=$(wc -c < "$apk") - aar_bytes=$(wc -c < "$aar") - echo "apk_bytes=$apk_bytes aar_bytes=$aar_bytes" - [ "$apk_bytes" -gt 0 ] - [ "$aar_bytes" -gt 0 ] - ( cd dist && sha256sum -c "onionwire-$version-android-$abi.apk.sha256" "onionwire-sdk-$version.aar.sha256" ) - echo "=== ci-verify.log (from bookworm build container) ===" - cat dist/ci-verify.log - echo "=== resources after build ===" - free -h || true - df -h || true - export DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}" - docker images "$ANDROID_IMAGE" --format '{{.Repository}}:{{.Tag}} {{.Size}}' || true - docker system df || true - - - name: Upload dist artifact - uses: https://code.forgejo.org/actions/upload-artifact@v3 - with: - name: onionwire-android - path: dist/ - if-no-files-found: error - retention-days: 1 - - - name: Scrub keystore - if: always() - run: | - set -euo pipefail - rm -rf "$HOME/.android/onionwire-release.jks" "$HOME/.android/onionwire-release.env" .ci-android - echo "keystore removed from runner" - - publish: - needs: android - # Pi runner, not docker-amd64: POST /releases from amd64 dind returns 422 - # with an empty body (core run 116). This job only curls the Forgejo API. - # `always()` is load-bearing on this runner, not decoration. Without it the - # job-level `needs.android.result` gate is evaluated as unset, the job is - # dropped before it is ever created (it does not appear in - # /actions/runs//jobs at all, so it reads as a silent skip), and the APK - # and AAR never reach the release. Run 770 did exactly that: `android` - # green, no `publish` job, eleven assets and no APK. release.yml's publish - # job carries the same prefix for the same reason (run 135). - if: always() && needs.android.result == 'success' && needs.android.outputs.dry_run != 'true' - runs-on: docker - timeout-minutes: 20 - steps: - - name: Checkout CI tooling - uses: https://code.forgejo.org/actions/checkout@v4 - with: - path: .ci-tools - - - name: Download Android dist - uses: https://code.forgejo.org/actions/download-artifact@v3 - with: - path: artifacts - - - name: Publish (create-or-join) - env: - FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} - REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} - EVENT_SHA: ${{ github.sha }} - TAG: ${{ needs.android.outputs.tag }} - VERSION: ${{ needs.android.outputs.version }} - run: | - set -euo pipefail - : "${FORGEJO_TOKEN:?FORGEJO_TOKEN secret is missing}" - echo "publish host=$(hostname) arch=$(uname -m) tag=$TAG version=$VERSION" - mkdir -p dist - abi="$ONIONWIRE_ANDROID_ABI" - apk="onionwire-$VERSION-android-$abi.apk" - aar="onionwire-sdk-$VERSION.aar" - for f in "$apk" "$apk.sha256" "$aar" "$aar.sha256"; do - src=$(find artifacts -type f -name "$f" -print -quit) - if [ -z "$src" ]; then - echo "missing artifact $f" >&2 - find artifacts -type f >&2 || true - exit 1 - fi - cp "$src" "dist/$f" - done - for f in dist/"$apk" dist/"$apk".sha256 dist/"$aar" dist/"$aar".sha256; do - bytes=$(wc -c < "$f") - echo "on disk: $f $bytes bytes" - [ "$bytes" -gt 0 ] || { echo "refusing to publish empty $f" >&2; exit 1; } - file "$f" || true - done - - tag_exists=0 - i=0 - while [ "$i" -lt 6 ]; do - code=$(curl -sS --http1.1 -o /tmp/tag.json -w '%{http_code}' \ - -u "sirius:${FORGEJO_TOKEN}" \ - "$REPO_API/tags/$TAG" || true) - if [ "$code" = "200" ]; then - tag_exists=1 - echo "tag $TAG already exists; joining" - break - fi - i=$((i + 1)) - echo "tag $TAG not found yet (http $code), wait 10s ($i/6)" - sleep 10 - done - - if [ "$tag_exists" = "1" ]; then - unset TARGET_COMMITISH || true - else - export TARGET_COMMITISH="$EVENT_SHA" - echo "creating tag $TAG at $TARGET_COMMITISH" - fi - - echo "publishing $TAG from $REPO_API" - .ci-tools/scripts/publish-release.sh \ - "$TAG" "OnionWire $TAG" \ - .ci-tools/scripts/release-body.md \ - "dist/$apk" \ - "dist/$apk.sha256" \ - "dist/$aar" \ - "dist/$aar.sha256" diff --git a/.forgejo/workflows/arti-watch.yml b/.forgejo/workflows/arti-watch.yml deleted file mode 100644 index 10a0e5f..0000000 --- a/.forgejo/workflows/arti-watch.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: arti-watch - -# Daily upstream check for the in-process Tor stack. Arti onion services are -# experimental (README) and tor-*/arti-* are the largest attack surface here, -# so when crates.io has a newer major.minor than the pins in Cargo.toml this -# files ONE Forgejo issue (deduped on the title — a second run is a no-op). -# -# Forgejo has no Dependabot: this workflow IS the dependency alert. It -# deliberately bumps nothing. A bump is a reviewed PR; the procedure, toolchain -# floor and the tests it must pass are in docs/ARTI_UPGRADE.md. -# -# NOT covered, by design: Tor Project security announcements (a fix that ships -# with no crates.io version bump is invisible here) and a yanked crate / -# vulnerability in a version that has not changed. Read -# https://blog.torproject.org/ yourself. -on: - schedule: - # 06:17 UTC daily. Forgejo cron is UTC; off the hour on purpose. - - cron: "17 6 * * *" - workflow_dispatch: - inputs: - dry_run: - description: Compare and log only, file no issue (true/false) - required: false - type: string - default: "false" - simulate_pin: - description: 'Test the alert path on real crates.io data, e.g. "arti-client=0.45,tor-hsservice=0.45". Empty = the real Cargo.toml pins.' - required: false - type: string - -# Never two watchers at once: two simultaneous runs could both see "no issue -# with this title yet" and file twice. -concurrency: - group: onionwire-arti-watch - cancel-in-progress: false - -jobs: - watch: - # Same Pi runner + `docker` job image as ci.yml / release.yml (which run - # python3 and curl there). No cargo, no docker: four crates.io GETs and at - # most one issue POST. - runs-on: docker - timeout-minutes: 10 - steps: - - name: Checkout - uses: https://code.forgejo.org/actions/checkout@v4 - - - name: Compare pins against crates.io and file an issue on a bump - shell: bash - env: - FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} - REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} - INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }} - INPUT_SIMULATE_PIN: ${{ github.event.inputs.simulate_pin }} - run: | - set -euo pipefail - args=(--cargo-toml Cargo.toml) - case "${INPUT_DRY_RUN:-false}" in - true|True|TRUE|1|yes|YES) args+=(--dry-run) ;; - esac - if [ -n "${INPUT_SIMULATE_PIN:-}" ]; then - IFS=',' read -ra pairs <<< "$INPUT_SIMULATE_PIN" - for pair in "${pairs[@]}"; do - pair="${pair// /}" - if [ -n "$pair" ]; then - args+=(--simulate-pin "$pair") - fi - done - fi - echo "run: python3 scripts/arti-watch.py ${args[*]}" - python3 scripts/arti-watch.py "${args[@]}" diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index fe6fe69..ca59df8 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -2,72 +2,18 @@ name: ci # Tests and clippy run on the Pi runner (aarch64) inside a rust container, so # this CI proves the aarch64 build too. Jobs use the runner's `docker` label. -# -# Path allowlist: skip the cargo job when the change cannot affect the Rust -# build (docs, android, scripts, sibling workflows, markdown). No required -# status checks on main, so a missing run is not a merge trap. -# workflow_dispatch has no path filter — it always runs the suite. -# -# The nightly cargo-fuzz job used to be a third job here. It had its own -# workflow (`.forgejo/workflows/fuzz.yml`, `schedule` only) because a job -# cannot narrow a workflow-level path filter: `fuzz/**` sat in the list -# alongside `src/**` and `crates/**`, so 80 of 84 recorded fuzz runs touched -# nothing in `fuzz/`. on: push: branches: [main] - paths: - - "src/**" - - "crates/**" - - "tests/**" - - "Cargo.toml" - - "Cargo.lock" - - ".forgejo/workflows/ci.yml" pull_request: - paths: - - "src/**" - - "crates/**" - - "tests/**" - - "Cargo.toml" - - "Cargo.lock" - - ".forgejo/workflows/ci.yml" workflow_dispatch: -# One cargo job on the Pi at a time. Overlapping runs share the -# `onionwire-cargo-registry` and `onionwire-target-ci` volumes, and two -# writers to one cargo target dir produce `Permission denied (os error 13)` -# on /target/debug/deps binaries. The per-run container name (below) is no -# longer shared, so the docker Conflict is gone — but the volume race is not, -# and the serialization is what prevents it. -# -# `cancel-in-progress` stays false: cancelling a *queued* run would release -# this group and let the next run start a second cargo job against the same -# volume. Superseded runs are instead skipped by the staleness gate at the -# top of each job, which costs seconds instead of the minutes a full build -# spends proving something nobody will look at. -concurrency: - group: onionwire-ci-pi - cancel-in-progress: false - env: CARGO_TERM_COLOR: never - # Not 1.91. `cuprate-daemon` is a default feature, so `cargo test --locked` - # compiles `tapes`, which calls `VecDeque::pop_front_if` (stable since 1.93). - # On `rust:1.91-bookworm` that is `error[E0658]: use of unstable library - # feature 'vec_deque_pop_if'`, after the job has already built the rest of - # the graph. 1.98 is the release this graph is built with on the dev machine - # and in the Android workflows. `--no-default-features` still builds on 1.91 - # (Arti 0.49's floor); the default build does not, so the image follows the - # default build. - RUST_IMAGE: rust:1.98-bookworm + RUST_IMAGE: rust:1.91-bookworm 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: `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 }} + BUILD_CONTAINER: onionwire-ci jobs: test: @@ -77,40 +23,9 @@ jobs: - name: Checkout uses: https://code.forgejo.org/actions/checkout@v4 - - name: Skip superseded run - id: staleness - run: | - set -uo pipefail - # A force-push, or a merge of another PR, can put a newer commit on - # this branch while this run sits in the concurrency queue above. - # Testing it then proves nothing about the tree that is actually on - # the branch. 279 of 353 runs in a two-week window were on an - # already-superseded sha — the single largest source of wasted Pi - # time, and `cancel-in-progress: true` cannot fix it without letting - # two cargo jobs share the target volume. - # - # For a pull_request, GITHUB_HEAD_REF is the PR's source branch (the - # ref itself is refs/pull/N/merge); for a push it is empty, so fall - # back to GITHUB_REF_NAME. - ref="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:-}}" - remote="" - if [ -n "$ref" ]; then - remote="$(git ls-remote origin "refs/heads/$ref" 2>/dev/null | cut -f1)" - fi - if [ -n "$remote" ] && [ "$remote" != "$GITHUB_SHA" ]; then - echo "::notice::superseded: refs/heads/$ref is at ${remote:0:12}, this run is ${GITHUB_SHA:0:12} — skipping" - echo "skip=true" >> "$GITHUB_OUTPUT" - else - echo "tip=${remote:-unknown} sha=${GITHUB_SHA} ref=${ref:-none} — running" - echo "skip=false" >> "$GITHUB_OUTPUT" - fi - - name: cargo test + clippy on aarch64 - if: steps.staleness.outputs.skip != 'true' run: | set -euo pipefail - cd "${GITHUB_WORKSPACE}" - echo "workspace: $GITHUB_WORKSPACE" docker volume create "$CARGO_REGISTRY_VOLUME" > /dev/null docker volume create "$CARGO_TARGET_VOLUME" > /dev/null docker rm -f "$BUILD_CONTAINER" > /dev/null 2>&1 || true @@ -118,88 +33,16 @@ 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 /target/tmp && tar xzf - -C /src && cd /src \ + sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \ && apt-get update \ - && apt-get install -y --no-install-recommends cmake build-essential \ + && 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' tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees . \ | docker start -a -i "$BUILD_CONTAINER" 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. 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 installs `cmake` and `build-essential` (g++, make) because - # the default feature set includes `cuprate-daemon`. RandomX's build script - # calls cmake; without it the job dies with "is cmake not installed?" (os error 2). - # It still does not install `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 - steps: - - name: Checkout - uses: https://code.forgejo.org/actions/checkout@v4 - - - name: Skip superseded run - id: staleness - run: | - set -uo pipefail - # Same gate as the `test` job above — see the comment there. - ref="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:-}}" - remote="" - if [ -n "$ref" ]; then - remote="$(git ls-remote origin "refs/heads/$ref" 2>/dev/null | cut -f1)" - fi - if [ -n "$remote" ] && [ "$remote" != "$GITHUB_SHA" ]; then - echo "::notice::superseded: refs/heads/$ref is at ${remote:0:12}, this run is ${GITHUB_SHA:0:12} — skipping" - echo "skip=true" >> "$GITHUB_OUTPUT" - else - echo "tip=${remote:-unknown} sha=${GITHUB_SHA} ref=${ref:-none} — running" - echo "skip=false" >> "$GITHUB_OUTPUT" - fi - - - name: cargo test + clippy for crates/onionwire-sdk on aarch64 - if: steps.staleness.outputs.skip != 'true' - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - echo "workspace: $GITHUB_WORKSPACE" - docker volume create "$CARGO_REGISTRY_VOLUME" > /dev/null - docker volume create "$SDK_CARGO_TARGET_VOLUME" > /dev/null - docker rm -f "$SDK_BUILD_CONTAINER" > /dev/null 2>&1 || true - docker create --name "$SDK_BUILD_CONTAINER" -i \ - -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 \ - "$RUST_IMAGE" \ - sh -euxc 'mkdir -p /src /target/tmp && tar xzf - -C /src && cd /src/crates/onionwire-sdk \ - && 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' - tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees \ - --exclude=./crates/onionwire-sdk/target . \ - | docker start -a -i "$SDK_BUILD_CONTAINER" - docker rm -f "$SDK_BUILD_CONTAINER" > /dev/null diff --git a/.forgejo/workflows/fuzz.yml b/.forgejo/workflows/fuzz.yml deleted file mode 100644 index ba63eee..0000000 --- a/.forgejo/workflows/fuzz.yml +++ /dev/null @@ -1,99 +0,0 @@ -name: fuzz - -# 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 else in CI compiles this crate, so the targets bit-rot silently. -# -# This used to be a job in `ci.yml`, which meant it inherited that workflow's -# PR path filter (`src/**`, `crates/**`, `tests/**`, `Cargo.lock`, …) and ran -# on almost every push: 80 of 84 recorded runs touched neither `fuzz/` nor -# `scripts/run-fuzz.sh`. Each one also paid `rustup toolchain install nightly` -# plus `cargo install cargo-fuzz --locked` before it could do 15 seconds of -# fuzzing. Bit-rot is a slow signal; a PR gate is the wrong shape for it. -# -# It is a scheduled job now. `workflow_dispatch` is the manual escape hatch -# (a parser change deserves a longer run than the 15s below — raise FUZZ_SECS -# in the dispatch env for that). -on: - schedule: - # 03:30 UTC nightly. Forgejo cron is UTC; off the hour on purpose so it - # does not pile onto the 06:17 arti-watch slot. - - cron: "30 3 * * *" - workflow_dispatch: - -# Never two fuzz runs at once: they hold the shared fuzz registry and target -# volumes, and a second one is a `docker Conflict` plus a cold rebuild. -concurrency: - group: onionwire-ci-pi-fuzz - cancel-in-progress: false - -env: - CARGO_TERM_COLOR: never - # Base image only: the job switches to nightly before it compiles. Kept on - # the same tag as ci.yml so a step that forgets `+nightly` does not die in - # `tapes` on 1.91 (`VecDeque::pop_front_if`). - RUST_IMAGE: rust:1.98-bookworm - # The build needs a release profile + debug=line-tables-only, so 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 - # Per-build CPU budget. The Pi has 4 cores shared with whatever CI run is - # live, so 2 is what leaves headroom. - FUZZ_SECS: "15" - FUZZ_JOBS: "2" - -jobs: - build: - runs-on: docker - timeout-minutes: 120 - steps: - - name: Checkout - uses: https://code.forgejo.org/actions/checkout@v4 - - - name: build + run fuzz targets - 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 - # Build AND run in ONE container. Splitting them into two - # `docker create` calls gives the second one a fresh image, and the - # cargo-fuzz binary installed in the first is gone with it - # (PR #106 fixed this; PR #106/#107 added the PATH export too). - 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="$FUZZ_SECS" \ - -e FUZZ_JOBS="$FUZZ_JOBS" \ - -v "$FUZZ_REGISTRY_VOLUME":/usr/local/cargo/registry \ - -v "$FUZZ_TARGET_VOLUME":/target \ - -w /src \ - "$RUST_IMAGE" \ - sh -euxc 'mkdir -p /src /target/tmp && tar xzf - -C /src && cd /src \ - && apt-get update \ - && apt-get install -y --no-install-recommends pkg-config libssl-dev cmake build-essential \ - && 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 \ - && bash /src/scripts/run-fuzz.sh' - # A fresh Docker volume has no tmp/ subdirectory, and rustup fails - # with "error creating temp directory: No such file or directory" if - # TMPDIR points into one that does not exist yet. - tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees . \ - | docker start -a -i "$FUZZ_BUILD_CONTAINER" - docker rm -f "$FUZZ_BUILD_CONTAINER" > /dev/null diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index d625d19..ce85219 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -1,620 +1,92 @@ name: release -# Manual, batched releases. There is deliberately NO push trigger: a merged -# PR does not mint a release. A maintainer dispatches this at a stopping point -# (a batch of work has landed and CI is green on main) — see docs/RELEASING.md. -# Tag-push is intentionally NOT a trigger here: this workflow creates the tag -# via the API, and a tag-push hook would start a second run of the same release. -# (A tag this workflow creates does not wake android-release.yml either — see -# docs/RELEASING.md: on this Forgejo, pushes made with the CI token are -# Actions-user events and are not dispatched back into Actions.) -# Version: explicit `version`, else `bump` off the newest v*.*.* tag -# (default minor — a batched release is usually a feature set); zero tags → v0.1.0. +# Native aarch64 build on the Pi runner, published to the Forgejo release. +# x86_64 is NOT built here: there is no x86_64 runner on this instance — build +# it on an x86_64 host with scripts/build-release-local.sh (same release, same +# asset naming), or the release will carry aarch64 only. on: + push: + tags: + - "v*.*.*" workflow_dispatch: inputs: - bump: - description: Bump off the newest v*.*.* tag (ignored when version or tag is set) - required: false - type: choice - options: - - minor - - patch - - major - default: minor - version: - description: Explicit version MAJOR.MINOR.PATCH (or vMAJOR.MINOR.PATCH); overrides bump - required: false - type: string tag: - description: Existing tag to (re)build and publish (empty = create the next version) - required: false - type: string - dry_run: - description: Build and checksum without creating a tag or publishing (true/false) - required: false - type: string - default: "false" - -# Same group as ci.yml: both cargo builds share the Pi's 4 cores and the -# onionwire-cargo-registry volume. A separate group raced tests and produced -# Permission denied (os error 13) on /target/debug/deps/* binaries. -concurrency: - group: onionwire-ci-pi - cancel-in-progress: false + description: Existing tag to (re)build and publish + required: true env: CARGO_TERM_COLOR: never - # Same floor as ci.yml: the release binary has `cuprate-daemon` on by default, - # and `tapes` does not build on 1.91 (`VecDeque::pop_front_if`, stable in 1.93). - # Pinned by DIGEST, not by tag. `rust:1.98-bookworm` floats: a rustc patch - # release changes codegen and therefore every published hash — which turns a - # routine toolchain bump into an unexplainable reproducibility mismatch for - # anyone verifying an old release. rustc in this digest is 1.98.1 - # (48a229cea), LLVM 21.1.2, host x86_64-unknown-linux-gnu. 1.98 is the floor - # for the default feature set (see Cargo.toml rust-version). - # - # This digest IS the release recipe, and it must match BUILDER_IMAGE in - # scripts/verify-reproducible.sh and scripts/build-release-local.sh. If they - # disagree, a verifier rebuilds with a different toolchain than CI shipped and - # reports a false mismatch. Bump all of them in one commit — docs/VERIFY.md. - RUST_IMAGE: rust@sha256:93ce27a88655056a51dbdd8f5f2d7ddc071c7b0070fb288a37b5a285fc83971e - # Not baking pkg-config/libssl-dev into a custom image on this card — - # dind PVC would make that the durable fix for the apt loop. Filed separately. + TARGET: aarch64-unknown-linux-gnu + # Job steps run inside node:20-bullseye (the runner's docker label image) with + # the host docker socket mounted, so builds happen in a sibling rust container. + RUST_IMAGE: rust:1.91-bookworm CARGO_REGISTRY_VOLUME: onionwire-cargo-registry + CARGO_TARGET_VOLUME: onionwire-target-aarch64 + BUILD_CONTAINER: onionwire-release-build jobs: - version: - runs-on: docker - timeout-minutes: 10 - outputs: - tag: ${{ steps.plan.outputs.tag }} - sha: ${{ steps.plan.outputs.sha }} - dry_run: ${{ steps.plan.outputs.dry_run }} - created_tag: ${{ steps.plan.outputs.created_tag }} - steps: - - name: Plan version, create tag unless dry_run - id: plan - env: - FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} - REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} - EVENT_NAME: ${{ github.event_name }} - EVENT_SHA: ${{ github.sha }} - INPUT_BUMP: ${{ github.event.inputs.bump }} - INPUT_VERSION: ${{ github.event.inputs.version }} - INPUT_TAG: ${{ github.event.inputs.tag }} - INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }} - run: | - set -euo pipefail - : "${FORGEJO_TOKEN:?FORGEJO_TOKEN secret is not set}" - FORGEJO_TOKEN=$(printf '%s' "$FORGEJO_TOKEN" | tr -d '\r\n') - dry_run=false - if [ "$EVENT_NAME" = "workflow_dispatch" ]; then - case "${INPUT_DRY_RUN:-false}" in - true|True|TRUE|1|yes|YES) dry_run=true ;; - esac - fi - echo "event=$EVENT_NAME sha=$EVENT_SHA input_version=${INPUT_VERSION-} input_tag=${INPUT_TAG-} input_bump=${INPUT_BUMP-} input_dry_run=${INPUT_DRY_RUN-} dry_run=$dry_run" - - api_curl() { - curl -sS --http1.1 --retry 5 --retry-all-errors --retry-delay 3 \ - --connect-timeout 20 --max-time 60 \ - -u "sirius:${FORGEJO_TOKEN}" "$@" | sed 's/\r$//' - } - - input_tag="${INPUT_TAG:-}" - version_input="${INPUT_VERSION:-}" - bump="${INPUT_BUMP:-minor}" - # Contradictory input is rejected, never guessed at. - if [ -n "$input_tag" ] && [ -n "$version_input" ]; then - echo "got both tag='$input_tag' and version='$version_input': tag rebuilds an existing tag, version mints a new one — pass one" >&2 - exit 1 - fi - if [ -n "$input_tag" ]; then - code=$(api_curl -o /tmp/tag.json -w '%{http_code}' \ - "$REPO_API/tags/$input_tag") - if [ "$code" != "200" ]; then - echo "dispatch tag $input_tag not found (HTTP $code)" >&2 - cat /tmp/tag.json >&2 || true - exit 1 - fi - sha=$(python3 -c "import json; print(json.load(open('/tmp/tag.json'))['commit']['sha'])") - tag="$input_tag" - created=false - echo "re-publish existing tag $tag at $sha (dry_run=$dry_run)" - else - if [ -n "$version_input" ]; then - tag=$(python3 -c "import re,sys; m=re.fullmatch(r'v?([0-9]+)\.([0-9]+)\.([0-9]+)', sys.argv[1].strip()); print('v' + '.'.join(m.groups()) if m else '')" "$version_input") - if [ -z "$tag" ]; then - echo "version must be MAJOR.MINOR.PATCH or vMAJOR.MINOR.PATCH, got '$version_input'" >&2 - exit 1 - fi - else - case "$bump" in - patch|minor|major) ;; - *) echo "bump must be patch|minor|major, got '$bump'" >&2; exit 1 ;; - esac - api_curl "$REPO_API/tags?limit=50" -o /tmp/tags.json - latest=$(python3 -c "import json,re; tags=json.load(open('/tmp/tags.json')); assert isinstance(tags, list), tags; s=[tuple(int(x) for x in m.groups()) for t in tags for m in [re.fullmatch(r'v([0-9]+)\.([0-9]+)\.([0-9]+)', t.get('name') or '')] if m]; print('%d.%d.%d' % max(s) if s else '')") - if [ -z "$latest" ]; then - tag="v0.1.0" - else - major="${latest%%.*}" - rest="${latest#*.}" - minor="${rest%%.*}" - patch="${rest#*.}" - case "$bump" in - major) tag="v$((major + 1)).0.0" ;; - minor) tag="v$major.$((minor + 1)).0" ;; - patch) tag="v$major.$minor.$((patch + 1))" ;; - esac - fi - fi - sha="$EVENT_SHA" - created=false - if [ "$dry_run" = "true" ]; then - echo "dry_run: would use $tag on $sha (no tag created)" - else - code=$(api_curl -o /tmp/tag.json -w '%{http_code}' \ - "$REPO_API/tags/$tag") - if [ "$code" = "200" ]; then - existing=$(python3 -c "import json; print(json.load(open('/tmp/tag.json'))['commit']['sha'])") - if [ "$existing" != "$sha" ]; then - echo "tag $tag exists on $existing, not moving from $sha" >&2 - exit 1 - fi - echo "tag $tag already exists on $sha — joining" - elif [ "$code" = "404" ]; then - python3 -c "import json,sys; json.dump({'tag_name':sys.argv[1],'target':sys.argv[2],'message':'OnionWire '+sys.argv[1]}, sys.stdout)" \ - "$tag" "$sha" > /tmp/tag-create.json - echo "tag-create payload $(wc -c < /tmp/tag-create.json) bytes" - create_code=$(api_curl -o /tmp/tag-created.json -w '%{http_code}' \ - -X POST -H "Content-Type: application/json" \ - --data-binary @/tmp/tag-create.json \ - "$REPO_API/tags") - if [ "$create_code" = "201" ]; then - created=true - echo "created tag $tag on $sha" - elif [ "$create_code" = "409" ]; then - echo "tag $tag created concurrently — joining" - else - echo "creating tag $tag failed HTTP $create_code" >&2 - cat /tmp/tag-created.json >&2 || true - exit 1 - fi - else - echo "GET tags/$tag failed HTTP $code" >&2 - cat /tmp/tag.json >&2 || true - exit 1 - fi - fi - fi - - echo "tag=$tag" >> "$GITHUB_OUTPUT" - echo "sha=$sha" >> "$GITHUB_OUTPUT" - echo "dry_run=$dry_run" >> "$GITHUB_OUTPUT" - echo "created_tag=$created" >> "$GITHUB_OUTPUT" - echo "plan: tag=$tag sha=$sha dry_run=$dry_run created_tag=$created" - aarch64: - needs: version runs-on: docker timeout-minutes: 120 - env: - TARGET: aarch64-unknown-linux-gnu - # Per-run, and removed at the end of the job: a reused target dir lets the - # published binary come out of cached artifacts, which is precisely what a - # verifier rebuilding from an empty directory cannot reproduce. - CARGO_TARGET_VOLUME: onionwire-target-release-${{ github.run_id }}-aarch64 - BUILD_CONTAINER: onionwire-release-${{ github.run_id }}-aarch64 steps: - - name: Checkout source + - name: Checkout uses: https://code.forgejo.org/actions/checkout@v4 with: - ref: ${{ needs.version.outputs.sha }} + # A tag push builds that tag; a manual dispatch builds the tag the + # caller named (otherwise the binary version would not match the + # release it is attached to). + ref: ${{ github.event.inputs.tag || github.ref_name }} - - name: Show runner arch - run: uname -m && echo "target=$TARGET" - - - name: Resolve SOURCE_DATE_EPOCH from the released commit - id: epoch + - name: Build ${{ env.TARGET }} in a rust container run: | set -euo pipefail - cd "${GITHUB_WORKSPACE}" - # The released commit's committer time, not "now". A rebuild of this - # tag in six months has to hand the compiler the same epoch CI handed - # it, or the two builds cannot match and every verification is noise. - epoch=$(git log -1 --format=%ct "${{ needs.version.outputs.sha }}") - case "$epoch" in - ''|*[!0-9]*) echo "could not read a commit time for ${{ needs.version.outputs.sha }}" >&2; exit 1 ;; - esac - echo "epoch=$epoch" >> "$GITHUB_OUTPUT" - echo "SOURCE_DATE_EPOCH=$epoch" - - - name: Build ${{ env.TARGET }} in the pinned rust container - env: - SOURCE_DATE_EPOCH: ${{ steps.epoch.outputs.epoch }} - RELEASE_SHA: ${{ needs.version.outputs.sha }} - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - echo "workspace: $GITHUB_WORKSPACE" docker volume create "$CARGO_REGISTRY_VOLUME" > /dev/null - # Fresh per run (see the job env): the published artifact has to be - # reproducible from an empty target dir, so it is not allowed to come - # out of a cache that a verifier does not have. docker volume create "$CARGO_TARGET_VOLUME" > /dev/null docker rm -f "$BUILD_CONTAINER" > /dev/null 2>&1 || true + # The workspace lives in a per-task volume the host daemon cannot + # resolve, so pipe the source tree in over stdin (tar) and pull the + # binary back out with docker cp. docker create --name "$BUILD_CONTAINER" -i \ -e CARGO_TARGET_DIR=/target \ -e CARGO_BUILD_JOBS=2 \ -e CARGO_TERM_COLOR=never \ - -e SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \ - -e BUILDER_IMAGE="$RUST_IMAGE" \ - -e TARGET_TRIPLE="$TARGET" \ - -e GIT_SHA="$RELEASE_SHA" \ - -e OUT=/out \ -v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \ -v "$CARGO_TARGET_VOLUME":/target \ -w /src \ "$RUST_IMAGE" \ - sh -euxc 'mkdir -p /src /out && tar xzf - -C /src && cd /src && bash /src/scripts/reproducible-build.sh' - tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees \ - --exclude=./.ci-tools . \ + 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 \ + && cargo build --release --locked \ + && strip /target/release/onionwire \ + && ls -l /target/release/onionwire' + tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees . \ | docker start -a -i "$BUILD_CONTAINER" mkdir -p dist - # The recipe writes the stripped binary, its .sha256 and the build-info - # record into /out, and installs its own apt build deps — the caller - # supplies only the source tree and the pinned epoch. - docker cp "$BUILD_CONTAINER:/out/." dist/ + docker cp "$BUILD_CONTAINER:/target/release/onionwire" "dist/onionwire-$TARGET" docker rm -f "$BUILD_CONTAINER" > /dev/null - docker volume rm "$CARGO_TARGET_VOLUME" > /dev/null - - name: Verify the recipe's dist output + - name: Pack and checksum run: | set -euo pipefail - cd "${GITHUB_WORKSPACE}/dist" - ls -l - # scripts/reproducible-build.sh owns the checksum and the build-info - # record. This step only refuses to hand a half-made dist to publish. - for f in "onionwire-$TARGET" "onionwire-$TARGET.sha256" "build-info-$TARGET.txt"; do - if [ ! -s "$f" ]; then - echo "missing or empty dist asset: $f" >&2 - exit 1 - fi - done - sha256sum -c "onionwire-$TARGET.sha256" + cd dist file "onionwire-$TARGET" - cat "build-info-$TARGET.txt" - - - name: Upload dist artifact - uses: https://code.forgejo.org/actions/upload-artifact@v3 - with: - name: onionwire-aarch64-unknown-linux-gnu - path: dist/ - if-no-files-found: error - retention-days: 1 - - x86_64: - needs: version - runs-on: docker-amd64 - timeout-minutes: 120 - env: - TARGET: x86_64-unknown-linux-gnu - # Per-run, and removed at the end of the job: a reused target dir lets the - # published binary come out of cached artifacts, which is precisely what a - # verifier rebuilding from an empty directory cannot reproduce. - CARGO_TARGET_VOLUME: onionwire-target-release-${{ github.run_id }}-x86_64 - BUILD_CONTAINER: onionwire-release-${{ github.run_id }}-x86_64 - steps: - - name: Checkout source - uses: https://code.forgejo.org/actions/checkout@v4 - with: - ref: ${{ needs.version.outputs.sha }} - - - name: Show runner arch - run: uname -m && echo "target=$TARGET" - - - name: Ensure docker CLI (amd64 dind job image has none) - run: | - set -euo pipefail - if ! command -v docker >/dev/null 2>&1; then - curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-27.3.1.tgz \ - | tar xz -C /tmp - install -m 755 /tmp/docker/docker /usr/local/bin/docker - fi - docker version - if [ ! -S /var/run/docker.sock ]; then - echo "docker.sock is not mounted into the job container" >&2 - ls -l /var/run || true - exit 1 - fi - - - name: Resolve SOURCE_DATE_EPOCH from the released commit - id: epoch - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - # The released commit's committer time, not "now". A rebuild of this - # tag in six months has to hand the compiler the same epoch CI handed - # it, or the two builds cannot match and every verification is noise. - epoch=$(git log -1 --format=%ct "${{ needs.version.outputs.sha }}") - case "$epoch" in - ''|*[!0-9]*) echo "could not read a commit time for ${{ needs.version.outputs.sha }}" >&2; exit 1 ;; - esac - echo "epoch=$epoch" >> "$GITHUB_OUTPUT" - echo "SOURCE_DATE_EPOCH=$epoch" - - - name: Build ${{ env.TARGET }} in the pinned rust container - env: - SOURCE_DATE_EPOCH: ${{ steps.epoch.outputs.epoch }} - RELEASE_SHA: ${{ needs.version.outputs.sha }} - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}" - echo "workspace: $GITHUB_WORKSPACE" - docker volume create "$CARGO_REGISTRY_VOLUME" > /dev/null - # Fresh per run (see the job env): the published artifact has to be - # reproducible from an empty target dir, so it is not allowed to come - # out of a cache that a verifier does not have. - docker volume create "$CARGO_TARGET_VOLUME" > /dev/null - docker rm -f "$BUILD_CONTAINER" > /dev/null 2>&1 || true - docker create --name "$BUILD_CONTAINER" -i \ - -e CARGO_TARGET_DIR=/target \ - -e CARGO_BUILD_JOBS=2 \ - -e CARGO_TERM_COLOR=never \ - -e SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \ - -e BUILDER_IMAGE="$RUST_IMAGE" \ - -e TARGET_TRIPLE="$TARGET" \ - -e GIT_SHA="$RELEASE_SHA" \ - -e OUT=/out \ - -v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \ - -v "$CARGO_TARGET_VOLUME":/target \ - -w /src \ - "$RUST_IMAGE" \ - sh -euxc 'mkdir -p /src /out && tar xzf - -C /src && cd /src && bash /src/scripts/reproducible-build.sh' - tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees \ - --exclude=./.ci-tools . \ - | docker start -a -i "$BUILD_CONTAINER" - mkdir -p dist - # The recipe writes the stripped binary, its .sha256 and the build-info - # record into /out, and installs its own apt build deps — the caller - # supplies only the source tree and the pinned epoch. - docker cp "$BUILD_CONTAINER:/out/." dist/ - docker rm -f "$BUILD_CONTAINER" > /dev/null - docker volume rm "$CARGO_TARGET_VOLUME" > /dev/null - - - name: Verify the recipe's dist output - run: | - set -euo pipefail - cd "${GITHUB_WORKSPACE}/dist" - ls -l - # scripts/reproducible-build.sh owns the checksum and the build-info - # record. This step only refuses to hand a half-made dist to publish. - for f in "onionwire-$TARGET" "onionwire-$TARGET.sha256" "build-info-$TARGET.txt"; do - if [ ! -s "$f" ]; then - echo "missing or empty dist asset: $f" >&2 - exit 1 - fi - done + sha256sum "onionwire-$TARGET" > "onionwire-$TARGET.sha256" sha256sum -c "onionwire-$TARGET.sha256" - file "onionwire-$TARGET" - cat "build-info-$TARGET.txt" + ls -l - - name: Upload dist artifact - uses: https://code.forgejo.org/actions/upload-artifact@v3 - with: - name: onionwire-x86_64-unknown-linux-gnu - path: dist/ - if-no-files-found: error - retention-days: 1 - - publish: - needs: [version, aarch64, x86_64] - # Always run after version so a failed build still hits the fail-closed - # delete step (a skipped publish left act without a job result). - # Pi runner, not docker-amd64: the amd64 dind runner is capacity=1 and - # android-release sat in front of run 116's publish for ~1h; the Pi - # already created the tag over the public API (version job), so publish - # uses that same path. This job needs the docker CLI for one thing only — - # running scripts/sign-release.sh in the pinned builder image — and it uses - # a named volume + docker cp, never a bind mount of $GITHUB_WORKSPACE - # (that path exists only inside this container; docker resolves a -v source - # on the host and hands the container an empty /work — run 768). - # Fail-closed tag delete lives as a step here: a sibling cleanup job ran - # after a successful publish (act treats needs.publish.result as unset, so - # != success) and Early-terminated on run 135. Do not restore that job. - if: always() && needs.version.result == 'success' - runs-on: docker - timeout-minutes: 20 - steps: - - name: Skip publish on dry_run - if: needs.version.outputs.dry_run == 'true' - run: echo "dry_run not publishing" - - - name: Fail closed if a build failed - if: needs.version.outputs.dry_run != 'true' && (needs.aarch64.result != 'success' || needs.x86_64.result != 'success') - run: | - echo "aarch64=${{ needs.aarch64.result }} x86_64=${{ needs.x86_64.result }}" >&2 - exit 1 - - - name: Checkout CI tooling - if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success' - uses: https://code.forgejo.org/actions/checkout@v4 - with: - path: .ci-tools - - - name: Download both arch artifacts - if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success' - uses: https://code.forgejo.org/actions/download-artifact@v3 - with: - path: artifacts - - - name: Stage both arch artifacts into dist - if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success' - run: | - set -euo pipefail - # Everything the signer signs must already be in dist/ when the sign - # step runs. This loop used to live inside the publish step, i.e. - # AFTER the signature step, so signing ran against an empty dist/. - mkdir -p dist - find artifacts -type f -print - for target in aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do - for name in "onionwire-$target" "onionwire-$target.sha256" "build-info-$target.txt"; do - src=$(find artifacts -type f -name "$name" -print -quit) - if [ -z "$src" ]; then - echo "missing artifact: $name" >&2 - find artifacts -type f >&2 || true - exit 1 - fi - cp "$src" "dist/$name" - done - done - ls -l dist - - - name: Sign the release assets (minisign, fail closed) - if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success' - env: - MINISIGN_SECRET_KEY: ${{ secrets.MINISIGN_SECRET_KEY }} - RELEASE_TAG: ${{ needs.version.outputs.tag }} - SIGN_VOLUME: onionwire-sign-${{ github.run_id }} - SIGN_CONTAINER: onionwire-sign-${{ github.run_id }} - run: | - set -euo pipefail - # Signing runs BEFORE publish on purpose. A run without the key stops - # here, so nothing unsigned ever reaches the release page: an unsigned - # release is indistinguishable from a signed one to anyone who is not - # checking, which makes it worse than no release at all. - if [ -z "${MINISIGN_SECRET_KEY:-}" ]; then - echo "MINISIGN_SECRET_KEY is not set — add it in Settings -> Actions -> Secrets." >&2 - echo "See docs/VERIFY.md, \"Maintainer: the signing key\"." >&2 - exit 1 - fi - # NO `-v "${GITHUB_WORKSPACE}:/work"`: GITHUB_WORKSPACE is a path - # INSIDE this job container, but docker resolves a bind mount's source - # on the HOST, where it does not exist. Docker then creates an empty - # /work and the sign script is simply absent (run 768: "bash: - # .ci-tools/scripts/sign-release.sh: No such file or directory"). - # Same pattern as the build jobs: named volume + docker cp in/out. - # minisign still comes from the same pinned image the builds used, so - # our signature and the verifier's check are the same implementation. - cleanup() { - docker rm -f "$SIGN_CONTAINER" >/dev/null 2>&1 || true - docker volume rm "$SIGN_VOLUME" >/dev/null 2>&1 || true - } - trap cleanup EXIT - docker volume create "$SIGN_VOLUME" >/dev/null - docker rm -f "$SIGN_CONTAINER" >/dev/null 2>&1 || true - docker create --name "$SIGN_CONTAINER" \ - -e MINISIGN_SECRET_KEY \ - -e RELEASE_TAG \ - -v "$SIGN_VOLUME:/work" \ - -w /work \ - "$RUST_IMAGE" \ - bash -c 'apt-get update -qq && apt-get install -y -qq --no-install-recommends minisign >/dev/null \ - && bash /work/scripts/sign-release.sh \ - /work/dist/onionwire-aarch64-unknown-linux-gnu \ - /work/dist/onionwire-aarch64-unknown-linux-gnu.sha256 \ - /work/dist/onionwire-x86_64-unknown-linux-gnu \ - /work/dist/onionwire-x86_64-unknown-linux-gnu.sha256' - docker cp .ci-tools/scripts "$SIGN_CONTAINER:/work/scripts" - docker cp dist/. "$SIGN_CONTAINER:/work/dist/" - docker start -a "$SIGN_CONTAINER" - docker cp "$SIGN_CONTAINER:/work/dist/." dist/ - # Verify the signatures came back out before anything is published. - for f in \ - dist/onionwire-aarch64-unknown-linux-gnu.minisig \ - dist/onionwire-aarch64-unknown-linux-gnu.sha256.minisig \ - dist/onionwire-x86_64-unknown-linux-gnu.minisig \ - dist/onionwire-x86_64-unknown-linux-gnu.sha256.minisig - do - [ -s "$f" ] || { echo "signing produced no $f" >&2; exit 1; } - done - # The public key ships as an asset too, so a verifier can get it from - # the release; getting it from the repo instead is stronger, and - # docs/VERIFY.md says so. - cp .ci-tools/scripts/onionwire-signing.pub dist/onionwire-signing.pub - - - name: Publish both binaries to one release - if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success' + - name: Publish to the Forgejo release env: FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} + TARGET_COMMITISH: ${{ github.sha }} REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} - TAG: ${{ needs.version.outputs.tag }} + REF: ${{ github.ref_name }} + INPUT_TAG: ${{ github.event.inputs.tag }} run: | set -euo pipefail - # dist/ is staged and signed by the two steps above; this step only - # refuses to upload a hole in it. - find dist -type f -print - missing=0 - for f in \ - dist/onionwire-aarch64-unknown-linux-gnu \ - dist/onionwire-aarch64-unknown-linux-gnu.sha256 \ - dist/onionwire-aarch64-unknown-linux-gnu.minisig \ - dist/onionwire-aarch64-unknown-linux-gnu.sha256.minisig \ - dist/build-info-aarch64-unknown-linux-gnu.txt \ - dist/onionwire-x86_64-unknown-linux-gnu \ - dist/onionwire-x86_64-unknown-linux-gnu.sha256 \ - dist/onionwire-x86_64-unknown-linux-gnu.minisig \ - dist/onionwire-x86_64-unknown-linux-gnu.sha256.minisig \ - dist/build-info-x86_64-unknown-linux-gnu.txt \ - dist/onionwire-signing.pub - do - if [ ! -s "$f" ]; then - echo "refusing to publish missing or empty asset $f" >&2 - missing=1 - continue - fi - bytes=$(wc -c < "$f") - echo "on disk: $f $bytes bytes" - file "$f" || true - done - if [ "$missing" -ne 0 ]; then - exit 1 - fi - echo "publishing $TAG from $REPO_API" - .ci-tools/scripts/publish-release.sh \ - "$TAG" "OnionWire $TAG" \ - .ci-tools/scripts/release-body.md \ - dist/onionwire-aarch64-unknown-linux-gnu \ - dist/onionwire-aarch64-unknown-linux-gnu.sha256 \ - dist/onionwire-aarch64-unknown-linux-gnu.minisig \ - dist/onionwire-aarch64-unknown-linux-gnu.sha256.minisig \ - dist/build-info-aarch64-unknown-linux-gnu.txt \ - dist/onionwire-x86_64-unknown-linux-gnu \ - dist/onionwire-x86_64-unknown-linux-gnu.sha256 \ - dist/onionwire-x86_64-unknown-linux-gnu.minisig \ - dist/onionwire-x86_64-unknown-linux-gnu.sha256.minisig \ - dist/build-info-x86_64-unknown-linux-gnu.txt \ - dist/onionwire-signing.pub - - - name: Delete tag we created if this job failed - if: failure() && needs.version.outputs.created_tag == 'true' && needs.version.outputs.dry_run != 'true' - env: - FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} - REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} - TAG: ${{ needs.version.outputs.tag }} - run: | - set -euo pipefail - FORGEJO_TOKEN=$(printf '%s' "$FORGEJO_TOKEN" | tr -d '\r\n') - echo "fail-closed: removing tag $TAG created by this run" - code=$(curl -sS --http1.1 -o /tmp/rel.json -w '%{http_code}' \ - -u "sirius:${FORGEJO_TOKEN}" \ - "$REPO_API/releases/tags/$TAG") - if [ "$code" = "200" ]; then - rid=$(python3 -c "import json; print(json.load(open('/tmp/rel.json'))['id'])") - echo "deleting incomplete release id $rid" - curl -sS --http1.1 -X DELETE \ - -u "sirius:${FORGEJO_TOKEN}" \ - "$REPO_API/releases/$rid" -o /dev/null -w "DELETE release HTTP %{http_code}\n" - else - echo "no release for $TAG (HTTP $code)" - fi - del=$(curl -sS --http1.1 -o /tmp/tag-del.json -w '%{http_code}' -X DELETE \ - -u "sirius:${FORGEJO_TOKEN}" \ - "$REPO_API/tags/$TAG") - echo "DELETE tag HTTP $del" - if [ "$del" != "204" ] && [ "$del" != "404" ]; then - cat /tmp/tag-del.json >&2 || true - exit 1 - fi + tag="${INPUT_TAG:-$REF}" + echo "publishing $tag from $REPO_API" + scripts/publish-release.sh \ + "$tag" "OnionWire $tag" \ + scripts/release-body.md \ + "dist/onionwire-$TARGET" "dist/onionwire-$TARGET.sha256" diff --git a/.gitignore b/.gitignore index dca8ac8..4f96631 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,2 @@ /target /dist -/.worktrees/ - -# Machine-local Android build config. sdk.dir/ndk.dir are absolute paths to -# whatever the developer has installed — never commit them. -/.android-env.sh -android/local.properties -android/.cargo/ - -# Gradle / Android build output -android/.gradle/ -android/build/ -android/app/build/ -android/sdk/build/ - -# Rust: the SDK is its own Cargo workspace -crates/onionwire-sdk/target/ diff --git a/Cargo.lock b/Cargo.lock index 443af58..f983937 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,18 +125,6 @@ dependencies = [ "libc", ] -[[package]] -name = "anstyle" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" - -[[package]] -name = "anyhow" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" - [[package]] name = "approx" version = "0.5.1" @@ -146,27 +134,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "arc-swap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c049c0be4daef0b145cb3555416b3b8ef5b7888a38aea1a3a155801fe7b0810b" -dependencies = [ - "rustversion", -] - -[[package]] -name = "argon2" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072" -dependencies = [ - "base64ct", - "blake2", - "cpufeatures 0.2.17", - "password-hash", -] - [[package]] name = "arrayvec" version = "0.7.8" @@ -175,9 +142,9 @@ checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" [[package]] name = "arti-client" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b3624d7bee91f821b04fe5412f561671e5500677781d3f070a2fa101a128b0" +checksum = "aafcbc506657d886b27ef2d8e06a99edd9014b28130c798a3013935b46983097" dependencies = [ "async-trait", "cfg-if", @@ -193,9 +160,10 @@ dependencies = [ "libc", "once_cell", "postage", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", + "tempfile", "thiserror 2.0.20", "time", "tor-async-utils", @@ -256,7 +224,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.119", - "synstructure 0.13.2", + "synstructure", ] [[package]] @@ -271,10 +239,16 @@ dependencies = [ ] [[package]] -name = "async-compression" -version = "0.4.54" +name = "assert_matches" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c31224bd2c09447484a1143f2fc1d871eb405789859c8e5470a3e7f95f40a18" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + +[[package]] +name = "async-compression" +version = "0.4.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f10dafd0c8d2e51ae9a748805777613ed0bbe17bf586b76c8311f45c020a32f" dependencies = [ "compression-codecs", "compression-core", @@ -348,66 +322,12 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - [[package]] name = "autocfg" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" -[[package]] -name = "axum" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90" -dependencies = [ - "axum-core", - "bytes", - "futures-util", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-util", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "serde_core", - "serde_json", - "serde_path_to_error", - "sync_wrapper", - "tokio", - "tower", - "tower-layer", - "tower-service", -] - -[[package]] -name = "axum-core" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" -dependencies = [ - "bytes", - "futures-core", - "http", - "http-body", - "http-body-util", - "mime", - "pin-project-lite", - "sync_wrapper", - "tower-layer", - "tower-service", -] - [[package]] name = "base16ct" version = "0.2.0" @@ -436,21 +356,6 @@ dependencies = [ "unty", ] -[[package]] -name = "bit-set" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" -dependencies = [ - "bit-vec", -] - -[[package]] -name = "bit-vec" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" - [[package]] name = "bitflags" version = "1.3.2" @@ -462,10 +367,6 @@ name = "bitflags" version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" -dependencies = [ - "bytemuck", - "serde_core", -] [[package]] name = "bitvec" @@ -488,19 +389,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "blake3" -version = "1.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d9e454fc11f76977dc803893aff6304ed33d6a26efae8696573bea74baa27ae" -dependencies = [ - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq", - "cpufeatures 0.3.1", -] - [[package]] name = "blanket" version = "0.3.0" @@ -531,30 +419,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "borsh" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a" -dependencies = [ - "borsh-derive", - "bytes", - "cfg_aliases", -] - -[[package]] -name = "borsh-derive" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cdfe656708a01f89b451a7d36466e6fe6c414de0aa18fc54f864f6f9ca9f56" -dependencies = [ - "once_cell", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 3.0.5", -] - [[package]] name = "bs58" version = "0.5.1" @@ -592,20 +456,6 @@ name = "bytemuck" version = "1.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" -dependencies = [ - "bytemuck_derive", -] - -[[package]] -name = "bytemuck_derive" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] [[package]] name = "byteorder" @@ -613,32 +463,17 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" -[[package]] -name = "byteorder-lite" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" - [[package]] name = "bytes" version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" -dependencies = [ - "serde", -] - -[[package]] -name = "byteview" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d74937895e761d5984206f82ca8ff7725d0fd8021921011921894b41ab1b9f7" [[package]] name = "caret" -version = "0.11.2" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3f1a1c7fa296eb2367469e6226783ed07cb778d75d13f7b6ee3f1de593ba7f4" +checksum = "23a6f83e57018d15e7615a6f8e5e2c6b6b0226e24a1c562cd705f855a2bc751a" [[package]] name = "castaway" @@ -663,15 +498,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" - -[[package]] -name = "cfg_aliases" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "chacha20" @@ -743,55 +572,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "clap" -version = "4.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d" -dependencies = [ - "anstyle", - "clap_lex", - "strsim 0.11.1", - "terminal_size", -] - -[[package]] -name = "clap_derive" -version = "4.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "clap_lex" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486" - -[[package]] -name = "cmake" -version = "0.1.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" -dependencies = [ - "cc", -] - [[package]] name = "cmov" version = "0.5.4" @@ -800,9 +580,9 @@ checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" [[package]] name = "coarsetime" -version = "0.1.38" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae63702c5627c75addbfb1ea9d1b3842205a6ffd43e4cce884a2a9eb1828fd7" +checksum = "e58eb270476aa4fc7843849f8a35063e8743b4dbcdf6dd0f8ea0886980c204c2" dependencies = [ "libc", "wasix", @@ -823,17 +603,11 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "compare" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0095f6103c2a8b44acd6fd15960c801dafebf02e21940360833e0673f48ba7" - [[package]] name = "compression-codecs" -version = "0.4.49" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f938fc0d88fbe2c8d6f0e1ba96ba1165d89ff698e98468cd019d92cff2ecd367" +checksum = "58a6d0db8759036a783bc7c3f7a07f8cef3bf9470eb1db3bc86e8bcd1c5d0fe8" dependencies = [ "compression-core", "flate2", @@ -844,9 +618,9 @@ dependencies = [ [[package]] name = "compression-core" -version = "0.4.34" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ebdda89edc534bf8d5dd2857562633b6495557e5846552ade994b99ed13c36a" +checksum = "6e8ccc4ea9f6acc32d102c0f6d471d11d913ad15f20c04de743374861fa1d414" [[package]] name = "const-oid" @@ -860,34 +634,6 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" -[[package]] -name = "const_format" -version = "0.2.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4481a617ad9a412be3b97c5d403fef8ed023103368908b9c50af598ff467cc1e" -dependencies = [ - "const_format_proc_macros", - "konst", -] - -[[package]] -name = "const_format_proc_macros" -version = "0.2.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - -[[package]] -name = "constant_time_eq" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b" - [[package]] name = "convert_case" version = "0.10.0" @@ -955,47 +701,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e71406cd8807725f7ac2f999a4cdd32e98f829fdf65f528343cebf945e41df1e" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-epoch", - "crossbeam-queue", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-queue" version = "0.3.14" @@ -1005,16 +710,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "crossbeam-skiplist" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df29de440c58ca2cc6e587ec3d22347551a32435fbde9d2bff64e78a9ffa151b" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - [[package]] name = "crossbeam-utils" version = "0.8.23" @@ -1060,17 +755,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "crypto-bigint" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a52aa3fcda4e6302a9f48734f234d35d4721b96f8fe07d073f07ce9df4f0271" -dependencies = [ - "cpubits", - "ctutils", - "num-traits", -] - [[package]] name = "crypto-common" version = "0.1.7" @@ -1078,7 +762,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", - "rand_core 0.6.4", "typenum", ] @@ -1088,9 +771,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" dependencies = [ - "getrandom 0.4.3", "hybrid-array", - "rand_core 0.10.1", ] [[package]] @@ -1120,491 +801,6 @@ dependencies = [ "cmov", ] -[[package]] -name = "cuprate-address-book" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "borsh", - "cuprate-constants", - "cuprate-p2p-core", - "cuprate-pruning", - "futures", - "indexmap 2.14.2", - "rand 0.8.8", - "thiserror 2.0.20", - "tokio", - "tokio-util", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-async-buffer" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "futures", - "pin-project", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-blockchain" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "arc-swap", - "bytemuck", - "bytes", - "crossbeam", - "cuprate-constants", - "cuprate-helper", - "cuprate-pruning", - "cuprate-types", - "fjall", - "futures", - "indexmap 2.14.2", - "monero-oxide", - "rand 0.8.8", - "rayon", - "serde", - "tapes", - "thiserror 2.0.20", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-consensus" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "cfg-if", - "cuprate-consensus-context", - "cuprate-consensus-rules", - "cuprate-helper", - "cuprate-types", - "hex", - "indexmap 2.14.2", - "monero-oxide", - "rand 0.8.8", - "rayon", - "thiserror 2.0.20", - "thread_local", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-consensus-context" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "arc-swap", - "cuprate-consensus-rules", - "cuprate-helper", - "cuprate-types", - "futures", - "hex", - "monero-oxide", - "randomx-rs", - "rayon", - "strum", - "thread_local", - "tokio", - "tokio-util", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-consensus-rules" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "cfg-if", - "crypto-bigint 0.7.5", - "cuprate-constants", - "cuprate-cryptonight", - "cuprate-helper", - "cuprate-types", - "curve25519-dalek 4.1.3", - "hex", - "hex-literal 1.1.0", - "indexmap 2.14.2", - "monero-oxide", - "rand 0.8.8", - "rayon", - "thiserror 2.0.20", - "tracing", -] - -[[package]] -name = "cuprate-constants" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" - -[[package]] -name = "cuprate-cryptonight" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "digest 0.10.7", - "groestl", - "jh", - "keccak 0.1.6", - "seq-macro", - "sha3 0.10.9", - "skein", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-dandelion-tower" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "futures", - "rand 0.8.8", - "rand_distr", - "thiserror 2.0.20", - "tokio", - "tokio-util", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-epee-encoding" -version = "0.5.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bytes", - "cuprate-fixed-bytes", - "cuprate-hex", - "paste", - "ref-cast", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-fast-sync" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "blake3", - "clap", - "cuprate-blockchain", - "cuprate-consensus", - "cuprate-consensus-context", - "cuprate-helper", - "cuprate-hex", - "cuprate-p2p", - "cuprate-p2p-core", - "cuprate-types", - "fjall", - "futures", - "hex", - "monero-oxide", - "rayon", - "serde_json", - "tokio", - "tower", - "tracing-subscriber", -] - -[[package]] -name = "cuprate-fixed-bytes" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bytes", - "serde", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-helper" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "chrono", - "cuprate-constants", - "curve25519-dalek 4.1.3", - "dirs 6.0.0", - "futures", - "libc", - "monero-oxide", - "rayon", - "serde", - "windows", -] - -[[package]] -name = "cuprate-hex" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "hex", - "serde", -] - -[[package]] -name = "cuprate-json-rpc" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "serde", - "serde_json", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-levin" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bitflags 2.13.2", - "bytes", - "cfg-if", - "cuprate-helper", - "thiserror 2.0.20", - "tokio-util", - "tracing", -] - -[[package]] -name = "cuprate-p2p" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "borsh", - "bytes", - "cuprate-address-book", - "cuprate-async-buffer", - "cuprate-constants", - "cuprate-fixed-bytes", - "cuprate-helper", - "cuprate-p2p-core", - "cuprate-pruning", - "cuprate-types", - "cuprate-wire", - "futures", - "indexmap 2.14.2", - "monero-oxide", - "pin-project", - "rand 0.8.8", - "rand_distr", - "rayon", - "thiserror 2.0.20", - "tokio", - "tokio-stream", - "tokio-util", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-p2p-core" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "async-trait", - "borsh", - "cfg-if", - "cuprate-helper", - "cuprate-pruning", - "cuprate-types", - "cuprate-wire", - "futures", - "hex", - "hex-literal 1.1.0", - "rand 0.8.8", - "thiserror 2.0.20", - "tokio", - "tokio-stream", - "tokio-util", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-p2p-transport" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "async-trait", - "cuprate-p2p-core", - "cuprate-wire", - "futures", - "tokio", - "tokio-socks", - "tokio-util", -] - -[[package]] -name = "cuprate-pruning" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "borsh", - "cuprate-constants", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-rpc-interface" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "anyhow", - "axum", - "cuprate-epee-encoding", - "cuprate-helper", - "cuprate-json-rpc", - "cuprate-rpc-types", - "futures", - "paste", - "serde", - "serde_json", - "tower", -] - -[[package]] -name = "cuprate-rpc-types" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "cuprate-epee-encoding", - "cuprate-fixed-bytes", - "cuprate-helper", - "cuprate-hex", - "cuprate-p2p-core", - "cuprate-types", - "hex", - "monero-oxide", - "paste", - "serde", - "serde_json", -] - -[[package]] -name = "cuprate-txpool" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bitflags 2.13.2", - "blake3", - "bytemuck", - "cuprate-helper", - "cuprate-types", - "fjall", - "futures", - "hex", - "monero-oxide", - "rayon", - "thiserror 2.0.20", - "tower", -] - -[[package]] -name = "cuprate-types" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bitflags 2.13.2", - "bytes", - "cfg-if", - "cuprate-epee-encoding", - "cuprate-fixed-bytes", - "cuprate-helper", - "cuprate-hex", - "indexmap 2.14.2", - "monero-oxide", - "proptest", - "proptest-derive", - "serde", - "strum", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-wire" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bitflags 2.13.2", - "borsh", - "bytes", - "cuprate-epee-encoding", - "cuprate-fixed-bytes", - "cuprate-helper", - "cuprate-levin", - "cuprate-types", - "serde", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprated" -version = "0.1.0-preview" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "anyhow", - "axum", - "borsh", - "bytes", - "clap", - "const_format", - "cuprate-address-book", - "cuprate-blockchain", - "cuprate-consensus", - "cuprate-consensus-context", - "cuprate-consensus-rules", - "cuprate-constants", - "cuprate-cryptonight", - "cuprate-dandelion-tower", - "cuprate-fast-sync", - "cuprate-fixed-bytes", - "cuprate-helper", - "cuprate-hex", - "cuprate-p2p", - "cuprate-p2p-core", - "cuprate-p2p-transport", - "cuprate-pruning", - "cuprate-rpc-interface", - "cuprate-rpc-types", - "cuprate-txpool", - "cuprate-types", - "cuprate-wire", - "dashmap", - "fjall", - "futures", - "hex", - "hyper", - "hyper-util", - "indexmap 2.14.2", - "monero-address", - "monero-oxide", - "nu-ansi-term", - "pin-project-lite", - "rayon", - "serde", - "serde_json", - "sysinfo", - "thiserror 2.0.20", - "tokio", - "tokio-util", - "toml 1.2.3+spec-1.1.0", - "toml_edit 0.25.13+spec-1.1.0", - "tower", - "tower-http", - "tracing", - "tracing-appender", - "tracing-subscriber", -] - [[package]] name = "curve25519-dalek" version = "4.1.3" @@ -1615,24 +811,7 @@ dependencies = [ "cpufeatures 0.2.17", "curve25519-dalek-derive", "digest 0.10.7", - "fiat-crypto 0.2.9", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "5.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c1aa5a9b7626ed65ac0cf5ea9d4f1547af89017fbac20bd4de40022fff516f" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "curve25519-dalek-derive", - "digest 0.11.3", - "fiat-crypto 0.3.0", - "rand_core 0.10.1", + "fiat-crypto", "rustc_version", "subtle", "zeroize", @@ -1752,20 +931,6 @@ dependencies = [ "syn 3.0.5", ] -[[package]] -name = "dashmap" -version = "6.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6361d5c062261c78a176addb82d4c821ae42bed6089de0e12603cd25de2059c" -dependencies = [ - "cfg-if", - "crossbeam-utils", - "hashbrown 0.14.5", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "data-encoding" version = "2.11.1" @@ -1814,16 +979,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "der" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a" -dependencies = [ - "const-oid 0.10.2", - "zeroize", -] - [[package]] name = "der-parser" version = "10.0.0" @@ -1849,9 +1004,9 @@ dependencies = [ [[package]] name = "derive-deftly" -version = "1.14.0" +version = "1.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "724949bdda5310709ca2f97bf69c2b01e3362f44fef1fb47913445db4c1debb5" +checksum = "98e02cd118058400797c74550dca132b57cf2e6af0e9ea0672a83eb186fd655e" dependencies = [ "derive-deftly-macros", "heck", @@ -1859,9 +1014,9 @@ dependencies = [ [[package]] name = "derive-deftly-macros" -version = "1.14.0" +version = "1.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17933e749f2502cfcd1c27519292fbbea22e8fc64ce680e863f855e8cd8cce23" +checksum = "ba91f619216e76a5eb2515783f7ec2e271938b51aadac592f4930517f4626863" dependencies = [ "heck", "indexmap 2.14.2", @@ -1948,10 +1103,8 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ - "block-buffer 0.12.1", "const-oid 0.10.2", "crypto-common 0.2.2", - "ctutils", ] [[package]] @@ -1972,15 +1125,6 @@ dependencies = [ "dirs-sys", ] -[[package]] -name = "dirs" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f" -dependencies = [ - "dirs-sys", -] - [[package]] name = "dirs-sys" version = "0.5.0" @@ -2031,12 +1175,12 @@ version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ - "der 0.7.10", + "der", "digest 0.10.7", "elliptic-curve", "rfc6979", - "signature 2.2.0", - "spki 0.7.3", + "signature", + "spki", ] [[package]] @@ -2045,18 +1189,8 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8 0.10.2", - "signature 2.2.0", -] - -[[package]] -name = "ed25519" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29fcf32e6c73d1079f83ab4d782de2d81620346a5f38c6237a86a22f8368980a" -dependencies = [ - "pkcs8 0.11.0", - "signature 3.0.0", + "pkcs8", + "signature", ] [[package]] @@ -2065,29 +1199,12 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" dependencies = [ - "curve25519-dalek 4.1.3", - "ed25519 2.2.3", + "curve25519-dalek", + "ed25519", + "merlin", "rand_core 0.6.4", "serde", - "sha2 0.10.9", - "subtle", - "zeroize", -] - -[[package]] -name = "ed25519-dalek" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de" -dependencies = [ - "curve25519-dalek 5.1.0", - "ed25519 3.0.0", - "keccak 0.2.2", - "rand_core 0.10.1", - "serde", - "sha2 0.11.3", - "signature 3.0.0", - "strobe-rs", + "sha2", "subtle", "zeroize", ] @@ -2117,12 +1234,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", - "crypto-bigint 0.5.5", + "crypto-bigint", "digest 0.10.7", "ff", "generic-array", "group", - "pkcs8 0.10.2", + "pkcs8", "rand_core 0.6.4", "sec1", "subtle", @@ -2246,12 +1363,6 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" -[[package]] -name = "fiat-crypto" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" - [[package]] name = "figment" version = "0.10.19" @@ -2281,23 +1392,6 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d" -[[package]] -name = "fjall" -version = "3.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd201c93927cdf4712e8f7d4c9c8d34d68c7534380c05d4a58864a309f91c33f" -dependencies = [ - "byteorder-lite", - "byteview", - "dashmap", - "flume", - "log", - "lsm-tree", - "lz4_flex", - "tempfile", - "xxhash-rust", -] - [[package]] name = "flate2" version = "1.1.10" @@ -2315,15 +1409,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "749cff877dc1af878a0b31a41dd221a753634401ea0ef2f87b62d3171522485a" -[[package]] -name = "flume" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e139bc46ca777eb5efaf62df0ab8cc5fd400866427e56c68b22e414e53bd3be" -dependencies = [ - "spin 0.9.9", -] - [[package]] name = "fnv" version = "1.0.7" @@ -2368,12 +1453,12 @@ dependencies = [ [[package]] name = "fs-mistrust" -version = "0.16.2" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628799db8c034e020e48ee393c271f423aa749fde1c3195bd3bbc8bb5cfcbe8" +checksum = "9b2c81a5a0e7d67644309a15694eb7f414a4d6556c64c1ece1e5969aa609c8a9" dependencies = [ "derive_builder_fork_arti", - "dirs 7.0.0", + "dirs", "extend", "libc", "pwd-grp", @@ -2385,9 +1470,9 @@ dependencies = [ [[package]] name = "fslock-guard" -version = "0.9.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba455a614874a0b1814cf3e30f8a6d4c8858e2bc38569bd293e3ff8cbad49032" +checksum = "d10ce5036d49f8add4a11d08bc1b1afb0e3cefdd88778ab87fb4202d47b765e1" dependencies = [ "libc", "thiserror 2.0.20", @@ -2459,17 +1544,6 @@ dependencies = [ "syn 3.0.5", ] -[[package]] -name = "futures-rustls" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" -dependencies = [ - "futures-io", - "rustls", - "rustls-pki-types", -] - [[package]] name = "futures-sink" version = "0.3.34" @@ -2578,15 +1652,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9985c9503b412198aa4197559e9a318524ebc4519c229bfa05a535828c950b9d" -[[package]] -name = "groestl" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343cfc165f92a988fd60292f7a0bfde4352a5a0beff9fbec29251ca4e9676e4d" -dependencies = [ - "digest 0.10.7", -] - [[package]] name = "group" version = "0.13.0" @@ -2616,12 +1681,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hashbrown" version = "0.15.5" @@ -2673,21 +1732,6 @@ name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -dependencies = [ - "serde", -] - -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - -[[package]] -name = "hex-literal" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e712f64ec3850b98572bffac52e2c6f282b29fe6c5fa6d42334b30be438d95c1" [[package]] name = "hkdf" @@ -2695,16 +1739,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ - "hmac 0.12.1", -] - -[[package]] -name = "hkdf" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018" -dependencies = [ - "hmac 0.13.0", + "hmac", ] [[package]] @@ -2716,15 +1751,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "hmac" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" -dependencies = [ - "digest 0.11.3", -] - [[package]] name = "hostname-validator" version = "1.1.1" @@ -2741,29 +1767,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" -dependencies = [ - "bytes", - "http", -] - -[[package]] -name = "http-body-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" -dependencies = [ - "bytes", - "futures-core", - "http", - "http-body", - "pin-project-lite", -] - [[package]] name = "httparse" version = "1.10.1" @@ -2798,46 +1801,10 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" dependencies = [ - "ctutils", "typenum", "zeroize", ] -[[package]] -name = "hyper" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b501faa50e7a26c3d3560ca625132f4078a17771f4810baf70475ae48cbe43" -dependencies = [ - "atomic-waker", - "bytes", - "futures-channel", - "futures-core", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", -] - -[[package]] -name = "hyper-util" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" -dependencies = [ - "bytes", - "http", - "http-body", - "hyper", - "pin-project-lite", - "tokio", - "tower-service", -] - [[package]] name = "iana-time-zone" version = "0.1.65" @@ -3001,7 +1968,6 @@ checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ "equivalent", "hashbrown 0.17.1", - "rayon", "serde", "serde_core", ] @@ -3066,20 +2032,11 @@ dependencies = [ "syn 3.0.5", ] -[[package]] -name = "interval-heap" -version = "0.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11274e5e8e89b8607cfedc2910b6626e998779b48a019151c7604d0adcb86ac6" -dependencies = [ - "compare", -] - [[package]] name = "inventory" -version = "0.3.25" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" +checksum = "a4f0c30c76f2f4ccee3fe55a2435f691ca00c0e4bd87abe4f4a851b1d4dac39b" dependencies = [ "rustversion", ] @@ -3123,17 +2080,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" -[[package]] -name = "jh" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f65735f9e73adc203417d2e05352aef71d7e832ec090f65de26c96c9ec563aa5" -dependencies = [ - "digest 0.10.7", - "hex-literal 0.4.1", - "ppv-lite86", -] - [[package]] name = "jiff" version = "0.2.35" @@ -3141,25 +2087,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "668b7183bd07af9a4885f5c35b0cc5c83c4607a913c16b7e17291832910d2dcc" dependencies = [ "defmt", - "jiff-core 0.1.0", - "jiff-static 0.2.35", - "jiff-tzdb-platform 0.1.3", - "log", - "portable-atomic", - "portable-atomic-util", - "serde_core", - "windows-link", -] - -[[package]] -name = "jiff" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379ed44bd4e16d3926160e2b3a78b79ca0952ef5c037f124f554842ba272ef92" -dependencies = [ - "jiff-core 1.1.0", - "jiff-static 1.1.0", - "jiff-tzdb-platform 1.0.0", + "jiff-core", + "jiff-static", + "jiff-tzdb-platform", "log", "portable-atomic", "portable-atomic-util", @@ -3176,67 +2106,31 @@ dependencies = [ "defmt", ] -[[package]] -name = "jiff-core" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df46fc314b4f458aee614afcd8676ed6cb3637413aa359d47d2646cbc038b79" -dependencies = [ - "log", -] - [[package]] name = "jiff-static" version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a69dcb3a21cfb32ce1cd056169337ca284af0766dd766e7878819b251a49204" dependencies = [ - "jiff-core 0.1.0", + "jiff-core", "proc-macro2", "quote", "syn 2.0.119", ] -[[package]] -name = "jiff-static" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b729c549d3efb5855b3c80b0ee8ee1850d56330a127382fe2760965741c1f3" -dependencies = [ - "jiff-core 1.1.0", - "proc-macro2", - "quote", - "syn 3.0.5", -] - [[package]] name = "jiff-tzdb" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "142bd39932ad231f10513df9ab62661fead8719872150b7ad02a2df79f4e141e" -[[package]] -name = "jiff-tzdb" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e71a1b68a875a44a33bb7a1dd84392cb77145a3367a552a3cfe6a4f5cf3afc" - [[package]] name = "jiff-tzdb-platform" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" dependencies = [ - "jiff-tzdb 0.1.8", -] - -[[package]] -name = "jiff-tzdb-platform" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc65b284afcfa8f6cf189c7274c805505314a7ab975c60e1f548bff56525420e" -dependencies = [ - "jiff-tzdb 1.0.0", + "jiff-tzdb", ] [[package]] @@ -3262,13 +2156,12 @@ dependencies = [ [[package]] name = "k12" -version = "0.5.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38a8cc72399dffa4a445bc5f5a84d4af4d441c76604231bc52e9c529c1d47693" +checksum = "f4dc5fdb62af2f520116927304f15d25b3c2667b4817b90efdc045194c912c54" dependencies = [ - "digest 0.11.3", - "keccak 0.2.2", - "sponge-cursor", + "digest 0.10.7", + "sha3 0.10.9", ] [[package]] @@ -3299,34 +2192,8 @@ checksum = "d8f198d1db720e4940b5a493201d199d9f24f568f8f746bd13706243a2f71598" dependencies = [ "cfg-if", "cpufeatures 0.3.1", - "hybrid-array", ] -[[package]] -name = "kem" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01737161ba802849cfd486b5bd209d38ba4943494c249a8126005170c7621edd" -dependencies = [ - "crypto-common 0.2.2", - "rand_core 0.10.1", -] - -[[package]] -name = "konst" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128133ed7824fcd73d6e7b17957c5eb7bacb885649bd8c69708b2331a10bcefb" -dependencies = [ - "konst_macro_rules", -] - -[[package]] -name = "konst_macro_rules" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37" - [[package]] name = "kqueue" version = "1.2.1" @@ -3353,7 +2220,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.9.9", + "spin", ] [[package]] @@ -3404,7 +2271,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91632f3b4fb6bd1d72aa3d78f41ffecfcf2b1a6648d8c241dbe7dbfaf4875e15" dependencies = [ "cc", - "openssl-sys", "pkg-config", "vcpkg", ] @@ -3460,37 +2326,6 @@ dependencies = [ "hashbrown 0.17.1", ] -[[package]] -name = "lsm-tree" -version = "3.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5498808f4d41cf785079d3ef3f28716f1b4364af1b512f3097bfb651bded1b3e" -dependencies = [ - "byteorder-lite", - "byteview", - "crossbeam-skiplist", - "enum_dispatch", - "interval-heap", - "log", - "lz4_flex", - "quick_cache", - "rustc-hash", - "self_cell", - "sfa", - "tempfile", - "varint-rs", - "xxhash-rust", -] - -[[package]] -name = "lz4_flex" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef0d4ed8669f8f8826eb00dc878084aa8f253506c4fd5e8f58f5bce72ddb97e" -dependencies = [ - "twox-hash", -] - [[package]] name = "matchers" version = "0.2.0" @@ -3500,22 +2335,6 @@ dependencies = [ "regex-automata", ] -[[package]] -name = "matchit" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" - -[[package]] -name = "md-5" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" -dependencies = [ - "cfg-if", - "digest 0.10.7", -] - [[package]] name = "memchr" version = "2.8.3" @@ -3524,29 +2343,25 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "memmap2" -version = "0.9.12" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0" dependencies = [ "libc", ] [[package]] -name = "metrics" -version = "0.24.6" +name = "merlin" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89550ee9f79e88fef3119de263694973a8adb26c21d75322164fb8c493039fe2" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" dependencies = [ - "portable-atomic", - "rapidhash", + "byteorder", + "keccak 0.1.6", + "rand_core 0.6.4", + "zeroize", ] -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -3575,175 +2390,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "ml-kem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ba01ebcf90f6aff8e9b9f55bb69b19e6250e4ade5787d0040eaa27dd226238" -dependencies = [ - "hybrid-array", - "kem", - "module-lattice", - "pkcs8 0.11.0", - "rand_core 0.10.1", - "sha3 0.12.0", - "shake", - "zeroize", -] - -[[package]] -name = "module-lattice" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c61b87c9683ab7cb1c6871d261ad5479b6b10ceb52c4352aaca3b5d35a8febe" -dependencies = [ - "ctutils", - "hybrid-array", - "num-traits", - "zeroize", -] - -[[package]] -name = "monero-address" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "monero-base58", - "monero-ed25519", - "monero-io", - "monero-primitives", - "thiserror 2.0.20", - "zeroize", -] - -[[package]] -name = "monero-base58" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "monero-primitives", - "std-shims", -] - -[[package]] -name = "monero-borromean" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "monero-ed25519", - "monero-io", - "std-shims", - "zeroize", -] - -[[package]] -name = "monero-bulletproofs" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "monero-bulletproofs-generators", - "monero-ed25519", - "monero-io", - "monero-primitives", - "rand_core 0.6.4", - "std-shims", - "thiserror 2.0.20", - "zeroize", -] - -[[package]] -name = "monero-bulletproofs-generators" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "monero-ed25519", - "monero-io", - "monero-primitives", - "std-shims", -] - -[[package]] -name = "monero-clsag" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "group", - "monero-ed25519", - "monero-io", - "rand_chacha 0.3.1", - "rand_core 0.6.4", - "std-shims", - "subtle", - "thiserror 2.0.20", - "zeroize", -] - -[[package]] -name = "monero-ed25519" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "crypto-bigint 0.5.5", - "curve25519-dalek 4.1.3", - "monero-io", - "rand_core 0.6.4", - "sha3 0.10.9", - "std-shims", - "subtle", - "zeroize", -] - -[[package]] -name = "monero-io" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "std-shims", -] - -[[package]] -name = "monero-mlsag" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "monero-ed25519", - "monero-io", - "std-shims", - "thiserror 2.0.20", - "zeroize", -] - -[[package]] -name = "monero-oxide" -version = "0.1.4-alpha" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "hex-literal 1.1.0", - "monero-borromean", - "monero-bulletproofs", - "monero-clsag", - "monero-ed25519", - "monero-io", - "monero-mlsag", - "monero-primitives", - "std-shims", - "zeroize", -] - -[[package]] -name = "monero-primitives" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "sha3 0.10.9", -] - [[package]] name = "native-tls" version = "0.2.18" @@ -3940,47 +2586,33 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "oneshot-fused-workaround" -version = "0.8.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f851210432a7498257e0f1675c25b95131308f157b87821b70df756b01aa1dbc" +checksum = "56892f7dcba21c5eb4181b8de221620855805891ee55ef960aad7cac3b5d88b2" dependencies = [ "futures", ] [[package]] name = "onionwire" -version = "0.2.1" +version = "0.1.2" dependencies = [ - "argon2", "arti-client", - "chacha20poly1305", - "cuprated", - "ed25519-dalek 2.2.0", + "ed25519-dalek", "futures", - "hkdf 0.12.4", - "hmac 0.12.1", - "md-5", - "ml-kem", "qrcode", "rand 0.8.8", "ratatui", - "rpassword", "rusqlite", - "rustls", "safelog", - "serde_json", - "sha2 0.10.9", - "sha3 0.10.9", "snow", "tempfile", "tokio", - "toml 0.8.23", "tor-cell", "tor-hsservice", "tor-rtcompat", "tracing-subscriber", - "x25519-dalek 2.0.1", - "zeroize", + "x25519-dalek", ] [[package]] @@ -4020,15 +2652,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" -[[package]] -name = "openssl-src" -version = "300.6.1+3.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46eb8fb9fb3b61ce1c0f8a026c4c1a0714d3a9e138e7fbde78753ce2babc3846" -dependencies = [ - "cc", -] - [[package]] name = "openssl-sys" version = "0.9.117" @@ -4037,7 +2660,6 @@ checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" dependencies = [ "cc", "libc", - "openssl-src", "pkg-config", "vcpkg", ] @@ -4075,7 +2697,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -4087,7 +2709,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -4101,7 +2723,7 @@ dependencies = [ "elliptic-curve", "primeorder", "rand_core 0.6.4", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -4166,17 +2788,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "password-hash" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" -dependencies = [ - "base64ct", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "paste" version = "1.0.15" @@ -4273,9 +2884,9 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" dependencies = [ - "der 0.7.10", - "pkcs8 0.10.2", - "spki 0.7.3", + "der", + "pkcs8", + "spki", ] [[package]] @@ -4284,18 +2895,8 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.10", - "spki 0.7.3", -] - -[[package]] -name = "pkcs8" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7" -dependencies = [ - "der 0.8.2", - "spki 0.8.1", + "der", + "spki", ] [[package]] @@ -4401,6 +3002,17 @@ dependencies = [ "elliptic-curve", ] +[[package]] +name = "priority-queue" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93980406f12d9f8140ed5abe7155acb10bb1e69ea55c88960b9c2f117445ef96" +dependencies = [ + "equivalent", + "indexmap 2.14.2", + "serde", +] + [[package]] name = "proc-macro-crate" version = "3.5.0" @@ -4419,36 +3031,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "proptest" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b45fcc2344c680f5025fe57779faef368840d0bd1f42f216291f0dc4ace4744" -dependencies = [ - "bit-set", - "bit-vec", - "bitflags 2.13.2", - "num-traits", - "rand 0.9.5", - "rand_chacha 0.9.0", - "rand_xorshift", - "regex-syntax", - "rusty-fork", - "tempfile", - "unarray", -] - -[[package]] -name = "proptest-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c57924a81864dddafba92e1bf92f9bf82f97096c44489548a60e888e1547549b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "pwd-grp" version = "1.0.2" @@ -4467,22 +3049,6 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d68782463e408eb1e668cf6152704bd856c78c5b6417adaee3203d8f4c1fc9ec" -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quick_cache" -version = "0.6.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9c6658afe513a3b484e3abfdaa0d03ef3c0bbf017542c178dd55f94eb3051f9" -dependencies = [ - "equivalent", - "hashbrown 0.16.1", -] - [[package]] name = "quote" version = "1.0.47" @@ -4523,19 +3089,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.5" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" -dependencies = [ - "rand_chacha 0.9.0", - "rand_core 0.9.5", -] - -[[package]] -name = "rand" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" dependencies = [ "chacha20 0.10.2", "getrandom 0.4.3", @@ -4552,16 +3108,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "rand_chacha" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" -dependencies = [ - "ppv-lite86", - "rand_core 0.9.5", -] - [[package]] name = "rand_chacha" version = "0.10.0" @@ -4581,31 +3127,12 @@ dependencies = [ "getrandom 0.2.17", ] -[[package]] -name = "rand_core" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" -dependencies = [ - "getrandom 0.3.4", -] - [[package]] name = "rand_core" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" -[[package]] -name = "rand_distr" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" -dependencies = [ - "num-traits", - "rand 0.8.8", -] - [[package]] name = "rand_jitter" version = "0.6.1" @@ -4617,42 +3144,12 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "rand_xorshift" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" -dependencies = [ - "rand_core 0.9.5", -] - -[[package]] -name = "randomx-rs" -version = "1.4.1" -source = "git+https://github.com/Cuprate/randomx-rs.git?rev=76c2385#76c2385771ca5aca941e0991ebd822e6edb8d94d" -dependencies = [ - "bitflags 1.3.2", - "cc", - "cmake", - "libc", - "thiserror 1.0.69", -] - [[package]] name = "rangemap" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d" -[[package]] -name = "rapidhash" -version = "4.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da7e78a036ce858e8d55b7e7dc8ba3a88b78350fd2155d3591bbd966b58589e" -dependencies = [ - "rustversion", -] - [[package]] name = "ratatui" version = "0.30.2" @@ -4719,26 +3216,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "rayon" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - [[package]] name = "rdrand" version = "0.9.0" @@ -4829,9 +3306,9 @@ dependencies = [ [[package]] name = "retry-error" -version = "0.14.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67f26b5caa81adf9b23ab230ce975acbf46aec461bc357f9fb51cfd4f2bfaebf" +checksum = "d350ad359aca3414f7261cdcc763e37ccc9fa56fe40ca30a9758c28a295bcad0" dependencies = [ "humantime", "web-time", @@ -4843,7 +3320,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "hmac 0.12.1", + "hmac", "subtle", ] @@ -4861,17 +3338,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rpassword" -version = "7.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da316a15f47e3d053de9cb2c439650bd8fa4aaeb9365f2e5f27f492ff73c196" -dependencies = [ - "libc", - "rtoolbox", - "windows-sys 0.61.2", -] - [[package]] name = "rsa" version = "0.9.10" @@ -4884,25 +3350,15 @@ dependencies = [ "num-integer", "num-traits", "pkcs1", - "pkcs8 0.10.2", + "pkcs8", "rand_core 0.6.4", - "sha2 0.10.9", - "signature 2.2.0", - "spki 0.7.3", + "sha2", + "signature", + "spki", "subtle", "zeroize", ] -[[package]] -name = "rtoolbox" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1efe12a1469752d0e6ff5ebec0b6ef4924cc5c4c71046b0ec730040535819d" -dependencies = [ - "libc", - "windows-sys 0.61.2", -] - [[package]] name = "rusqlite" version = "0.36.0" @@ -4918,12 +3374,6 @@ dependencies = [ "time", ] -[[package]] -name = "rustc-hash" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" - [[package]] name = "rustc_version" version = "0.4.1" @@ -4955,59 +3405,12 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "rustls" -version = "0.23.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" -dependencies = [ - "log", - "once_cell", - "ring", - "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", -] - -[[package]] -name = "rustls-pki-types" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" -dependencies = [ - "zeroize", -] - -[[package]] -name = "rustls-webpki" -version = "0.103.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" -[[package]] -name = "rusty-fork" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6bf79ff24e648f6da1f8d1f011e9cac26491b619e6b9280f2b47f1774e6ee2" -dependencies = [ - "fnv", - "quick-error", - "tempfile", - "wait-timeout", -] - [[package]] name = "ryu" version = "1.0.23" @@ -5016,9 +3419,9 @@ checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "safelog" -version = "0.10.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c090399e87e5eaec9515d6b859fdb7ec417c269c2e7564c169a8963df75a2ce" +checksum = "73ef1d6e273fc8ce5cc1376cf498c06d23b786e80e4a7679a643bb0a838b0029" dependencies = [ "derive_more", "educe", @@ -5047,12 +3450,9 @@ dependencies = [ [[package]] name = "saturating-time" -version = "0.6.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950f7f265dc6fc082387eccf710b1adbf22d75f17c4ee0db4648c9b6959b50d" -dependencies = [ - "web-time-compat", -] +checksum = "802bdbfcca9a239cb46eeaaedea507e37bb13ba1a673762d2e2ef7a9dac63144" [[package]] name = "schannel" @@ -5100,9 +3500,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct", - "der 0.7.10", + "der", "generic-array", - "pkcs8 0.10.2", + "pkcs8", "subtle", "zeroize", ] @@ -5130,24 +3530,12 @@ dependencies = [ "libc", ] -[[package]] -name = "self_cell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" - [[package]] name = "semver" version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" -[[package]] -name = "seq-macro" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" - [[package]] name = "serde" version = "1.0.229" @@ -5210,9 +3598,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.154" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" dependencies = [ "itoa", "memchr", @@ -5221,17 +3609,6 @@ dependencies = [ "zmij", ] -[[package]] -name = "serde_path_to_error" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" -dependencies = [ - "itoa", - "serde", - "serde_core", -] - [[package]] name = "serde_spanned" version = "0.6.9" @@ -5243,18 +3620,18 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "1.1.3" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" dependencies = [ "serde_core", ] [[package]] name = "serde_with" -version = "3.25.0" +version = "3.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56cb1ca7c93ae63d6439b5250f6b6b040f7e121f32e5dd2f5d523dd4149b3204" +checksum = "935177bb8c0cd8ca1a4e6d1a2ac8988bea69cab4f9d3a31311e012ad27868ea4" dependencies = [ "base64", "bs58", @@ -5262,8 +3639,7 @@ dependencies = [ "hex", "indexmap 1.9.3", "indexmap 2.14.2", - "jiff 0.2.35", - "jiff 1.1.0", + "jiff", "schemars 0.9.0", "schemars 1.2.2", "serde_core", @@ -5274,9 +3650,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.25.0" +version = "3.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff15a7c864bbec77d9586ca6822bc7c369bdf19e9243134a62b0b51ce26b31f" +checksum = "1d607aa01a3cb0ad757d6fd216136910db3c97b102fe686585689615a02dbcdc" dependencies = [ "darling 0.24.1", "proc-macro2", @@ -5284,26 +3660,15 @@ dependencies = [ "syn 3.0.5", ] -[[package]] -name = "sfa" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1296838937cab56cd6c4eeeb8718ec777383700c33f060e2869867bd01d1175" -dependencies = [ - "byteorder-lite", - "log", - "xxhash-rust", -] - [[package]] name = "sha1" -version = "0.11.0" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214" +checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" dependencies = [ "cfg-if", - "cpufeatures 0.3.1", - "digest 0.11.3", + "cpufeatures 0.2.17", + "digest 0.10.7", ] [[package]] @@ -5317,17 +3682,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sha2" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "820083d430c52864bf834423fc988cbcf61685d6f9d22a765a64e3f6cfe3521c" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "digest 0.11.3", -] - [[package]] name = "sha3" version = "0.10.9" @@ -5349,17 +3703,6 @@ dependencies = [ "sponge-cursor", ] -[[package]] -name = "shake" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09057cb2149ad4cbd2da1e26b351f9a4c354219421229c69c3063e6f61947c4a" -dependencies = [ - "digest 0.11.3", - "keccak 0.2.2", - "sponge-cursor", -] - [[package]] name = "sharded-slab" version = "0.1.7" @@ -5376,7 +3719,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32824fab5e16e6c4d86dc1ba84489390419a39f97699852b66480bb87d297ed8" dependencies = [ "bstr", - "dirs 6.0.0", + "dirs", "os_str_bytes", ] @@ -5427,15 +3770,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "signature" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" -dependencies = [ - "rand_core 0.10.1", -] - [[package]] name = "simd-adler32" version = "0.3.10" @@ -5448,16 +3782,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" -[[package]] -name = "skein" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96a90a220ab98dbbfeabeae7c558a79f37839c10b9ef55c77082a741a463cab7" -dependencies = [ - "digest 0.10.7", - "threefish", -] - [[package]] name = "slab" version = "0.4.12" @@ -5476,14 +3800,15 @@ dependencies = [ [[package]] name = "slotmap-careful" -version = "0.9.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e13aa7333b92ad3a6d3136abaa7fb5d8c19cc121441fcb435f6947d6ef2f8f7" +checksum = "ba7bcbd01d9b495f4509e74f660ebaf3315219b2f8a81753667ee7d6d8a199ac" dependencies = [ "paste", "serde", "slotmap", "thiserror 2.0.20", + "void", ] [[package]] @@ -5501,11 +3826,11 @@ dependencies = [ "aes-gcm", "blake2", "chacha20poly1305", - "curve25519-dalek 4.1.3", + "curve25519-dalek", "getrandom 0.3.4", "ring", "rustc_version", - "sha2 0.10.9", + "sha2", "subtle", ] @@ -5524,15 +3849,6 @@ name = "spin" version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spin" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "023a211cb3138dbc438680b32560ad89f699977624c9f8dbb95a47d5b4c07dd3" [[package]] name = "spki" @@ -5541,17 +3857,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", - "der 0.7.10", -] - -[[package]] -name = "spki" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef958a98b9d5da290cfc78946e9f3e61e1e62a18db0d92cac0b83cc161491a9" -dependencies = [ - "base64ct", - "der 0.8.2", + "der", ] [[package]] @@ -5578,7 +3884,7 @@ checksum = "e0cf03c3a7ea88451ff83a129a79451fd9891d44fc76c25e916a11848b81814c" dependencies = [ "base64ct", "pem-rfc7468", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -5594,8 +3900,8 @@ dependencies = [ "rand_core 0.6.4", "rsa", "sec1", - "sha2 0.10.9", - "signature 2.2.0", + "sha2", + "signature", "ssh-cipher-fork-arti", "ssh-encoding-fork-arti", "subtle", @@ -5614,30 +3920,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "std-shims" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "227c4f8561598188d0df96dbe749824576174bba278b5b6bb2eacff1066067d0" -dependencies = [ - "hashbrown 0.16.1", - "rustversion", - "spin 0.10.1", -] - -[[package]] -name = "strobe-rs" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83561175f0a962dea437885589480d216d8741debf853e0d36edd526344fd273" -dependencies = [ - "bitflags 2.13.2", - "byteorder", - "keccak 0.2.2", - "subtle", - "zeroize", -] - [[package]] name = "strsim" version = "0.10.0" @@ -5677,12 +3959,6 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" -[[package]] -name = "symlink" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a" - [[package]] name = "syn" version = "1.0.109" @@ -5733,17 +4009,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "synstructure" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - [[package]] name = "sysinfo" version = "0.38.4" @@ -5764,18 +4029,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "tapes" -version = "0.2.0" -source = "git+https://github.com/Cuprate/Tapes.git?rev=04562f4#04562f44fd8e029ce0caf7dfa993682ffe69837d" -dependencies = [ - "blake2", - "borsh", - "bytemuck", - "parking_lot", - "slab", -] - [[package]] name = "tempfile" version = "3.27.0" @@ -5789,16 +4042,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "terminal_size" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" -dependencies = [ - "rustix", - "windows-sys 0.61.2", -] - [[package]] name = "thiserror" version = "1.0.69" @@ -5848,12 +4091,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "threefish" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a693d0c8cf16973fac5a93fbe47b8c6452e7097d4fcac49f3d7a18e39c76e62e" - [[package]] name = "time" version = "0.3.55" @@ -5888,9 +4125,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.8.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" dependencies = [ "displaydoc", "serde_core", @@ -5914,14 +4151,13 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.54.1" +version = "1.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" dependencies = [ "bytes", "libc", "mio", - "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -5940,45 +4176,18 @@ dependencies = [ "syn 3.0.5", ] -[[package]] -name = "tokio-socks" -version = "0.5.2" -source = "git+https://github.com/Cuprate/tokio-socks.git?rev=8737caf#8737caf429a86ab181954444fac4f9b917795b19" -dependencies = [ - "either", - "futures-util", - "thiserror 1.0.69", - "tokio", -] - -[[package]] -name = "tokio-stream" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d06f0b082ba57c26b79407372e57cf2a1e28124f78e9479fe80322cf53420b" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", - "tokio-util", -] - [[package]] name = "tokio-util" -version = "0.7.20" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e464cf451ba96ebfc6f9b6542f17ee8b8956e33f1e40d9690624e59d7a7f8a4b" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" dependencies = [ "bytes", "futures-core", "futures-io", "futures-sink", - "futures-util", - "libc", "pin-project-lite", - "slab", "tokio", - "tracing", ] [[package]] @@ -5995,14 +4204,14 @@ dependencies = [ [[package]] name = "toml" -version = "1.2.3+spec-1.1.0" +version = "1.1.5+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b1f26e9485c1fa43ee89fe76e9f3fb9e2e52bb227f8594b4d687496b83d073" +checksum = "12c0ba9680044b4ce98d391a62094047eada0d64860b80166c39f4a6b5640785" dependencies = [ "indexmap 2.14.2", "serde_core", - "serde_spanned 1.1.3", - "toml_datetime 1.1.3+spec-1.1.0", + "serde_spanned 1.1.1", + "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", "toml_writer", "winnow 1.0.4", @@ -6019,9 +4228,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "1.1.3+spec-1.1.0" +version = "1.1.1+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" dependencies = [ "serde_core", ] @@ -6047,17 +4256,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b" dependencies = [ "indexmap 2.14.2", - "toml_datetime 1.1.3+spec-1.1.0", + "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", - "toml_writer", "winnow 1.0.4", ] [[package]] name = "toml_parser" -version = "1.1.7+spec-1.1.0" +version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb28d6e049a9766c3bd91a8326e6179f5b132dec87906bb97018ef7a2f3431a" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" dependencies = [ "winnow 1.0.4", ] @@ -6070,15 +4278,15 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] name = "toml_writer" -version = "1.2.0+spec-1.1.0" +version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" [[package]] name = "tor-async-utils" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea51881be51a4dff308071d7cf6489445fd658e821a8bf35c47a4830effd1ab" +checksum = "31d9f28de36ed7646f0f03835ce2e306e2c5df8a1784a2cac27bd549cdc07599" dependencies = [ "cfg-if", "derive-deftly", @@ -6102,9 +4310,9 @@ dependencies = [ [[package]] name = "tor-basic-utils" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235993fcf72e09e597e6b609d52b4cfc2f28bfa8ca827ed304127889639d5776" +checksum = "1a2bd42110ae0faea1d446b35899aa5c3591cd31a94b593aa9264f00baba41da" dependencies = [ "derive-deftly", "derive_more", @@ -6115,7 +4323,7 @@ dependencies = [ "itertools 0.15.0", "libc", "paste", - "rand 0.10.4", + "rand 0.10.2", "rand_chacha 0.10.0", "serde", "slab", @@ -6128,13 +4336,13 @@ dependencies = [ [[package]] name = "tor-bytes" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb3c0504ae2bca19b92e55c869fe58f68688505737ce2ddae85b60b9806ed4c" +checksum = "73de2ba54a125c27a440616f2d806a171bcb4e30013de166c7dc0a79bde44ab4" dependencies = [ "bytes", "derive-deftly", - "digest 0.11.3", + "digest 0.10.7", "educe", "getrandom 0.4.3", "safelog", @@ -6146,9 +4354,9 @@ dependencies = [ [[package]] name = "tor-cell" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6a814400b9bd2a8d07ee89057db816eed53b2b2719066f77630698f0bd2cb0" +checksum = "118f2b6a56605bedd077003ee5678fda215965d550dd0aef21ce8e10dd082750" dependencies = [ "amplify", "bitflags 2.13.2", @@ -6159,7 +4367,7 @@ dependencies = [ "educe", "itertools 0.15.0", "paste", - "rand 0.10.4", + "rand 0.10.2", "smallvec", "thiserror 2.0.20", "tor-basic-utils", @@ -6177,14 +4385,15 @@ dependencies = [ [[package]] name = "tor-cert" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68df0747b5d218cfb2c481b2a267bbdbf89dda2849911630e966eed3dc630f7b" +checksum = "b2cec6ae3abafc382e126a26e74f000bffbbf2c9b1a8c9ec26bb84463f0120b4" dependencies = [ "caret", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", + "saturating-time", "thiserror 2.0.20", "tor-bytes", "tor-checkable", @@ -6195,9 +4404,9 @@ dependencies = [ [[package]] name = "tor-chanmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b5dec2bf27e75dd65bfe9289f24eee230c49ac4a65f85f0ead3b3b3c19f51d" +checksum = "6cef673b170f10790ff81d2f190e0a8150e5c9683c2c8f4c09652a6954c0e5ab" dependencies = [ "async-trait", "base64ct", @@ -6211,7 +4420,7 @@ dependencies = [ "oneshot-fused-workaround", "percent-encoding", "postage", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", "serde_with", @@ -6238,13 +4447,13 @@ dependencies = [ [[package]] name = "tor-checkable" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee5237cfbec5e4e7860b6579932072e2dd3dfa91a950a3d2c4c8c253f405c4a" +checksum = "d3872a5bda49647ad4c4a822c58774995ad3acd02327f1cabe6cfc019d714535" dependencies = [ "humantime", "itertools 0.15.0", - "signature 3.0.0", + "signature", "thiserror 2.0.20", "tor-llcrypto", "web-time-compat", @@ -6252,9 +4461,9 @@ dependencies = [ [[package]] name = "tor-circmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bead875b0e3876110dbfa584ea65af47ed44ebc7ffebb32c460723837aa4843" +checksum = "2cf1eb6c2e3184c9e51c746df81f1a890ba7b663ac418debe2dac3756d840c8a" dependencies = [ "amplify", "async-trait", @@ -6271,7 +4480,7 @@ dependencies = [ "once_cell", "oneshot-fused-workaround", "pin-project", - "rand 0.10.4", + "rand 0.10.2", "retry-error", "safelog", "serde", @@ -6302,9 +4511,9 @@ dependencies = [ [[package]] name = "tor-config" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9788a9af2a0303e4c05a9bdbf08efbba485c4e92978f140713bc5e201f14580" +checksum = "dd8ca5684100c9223590c11685f3f39c4e4c0037c65daddc26927b3ae4cc893d" dependencies = [ "amplify", "cfg-if", @@ -6327,7 +4536,7 @@ dependencies = [ "serde_ignored", "strum", "thiserror 2.0.20", - "toml 1.2.3+spec-1.1.0", + "toml 1.1.5+spec-1.1.0", "tor-basic-utils", "tor-error", "tor-rtcompat", @@ -6337,9 +4546,9 @@ dependencies = [ [[package]] name = "tor-config-path" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d165d5b36b7518e8cf0a51a9ed831019cf9d02afd88b408f2ca8d922710565" +checksum = "cbed06099bacbdbb1d91cfff1032863896d6097c33eece067ab20756e4a6fa2b" dependencies = [ "directories", "serde", @@ -6351,12 +4560,12 @@ dependencies = [ [[package]] name = "tor-consdiff" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "543cd2e0796c7959fe89a2c264ea09ebbb0d1bb70ce4870a2b394ee8d099bbea" +checksum = "9760d0051159a257b1d0065615ad6bc023da4e178d41ff5640222a29852de848" dependencies = [ "derive_more", - "digest 0.11.3", + "digest 0.10.7", "hex", "imara-diff", "static_assertions", @@ -6368,9 +4577,9 @@ dependencies = [ [[package]] name = "tor-dirclient" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d683861c37ff8c0c522c5cdfed94a8f43d8c07fc9ae6ce3622ca29ec1b76db2" +checksum = "403a79a0d00de6c78f15773a284e790459cff6983449e8578490e6b5dfb2afcd" dependencies = [ "async-compression", "base64ct", @@ -6381,6 +4590,7 @@ dependencies = [ "httparse", "httpdate", "itertools 0.15.0", + "memchr", "thiserror 2.0.20", "tor-circmgr", "tor-error", @@ -6396,9 +4606,9 @@ dependencies = [ [[package]] name = "tor-dircommon" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c9d4239fe25e4797edc7cf7b6efb4935bcec4552d7fe1ed1b61a30b165736b6" +checksum = "dd5cd2a4f641ecb007cc50914bb1b46128de0975aba08baa56497c8e03c71c71" dependencies = [ "base64ct", "derive-deftly", @@ -6417,15 +4627,15 @@ dependencies = [ [[package]] name = "tor-dirmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed9e6665621160a7065f3bb56f7bbc77b85aff362f0950415dd882e8c22af9" +checksum = "805da4e947311285ce0782ab129df318701c2c08046c316086cb6bb3eb7a463e" dependencies = [ "async-trait", "base64ct", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "event-listener", "fs-mistrust", @@ -6439,14 +4649,13 @@ dependencies = [ "oneshot-fused-workaround", "paste", "postage", - "rand 0.10.4", + "rand 0.10.2", "rusqlite", "safelog", - "saturating-time", "scopeguard", "serde", "serde_json", - "signature 3.0.0", + "signature", "static_assertions", "strum", "thiserror 2.0.20", @@ -6475,9 +4684,9 @@ dependencies = [ [[package]] name = "tor-error" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1caef18eb269eab70a6244cbfc003e92c8a28c4017fa5f7cb17be718787f151c" +checksum = "08f29e906f9f333a6e32e32afac9fb6712ac340191eb3292295b3337682b2dad" dependencies = [ "derive_more", "futures", @@ -6493,9 +4702,9 @@ dependencies = [ [[package]] name = "tor-general-addr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09068bc76af4da4bbf0f17be95693c02253b12ed0aa2b4979bee786a1c7f24b5" +checksum = "7b45ecd95dbf79070f9e477e1d84b22e47f03b2ab2f853abe31887daa9090cf0" dependencies = [ "derive_more", "thiserror 2.0.20", @@ -6504,9 +4713,9 @@ dependencies = [ [[package]] name = "tor-guardmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d430b1785b1e8f6569043b2ae2ca6c340ff5327f39ba3a19b7cfa9c99ad9a1d" +checksum = "3e84beedbf276ce4ea170206b38ca01c995dbf1b9f678e9708f50e2e71dbfef4" dependencies = [ "amplify", "base64ct", @@ -6523,9 +4732,8 @@ dependencies = [ "oneshot-fused-workaround", "pin-project", "postage", - "rand 0.10.4", + "rand 0.10.2", "safelog", - "saturating-time", "serde", "strum", "thiserror 2.0.20", @@ -6549,9 +4757,9 @@ dependencies = [ [[package]] name = "tor-hsclient" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa940dbbff0c4c9323623acb4a49ac40fa227a6a3a07236918f4723db6ab7f9c" +checksum = "3eba66be03b5eb899185e5b4416d8893fdb09a97b33db9e450042f06e2550f0e" dependencies = [ "async-trait", "cfg-if", @@ -6563,7 +4771,7 @@ dependencies = [ "itertools 0.15.0", "oneshot-fused-workaround", "postage", - "rand 0.10.4", + "rand 0.10.2", "retry-error", "safelog", "slotmap-careful", @@ -6595,23 +4803,23 @@ dependencies = [ [[package]] name = "tor-hscrypto" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a262916c319c77cd6dacb3c2aa1e1cdae1d2bf40dae18b1138cf9d544b927dc2" +checksum = "118ff6a69bfa111b6e8d087ffb107ea9cbcd5d4469295cd7ada1b3cf19ba5a0f" dependencies = [ "cipher 0.5.2", "data-encoding", "derive-deftly", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "hex", "humantime", "itertools 0.15.0", "paste", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", - "signature 3.0.0", + "signature", "subtle", "thiserror 2.0.20", "tor-basic-utils", @@ -6628,9 +4836,9 @@ dependencies = [ [[package]] name = "tor-hsservice" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cfbd1aa7939e12a7dc56b6eefc1e44444de1f0bdf1a5fbd2eb897e4286733c9" +checksum = "d61a6b5217c14780f54fa1c8610514b1349c93f657304dec98bd8e3083e1a09f" dependencies = [ "amplify", "async-trait", @@ -6639,7 +4847,7 @@ dependencies = [ "derive-deftly", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "fs-mistrust", "futures", @@ -6651,7 +4859,7 @@ dependencies = [ "once_cell", "oneshot-fused-workaround", "postage", - "rand 0.10.4", + "rand 0.10.2", "rand_core 0.10.1", "retry-error", "safelog", @@ -6687,17 +4895,17 @@ dependencies = [ [[package]] name = "tor-key-forge" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2788d37b8b723a83da9c3f22ee44530ffef4bf0fb13588bd88f44c90cdaa9bae" +checksum = "1861b5eebab93515a0ab2401540f3d5a9fb376f1b1535d5793dcd697fb19f928" dependencies = [ "derive-deftly", "derive_more", "downcast-rs", "paste", - "rand 0.10.4", + "rand 0.10.2", "rsa", - "signature 3.0.0", + "signature", "ssh-key-fork-arti", "thiserror 2.0.20", "tor-bytes", @@ -6709,13 +4917,13 @@ dependencies = [ [[package]] name = "tor-keymgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119f0f26e6b2a11cd0868374a2287c786e97f22330cd8a8ff69cee96b08670cb" +checksum = "b3088a573dadebb34acacb30d686751e2a94d12ccf9d6647946ab6c6b4ad5a0e" dependencies = [ "amplify", + "arrayvec", "cfg-if", - "data-encoding", "derive-deftly", "derive_builder_fork_arti", "derive_more", @@ -6726,10 +4934,10 @@ dependencies = [ "humantime", "inventory", "itertools 0.15.0", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", - "signature 3.0.0", + "signature", "ssh-key-fork-arti", "thiserror 2.0.20", "tor-basic-utils", @@ -6750,9 +4958,9 @@ dependencies = [ [[package]] name = "tor-linkspec" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bb55ea69084a82b1f69709059ecfcfb3097adaad6d522dff99d8c52735cb899" +checksum = "6d8d3a2aaf3bb67110218b9ff1718cd7d6c7e62226e2fee1a18efa6aa19ff07c" dependencies = [ "base64ct", "by_address", @@ -6777,25 +4985,25 @@ dependencies = [ [[package]] name = "tor-llcrypto" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1f114c13c14b0b2668304e2c9f102534ef95a2a004d1294ede969211c9bc60d" +checksum = "4fee81755528eb34f8352ca6987d5f5c66ebba6af2e4618da4b527f17b0e912e" dependencies = [ "aes 0.9.3", "base64ct", "ctr 0.10.1", - "curve25519-dalek 5.1.0", + "curve25519-dalek", "der-parser", "derive-deftly", "derive_more", - "digest 0.11.3", - "ed25519-dalek 3.0.0", + "digest 0.10.7", + "ed25519-dalek", "educe", "getrandom 0.2.17", "getrandom 0.3.4", "getrandom 0.4.3", "hex", - "rand 0.10.4", + "rand 0.10.2", "rand_chacha 0.10.0", "rand_core 0.10.1", "rand_core 0.6.4", @@ -6806,24 +5014,23 @@ dependencies = [ "safelog", "serde", "sha1", - "sha2 0.11.3", - "sha3 0.12.0", - "shake", - "signature 3.0.0", + "sha2", + "sha3 0.10.9", + "signature", "subtle", "thiserror 2.0.20", "tor-error", "tor-memquota-cost", "visibility", - "x25519-dalek 3.0.0", + "x25519-dalek", "zeroize", ] [[package]] name = "tor-log-ratelim" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eea1296076775d399e0b750117c2e1cfba7fe9463add26f056b7c1397c9a3357" +checksum = "2f8696c8ea9090059d91eea287628b5df0b3b4fba433179d893e348857857544" dependencies = [ "futures", "humantime", @@ -6837,9 +5044,9 @@ dependencies = [ [[package]] name = "tor-memquota" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "075e39b9ac84cd15c8249df1499c642e2fbea2a02cc7f146f19df31d771be0dc" +checksum = "03786604757846a5f936285eef397e3fc0ed455893dc5012ceafdf455ada0d8d" dependencies = [ "cfg-if", "derive-deftly", @@ -6869,9 +5076,9 @@ dependencies = [ [[package]] name = "tor-memquota-cost" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7fc75adc50ee789c2ef1633f95647aefc10942bb8a9e6294343dfb574c616c" +checksum = "86d6f7e1d842e6272e414e1f866dc688306b788d368df42e47c4995e040c679c" dependencies = [ "derive-deftly", "itertools 0.15.0", @@ -6881,20 +5088,20 @@ dependencies = [ [[package]] name = "tor-netdir" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27eb00ecbb05d92471bf7ca386ac929ebca28e1034893045679645293bbddbd0" +checksum = "9d3b84edfe732b77fb1420347902c06d92a1e6992e378ad19da6bdadcb8cd798" dependencies = [ "async-trait", "bitflags 2.13.2", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "futures", "hex", "humantime", "itertools 0.15.0", "num_enum", - "rand 0.10.4", + "rand 0.10.2", "serde", "strum", "thiserror 2.0.20", @@ -6914,9 +5121,9 @@ dependencies = [ [[package]] name = "tor-netdoc" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4f3fdfb2e47f82c6a15c11fb9bfac8bd4ec9e4bbff786fc23a8f8438436f040" +checksum = "5b6abd7aaeb2bdbb3fbf760aab9aaa4e8e1a0f8b84d93a834df5a16882faa31e" dependencies = [ "amplify", "base64ct", @@ -6924,7 +5131,7 @@ dependencies = [ "derive-deftly", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "enumset", "extend", @@ -6937,12 +5144,12 @@ dependencies = [ "memchr", "paste", "phf", - "rand 0.10.4", + "rand 0.10.2", "rangemap", "saturating-time", "serde", "serde_with", - "signature 3.0.0", + "signature", "smallvec", "strum", "subtle", @@ -6967,9 +5174,9 @@ dependencies = [ [[package]] name = "tor-persist" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48567a8e69f69edc6cfc3a7bfcd83e9ffb8c16617e81b6a4fbe11c391bd6356f" +checksum = "e6f2a41d13a685e181361cfc3bdf25d319b96b56f5806594b6b8ed760d0099ed" dependencies = [ "amplify", "derive-deftly", @@ -6987,6 +5194,7 @@ dependencies = [ "serde_json", "thiserror 2.0.20", "time", + "tor-async-utils", "tor-basic-utils", "tor-error", "tracing", @@ -6996,9 +5204,9 @@ dependencies = [ [[package]] name = "tor-proto" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ee0a62b16f6bde3e1dee30a20e6c6755c5cd912e781c01b96c9d451886848d" +checksum = "0ddf767335ae2e255025536d48384b92c6b4b8557e5b345be600e7ca2de1c880" dependencies = [ "aes 0.9.3", "amplify", @@ -7014,21 +5222,20 @@ dependencies = [ "derive-deftly", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "enum_dispatch", "futures", "futures-util", - "hkdf 0.13.0", - "hmac 0.13.0", + "hkdf", + "hmac", "itertools 0.15.0", - "metrics", "nonany", "oneshot-fused-workaround", "pin-project", "polyval 0.7.3", "postage", - "rand 0.10.4", + "rand 0.10.2", "rand_core 0.10.1", "safelog", "slotmap-careful", @@ -7054,6 +5261,7 @@ dependencies = [ "tor-memquota", "tor-protover", "tor-rtcompat", + "tor-rtmock", "tor-units", "tracing", "typenum", @@ -7065,14 +5273,12 @@ dependencies = [ [[package]] name = "tor-protover" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac0c7d7cc07222e72cc77231839d23259e4a1fdbbb02345c6c85d8ba142ad352" +checksum = "cab080a7551561bd56c0c2e3578b7114f0853700b96e43613fabc1fe06e5d885" dependencies = [ "caret", "derive-deftly", - "derive_more", - "itertools 0.15.0", "paste", "serde_with", "thiserror 2.0.20", @@ -7082,11 +5288,11 @@ dependencies = [ [[package]] name = "tor-relay-selection" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91947cd895147e04a4600103608a3e935541d399e1a0b1b400788ceb7583b6c5" +checksum = "07a5c22b7cfd59c40e38d4e111906793c0d65cf881e31efe3a83cac42887b1c9" dependencies = [ - "rand 0.10.4", + "rand 0.10.2", "serde", "tor-basic-utils", "tor-linkspec", @@ -7096,9 +5302,9 @@ dependencies = [ [[package]] name = "tor-rtcompat" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ecbaf82921338764c80b302abf5a75671400cc26d1daf3ee91826c653d5b9fc" +checksum = "542f4e13054bbba8d764ee24178fd889f77afb59dca7c6ae0a370604118c20b6" dependencies = [ "amplify", "async-native-tls", @@ -7112,15 +5318,11 @@ dependencies = [ "dyn-clone", "educe", "futures", - "futures-rustls", "hex", "libc", "native-tls", "paste", "pin-project", - "rustls", - "rustls-pki-types", - "rustls-webpki", "socket2", "thiserror 2.0.20", "tokio", @@ -7134,11 +5336,42 @@ dependencies = [ ] [[package]] -name = "tor-socksproto" -version = "0.49.0" +name = "tor-rtmock" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "040951b4e279a0ac1b315a4845b69557f7d1ea1376fa911d482333b0693225a6" +checksum = "04cb78b3a39634e46c1bc795f62fca17b4d8a9404fead18750592a03216e1da3" dependencies = [ + "amplify", + "assert_matches", + "async-trait", + "derive-deftly", + "derive_more", + "educe", + "futures", + "humantime", + "itertools 0.15.0", + "oneshot-fused-workaround", + "pin-project", + "priority-queue", + "slotmap-careful", + "strum", + "thiserror 2.0.20", + "tor-error", + "tor-general-addr", + "tor-rtcompat", + "tracing", + "tracing-test", + "void", + "web-time-compat", +] + +[[package]] +name = "tor-socksproto" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f96e25e5d36b4aff59af40ec86f7ebb227a32b2f726ef1bc8cccf927f8fb31a" +dependencies = [ + "amplify", "caret", "derive-deftly", "educe", @@ -7151,9 +5384,9 @@ dependencies = [ [[package]] name = "tor-units" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475566f8ee463e219980befbdc7b46397c1db5a8f54bd6ac75c41563712c5903" +checksum = "9a562c031f6c1f9d22f7bbcfbe715840d0e2cfe5e59d1296cc26000c17130555" dependencies = [ "derive-deftly", "derive_more", @@ -7162,54 +5395,6 @@ dependencies = [ "tor-memquota", ] -[[package]] -name = "tower" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" -dependencies = [ - "futures-core", - "futures-util", - "pin-project-lite", - "sync_wrapper", - "tokio", - "tokio-util", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-http" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c" -dependencies = [ - "bitflags 2.13.2", - "bytes", - "http", - "http-body", - "http-body-util", - "percent-encoding", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" - -[[package]] -name = "tower-service" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" - [[package]] name = "tracing" version = "0.1.44" @@ -7221,19 +5406,6 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-appender" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "050686193eb999b4bb3bc2acfa891a13da00f79734704c4b8b4ef1a10b368a3c" -dependencies = [ - "crossbeam-channel", - "symlink", - "thiserror 2.0.20", - "time", - "tracing-subscriber", -] - [[package]] name = "tracing-attributes" version = "0.1.31" @@ -7285,10 +5457,25 @@ dependencies = [ ] [[package]] -name = "twox-hash" -version = "2.1.4" +name = "tracing-test" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5283634e518fe9e82c7b20520bb4bc209009fd16c82077c802f8111ecbb0117a" +checksum = "19a4c448db514d4f24c5ddb9f73f2ee71bfb24c526cf0c570ba142d1119e0051" +dependencies = [ + "tracing-core", + "tracing-subscriber", + "tracing-test-macro", +] + +[[package]] +name = "tracing-test-macro" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad06847b7afb65c7866a36664b75c40b895e318cea4f71299f013fb22965329d" +dependencies = [ + "quote", + "syn 2.0.119", +] [[package]] name = "typed-index-collections" @@ -7306,12 +5493,6 @@ version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" -[[package]] -name = "unarray" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" - [[package]] name = "uncased" version = "0.9.10" @@ -7412,12 +5593,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" -[[package]] -name = "varint-rs" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa6c38708f6257f1ec2ca7e5a11f9bbf58a27d7060078b6b333624968183d96" - [[package]] name = "vcpkg" version = "0.2.15" @@ -7447,15 +5622,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -[[package]] -name = "wait-timeout" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" -dependencies = [ - "libc", -] - [[package]] name = "walkdir" version = "2.5.0" @@ -7557,9 +5723,9 @@ dependencies = [ [[package]] name = "web-time-compat" -version = "0.3.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f854754465eaf0d17b96236f75c6ddfaebf5907dc31c24ecdc265ffe609756c5" +checksum = "b6ab47578e1cd38415489592da29326341e272bd281f4ddbc0c10b654a425ad7" dependencies = [ "web-time", ] @@ -7915,23 +6081,12 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "rand_core 0.6.4", "serde", "zeroize", ] -[[package]] -name = "x25519-dalek" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e8131a03190127fb2263afc72b322ecadae46b6ff8c6f399ff5d02f5559af6" -dependencies = [ - "curve25519-dalek 5.1.0", - "rand_core 0.10.1", - "zeroize", -] - [[package]] name = "xxhash-rust" version = "0.8.18" @@ -7940,9 +6095,9 @@ checksum = "aee1b19627c7c60102ab80d3a9cbe18de90bfe03bfa6c3715447681f0e8c8af6" [[package]] name = "yoke" -version = "0.8.4" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" dependencies = [ "stable_deref_trait", "yoke-derive", @@ -7951,14 +6106,14 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.8.4" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", - "syn 3.0.5", - "synstructure 0.14.0", + "syn 2.0.119", + "synstructure", ] [[package]] @@ -7999,7 +6154,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.119", - "synstructure 0.13.2", + "synstructure", ] [[package]] @@ -8035,9 +6190,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.9" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" dependencies = [ "serde", "yoke", @@ -8047,9 +6202,9 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.7" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 7002734..eaded20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,91 +1,28 @@ [package] name = "onionwire" -version = "0.2.1" +version = "0.1.2" edition = "2024" -# 1.98, not 1.92. Arti 0.49 builds on 1.92, but the default feature set includes -# `cuprate-daemon`, and `tapes` (a Cuprate dep this repo cannot patch) calls -# `VecDeque::pop_front_if`, stable only from 1.93. 1.98 is the release CI and -# the Android workflows actually build that graph with. `--no-default-features` -# does not need it; `cargo` checks `rust-version` before features, so the -# declared floor is the default build's floor. -rust-version = "1.98" +rust-version = "1.91" description = "Lean Tor messenger: Arti in-process, identity=pubkey, onion=locator. No XMPP." license = "MIT" publish = false -repository = "https://forgejo.siriusdevops.com/sirius/onionwire" - -# TLS backend: `rustls` by default, `native-tls` (OpenSSL) opt-in. -# -# 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 = ["rustls", "cuprate-daemon"] -native-tls = ["arti-client/native-tls"] -rustls = ["arti-client/rustls"] -# In-process Monero chain daemon (Cuprate) as the local chain source, instead of -# spawning `monerod`. ON in the Linux TUI/release binary (this default). A build -# with `--no-default-features` does not include it. `cuprated` is pre-1.0 and is -# not published to crates.io (every Cuprate crate there is a `0.0.0-placeholder` -# name reservation), so this pins a git revision and pulls a large tree (RandomX, -# fjall, axum/hyper, rayon). See `docs/WALLET.md`, "The in-process chain daemon". -# -# Cuprate's own `arti` feature stays OFF (and is off in its default feature set, -# which is why `default-features = false` is load-bearing): it would link a -# second, older Tor stack (arti-client 0.44, which cannot unify with this -# crate's 0.49) next to OnionWire's. The in-process daemon runs clearnet-only; -# OnionWire's Arti is the only Tor in the process. -cuprate-daemon = ["dep:cuprated", "dep:toml"] +repository = "https://github.com/sirius0xdev/onionwire" [dependencies] -arti-client = { version = "0.49", default-features = false, features = [ - "tokio", - "onion-service-client", - "onion-service-service", - "compression", -] } +arti-client = { version = "0.46", features = ["tokio", "onion-service-client", "onion-service-service"] } futures = "0.3" -safelog = "0.10" +safelog = "0.9" ed25519-dalek = { version = "2", features = ["rand_core"] } rand = "0.8" -rusqlite = { version = "0.36", features = ["bundled-sqlcipher-vendored-openssl"] } -tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-util", "time", "net"] } -tor-cell = "0.49" -tor-hsservice = "0.49" -tor-rtcompat = { version = "0.49", 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"] } +rusqlite = { version = "0.36", features = ["bundled"] } +tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-util", "time"] } +tor-cell = "0.46" +tor-hsservice = "0.46" +tor-rtcompat = { version = "0.46", features = ["tokio"] } +qrcode = { version = "0.14.1", default-features = false } ratatui = { version = "0.30.2", default-features = false, features = ["crossterm"] } x25519-dalek = { version = "2", features = ["static_secrets"] } snow = "0.10" -serde_json = "1" -hkdf = "0.12" -hmac = "0.12" -argon2 = "0.5" -chacha20poly1305 = "0.10" -sha3 = "0.10" -sha2 = "0.10" -md-5 = "0.10" -rpassword = "7" -zeroize = { version = "1", features = ["derive"] } -# ML-KEM-768 (FIPS 203). `zeroize` wipes the decapsulation key; `getrandom` -# is how 0.3's `generate_keypair` / `encapsulate` reach the OS RNG. This -# crate's `rand` 0.8 cannot: ml-kem speaks `rand_core` 0.10. -ml-kem = { version = "0.3", features = ["zeroize", "getrandom"] } -qrcode = { version = "0.14", default-features = false } -cuprated = { git = "https://github.com/Cuprate/cuprate", rev = "4f8fcd1bf468f566fcd89c460d50de4adb6825bf", default-features = false, optional = true } -# `cuprated::config::Config` is deserialized, not built field by field: the -# struct's nested types move with the pinned revision, a TOML document does not. -# Cuprate has `deny_unknown_fields` on every config struct, so a stale key is a -# parse error instead of a silently ignored setting. -toml = { version = "0.8", features = ["parse", "display"], optional = true } [dev-dependencies] tempfile = "3" diff --git a/README.md b/README.md index 21bc666..5fd576c 100644 --- a/README.md +++ b/README.md @@ -1,116 +1,70 @@ # OnionWire Lean Tor messenger: one Rust process (ratatui + Noise IK + sqlite + in-process Arti). -No hosted server. Identity is an ed25519 public key; the onion is only a locator. +Two people scan a QR, then chat. No hosted server. Identity is a public key; the onion is only a locator. -Current tagged release: **v0.7.0**. Linux TUI + Android SDK/APK. Two people add -each other with an `onionwire:v2:…` invite string (`F2` share / `F3` paste; -~1.9 KB because it carries an ML-KEM-768 key). There is no invite QR graphic. -Chat is Noise IK over your own v3 onion; when the friend was added from a v2 -invite the session is **hybrid** (ML-KEM-768 prelude mixed into the Noise -prologue). A friend from a legacy `onionwire:v1` invite stays classical and the -roster labels them `classical`. 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. 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). -TUI keys: [docs/TUI.md](docs/TUI.md). Wallet: [docs/WALLET.md](docs/WALLET.md). -Releases: [docs/RELEASING.md](docs/RELEASING.md). Verifying a download: -[docs/VERIFY.md](docs/VERIFY.md). +You do **not** install a `tor` daemon, `torrc`, Prosody, or XMPP. OnionWire embeds Arti and publishes its own v3 onion. ## Install -Pick one: a CI-built binary, or build from source. +Pick one: a CI-built binary (fastest), or build from source. ### Requirements | Need | Notes | |---|---| | Linux | x86_64 or aarch64. TUI needs a real terminal (not a pipe). | -| Network | First run bootstraps Tor via Arti. Offline start fails closed. | +| Network | First run bootstraps Tor via Arti. Offline start will fail closed. | | Not needed | `tor` package, `torrc`, Prosody, an XMPP account, a DHT. | -Arti onion services are still **experimental**. If the hidden service cannot come -up, OnionWire exits. +Arti onion services are still **experimental**. If the hidden service cannot come up, OnionWire exits — it does not fall back to C-tor. ### Option A — download a release binary -CI does **not** release on a merge. Releases are manual and batched: a maintainer -dispatches `.forgejo/workflows/release.yml` at a stopping point (`dry_run=true` -first), which tags the next `v*.*.*` version and publishes both Linux binaries to -one [Forgejo release](https://forgejo.siriusdevops.com/sirius/onionwire/releases). -The Android APK + AAR attach to **the same tag** by a second dispatch of -`android-release` with `tag=`. Policy: [docs/RELEASING.md](docs/RELEASING.md). -This Forgejo does not serve `/releases/latest/download/…` (404); pin the tag. +CI (`.forgejo/workflows/release.yml`, Forgejo Actions on the Pi runner) builds the **aarch64** binary on every `v*.*.*` tag and attaches it to the [Forgejo release](https://forgejo.siriusdevops.com/sirius/onionwire/releases). There is no x86_64 runner on this instance, so the **x86_64** asset is built and uploaded by `scripts/build-release-local.sh` on an x86_64 host — both land on the same release page. -Every asset is signed with minisign, and every binary is reproducible from its -tag: pin the builder image by digest, fix the build paths and `SOURCE_DATE_EPOCH`, -and the published hash can be rebuilt and compared by anyone. Before running a -download, read [docs/VERIFY.md](docs/VERIFY.md). Each release carries -`build-info-.txt` (commit, epoch, toolchain, builder image digest, -resulting hash) next to its `.sha256`. - -**x86_64:** +**x86_64 (most PCs / VMs):** ```bash -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.7.0/onionwire-x86_64-unknown-linux-gnu -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.7.0/onionwire-x86_64-unknown-linux-gnu.sha256 +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/latest/download/onionwire-x86_64-unknown-linux-gnu +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/latest/download/onionwire-x86_64-unknown-linux-gnu.sha256 sha256sum -c onionwire-x86_64-unknown-linux-gnu.sha256 chmod +x onionwire-x86_64-unknown-linux-gnu ./onionwire-x86_64-unknown-linux-gnu --version ``` -**aarch64:** +**aarch64 (Raspberry Pi, ARM servers):** ```bash -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.7.0/onionwire-aarch64-unknown-linux-gnu -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.7.0/onionwire-aarch64-unknown-linux-gnu.sha256 +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/latest/download/onionwire-aarch64-unknown-linux-gnu +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/latest/download/onionwire-aarch64-unknown-linux-gnu.sha256 sha256sum -c onionwire-aarch64-unknown-linux-gnu.sha256 chmod +x onionwire-aarch64-unknown-linux-gnu ./onionwire-aarch64-unknown-linux-gnu --version ``` -Install onto `PATH` (keep the asset filename until after `sha256sum -c`): +Install onto `PATH` if you want `onionwire` as a command (keep the asset filename until after `sha256sum -c`): ```bash mkdir -p ~/.local/bin install -m 755 onionwire-x86_64-unknown-linux-gnu ~/.local/bin/onionwire +# ensure ~/.local/bin is on PATH, then: onionwire ``` -The app-owned wallet child looks for an executable named `monero-wallet-rpc` in -the same directory as the OnionWire binary, then on `PATH`. A remote daemon and -a remote wallet RPC stay available on F7. An absolute path configured for the -wallet-rpc binary is used as given. To place the official binary beside -`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. -```bash -scripts/fetch-monero-wallet-rpc.sh ~/.local/bin -``` - -The binary is dynamically linked against glibc (Ubuntu 24.04 builders). If it -dies with `GLIBC_… not found`, use Option B. Checksum files are `sha256sum` -format (` onionwire-`). +Checksum files are `sha256sum` format (` onionwire-`). Download both files with `curl -O` so the names match, then `sha256sum -c`. ### Option B — build from source -Needs [Rust](https://rustup.rs/) **1.98+** (`edition = "2024"`; `Cargo.toml` -`rust-version = "1.98"`). Arti 0.49 itself builds on 1.92, but the default -feature set includes the in-process chain daemon, and that graph does not -(`tapes` calls `VecDeque::pop_front_if`, stable since 1.93). Do not install `tor`. +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. ```bash +# rustup (if you do not already have cargo) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source "$HOME/.cargo/env" -rustc --version # must be 1.98 or newer +rustc --version # must be 1.91 or newer ``` ```bash @@ -123,292 +77,95 @@ cargo build --release --locked ./target/release/onionwire ``` +Install the binary: + ```bash cargo install --path . --locked --force # lands in ~/.cargo/bin/onionwire ``` -Build needs a C toolchain plus `perl` and `make`: SQLCipher is compiled from -vendored OpenSSL (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`). No -system OpenSSL headers or `pkg-config` are required — Arti's TLS backend is -`rustls`. - -The crate version in `Cargo.toml` is **not** bumped by the release workflow. The -tag (`v0.7.0`) is the version users download; `onionwire --version` prints -`CARGO_PKG_VERSION` from the tree that was built. +Build needs `pkg-config` and OpenSSL 3 headers (`libssl-dev` / `openssl-devel`) — +the released binaries link `libssl.so.3` dynamically. ### Two instances on one machine -Each process needs its own data dir: +Each process needs its own data dir (identity + onion + sqlite): ```bash ONIONWIRE_HOME=/tmp/ow-a ./onionwire ONIONWIRE_HOME=/tmp/ow-b ./onionwire ``` -Then `F2` on A, `F3`-paste on B (and the other way). No invite QR. +Then F2 on A, F3-paste on B (and the other way around). -## Run +## First run -There are **no subcommands**. Flags are `--version` / `-V` and `--help` / `-h` -only (`src/main.rs`). Anything else exits 2 with `onionwire: unknown argument`. - -```bash +``` onionwire ``` or `cargo run --release`. -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). +On start you should see `onionwire: bootstrapping Arti…` on stderr. First bootstrap can take a minute. 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. ## 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. - -## 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. +A friend is an ed25519 pubkey (`UNIQUE(pubkey)`). The `.onion` on that row is only where they are reachable right now. Re-scanning the same `k` updates the locator; it never creates a second person. ## Keys (TUI) -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 `?`). +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 `?`). | Key | Action | |---|---| | `Tab` / `Shift-Tab` | Cycle focus: roster → chat → composer | -| `1` / `2` / `3` | Focus roster / chat / composer (Main, when not typing) | +| `1` / `2` / `3` | Focus roster / chat / composer (when not typing) | | `j` `k` / `↑` `↓` | Move or scroll the focused pane | | `g` / `G` | Jump to top / bottom of the focused pane | | `?` | Keybinding help (`Esc` closes) | -| `F2` | Share invite (`onionwire:v2:…`, ~1.9 KB) | -| `F3` | Paste a friend's invite | +| `F2` | Share: terminal QR + payload | +| `F3` | Paste a friend’s payload | | `F4` | Rotate **onion** (locator only) | -| `F5` | Selected friend's profile (`/who`) | -| `F6` | Wallet (receive QR, balance, transfers, create/import) | -| `F7` | Node & wallet setup (wallet RPC endpoint, chain source, start/stop, live node state) | -| `F8` | Rotate **prekey and ML-KEM key** (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 | Run `/wipe` or `/wipe-all` from the 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 | -`F7` is where the Monero side is set up: the wallet RPC endpoint and login, the -chain source (receive-only, a local `monerod`, a remote daemon, or the in-process -Cuprate node), the chain datadir, and `Ctrl-S`/`Ctrl-X` to start and stop it. It -is also what the “open F7” wallet error points at. Full map: -[docs/TUI.md](docs/TUI.md). +## F2 QR -Composer `/commands` (`src/tui.rs` `parse_cmd`): `/wipe`, `/wipe-all`, `/profile`, -`/who`, `/pay [memo]`, `/tip [memo]`, `/backup /path`, `/restore /path`, -`/file /path`, `/settings`, `/wallet create`, `/wallet import`. +`F2` shows a terminal QR and the payload: -## F2 / F3 invite +`onionwire:v1:k=…:o=…:spk=…:sig=…` -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:v2:k=…:o=…:spk=…:kem=…:sig=…` - -The `kem=` field is the 1184-byte ML-KEM-768 public key (base64url), so the -string is about 1.9 KB instead of a few hundred bytes; `C` copies the whole -payload even when the terminal is too short to display all of it. Decode still -accepts a legacy `onionwire:v1:…` invite (no `kem=`): that friend is added as a -**classical** peer and the roster says `classical` next to them. There is no -silent upgrade — only a new signed v2 invite changes that. - -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/KEM key) only. - -No PQ for a legacy v1 peer: they have no `kem_pk`, so the session uses the old -`onionwire-v1` prologue with no ML-KEM secret. A v2 friend always sends the -prelude; a peer that omits it is hard-failed with `prelude required`. A v1-only -build cannot talk to a v2 friend, and that break is intentional. +`F3` pastes a payload. Unknown `k` asks for approval. Same `k` already in the roster updates `onion` only. ## F4 rotate onion -`F4` is a locator change, not a new identity. Confirm by typing `ROTATE` (Enter -alone does nothing). +`F4` is a locator change, not a new identity. Confirm by typing `ROTATE` (Enter alone does nothing). -- Identity fingerprint stays the same. +- Your identity fingerprint stays the same. - A new onion is published; the old one is hard-cut (no dual-host grace). - Online friends get a signed `loc` frame. -- Offline friends cannot find you until they F3-paste the new invite. There is no directory. +- Offline friends cannot find you until they rescan the new QR. There is no directory. -## Local outbox (chat) and fail closed +## Fail closed -**Chat** to an unreachable onion is written to a local `outbox` row and retried -in-process while the app runs (exponential backoff from 30s, cap 30 min, stop -after 8 attempts or a terminal failure — `src/outbox.rs`). There is **no** -server-side queue and **no** store-and-forward relay — a queued message never -leaves the device, and it dies with the device. - -- **Device seizure.** A pending message sits in the same SQLCipher store as the - rest of the history. Seizure *with* the passphrase reveals messages that were - never sent; seizure without it reveals nothing in this store. `/wipe` clears - outbox rows with chat history; `/wipe-all` removes them with the data dir. - Neither is a forensic erase. -- **Retry cadence is a local traffic-analysis surface.** A queued send re-dials - the peer's onion on a backoff schedule while the app runs. - -Still **fail closed** (no queue, no retry): - -- file transfer (`/file`) and payment frames (`inv` / `rcp` / `tip`) -- fingerprint mismatch vs the pinned key -- Arti cannot publish the onion (no C-tor fallback) -- no DHT, no name server, no hosted chat server - -## Chat ratchet - -Chat is ratcheted on top of the Noise session: each chat send is Double-Ratchet -encrypted first, and the resulting `rat ` frame is what the one-shot Noise -session carries. Wire format: [docs/PROTOCOL.md](docs/PROTOCOL.md). - -- Per-friend state lives in the encrypted store (`ratchet_sessions`). Nothing - about it is transmitted. -- **Only chat is ratcheted.** `loc`, `prf`, `inv`, `rcp`, `tip`, `png`, and - `fil` keep the one-shot Noise shape. -- **Chat length is bucketed.** The chat line is padded inside the ratchet - ciphertext to one fixed ladder size (256 B to 32 KiB), so the wire shows a - bucket rather than the exact message length. Timing and retry cadence are - still observable; this hides length only. -- Out-of-order delivery works (bounded skipped keys: 2000 per chain jump, 2000 - stored). A queued chat message re-sends the *same* `rat ` frame. -- `/wipe` clears chat, payments and outbox but **keeps** ratchet state. `/wipe-all` - removes the data dir. -- There is no `/reset`. State drops when the friend's prekey or ML-KEM key - changes (you `F3`-paste a refreshed invite). -- **Ratchet steps are hybrid; epoch 0 is not.** Every rotation after the - bootstrap mixes an ML-KEM-768 secret into the chain KDF, so a later X25519 - break does not open a hybrid chain. The bootstrap epoch is still derived only - from the two X25519 prekeys — a per-session KEM secret cannot be folded in - without breaking both-send-first convergence — so messages sent before the - first rotation stay X25519-only at the ratchet layer, and classical (v1) - friends have no PQ layer at all. No full post-quantum forward secrecy is - claimed; see [docs/THREAT_MODEL.md](docs/THREAT_MODEL.md). -- An inbound `rat ` frame that does not authenticate is logged as - `rat dropped ()` on stderr and dropped. There is no in-app desync banner. - -## File transfer - -`/file /path` sends a local file to the selected friend. Both must be online. -Cap 1 MiB (`file::MAX_BYTES`). Fail closed: a bad chunk or hash mismatch deletes -the partial. Files land in `$ONIONWIRE_HOME/inbox//`. Chat shows -`[file] name (N bytes)`. Not covered by the chat outbox. - -## Profile - -`/profile` edits your friend-visible display name, bio, and optional Monero -address (64 / 512 byte limits, no images). Enter saves and one-shot sends a -signed `prf` frame to the selected friend. `F5` or `/who` shows their last signed -profile. Unknown pubkeys are ignored. - -## Monero (opt-in) - -Chat does not need a wallet. Spend is opt-in at wallet create/restore. Optional -JSON-RPC to `monero-wallet-rpc` on **loopback only** (you run it, or the app -spawns it). Chain source is your choice: spawned local `monerod`, in-process -Cuprate (opt-in feature, **unvalidated on mainnet**), or a daemon address you -type. The wallet **must** use `--rpc-login`; OnionWire refuses an open RPC and -refuses URLs with no credentials. Wallet RPC is never on clearnet and never over -`.onion`. `--trusted-daemon` is never passed. - -The app-owned local daemon RPC port is **18081**. **18089** is a daemon's -*restricted*-RPC port and belongs only in examples of a *remote* address you type. - -```bash -# externally run wallet RPC (migration path) -export ONIONWIRE_WALLET_RPC=http://onionwire:secret@127.0.0.1:18083 -# or: -export ONIONWIRE_WALLET_RPC=http://127.0.0.1:18083 -export ONIONWIRE_WALLET_RPC_LOGIN=onionwire:secret -``` - -Prefer `ONIONWIRE_WALLET_NO_SPEND=1` until you actually want `/tip`. Details: -[docs/WALLET.md](docs/WALLET.md). - -| Command | Wire frame | What it does | -|---|---|---| -| `/pay [memo]` | `inv ` | Invoice to receive. Subaddress if RPC is up, else profile `xmr_addr`. | -| `/tip [memo]` | `rcp ` + `tip ` | Chain `transfer`, then signed receipt and tip. One-shot. Disabled under `ONIONWIRE_WALLET_NO_SPEND`. | - -Peer onion down → `/pay` and `/tip` fail. A queued invoice does not exist. - -`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, and -takes an optional Monero seed-offset passphrase (a second spend secret, not the -wallet-file passphrase; blank skips it, a wrong one opens a different wallet and -does not fail). -Type `SPEND` then `SEEN` on create. Each wallet gets its own file name -(`onionwire-1`, `onionwire-2`, …); the RPC must be started with `--wallet-dir`. - -`monero-wallet-rpc` keeps a wallet open only for the life of one process, so the -app opens the configured file itself after the child is up (`open_wallet`) — and -the passphrase that does it is kept, sealed in the store beside the RPC creds. -That is deliberate and it means the store passphrase is enough to spend; see -[docs/THREAT_MODEL.md](docs/THREAT_MODEL.md) and -[docs/WALLET.md](docs/WALLET.md). A wallet the app holds no passphrase for still -starts — the status reports `needs passphrase` and the app prompts for it once. - -## Backup / restore - -Losing `identity_sk` loses every friend relationship. - -- `/backup /path` — type `BACKUP`, passphrase twice. Writes `owbak1` (Argon2id + - ChaCha20-Poly1305). Onion is **not** in the file. -- `/restore /path` — type `RESTORE`, passphrase. Overwrites self keys. **Does not - rewrite the roster.** +If a peer’s onion is down, send fails. v1 has no outbox, no retry queue, no DHT, no name server. ## Wipe -- `/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**. +Composer (bottom of the roster screen): -Not a forensic erase (SSD wear-leveling). Esc cancels. +- `/wipe` — confirm by typing `WIPE`. Overwrites the message log and `VACUUM`s. Identity key and friends stay. +- `/wipe-all` — confirm by typing `WIPEALL`. Deletes the data dir. Next start is a **new person** (new identity key). Esc cancels. Nothing is wiped without confirm. ## Uninstall ```bash +# binary (whichever you used) rm -f ~/.local/bin/onionwire ~/.cargo/bin/onionwire + +# optional: destroy identity, friends, and message log +# (same as /wipe-all — you become a new person next run) rm -rf ~/.local/share/onionwire ``` @@ -416,77 +173,66 @@ If you set `ONIONWIRE_HOME`, delete that directory instead. ## Seized laptop -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. +v1 stores **plaintext** on disk: -Threat model: [docs/THREAT_MODEL.md](docs/THREAT_MODEL.md). +- message log (sqlite `messages.plaintext`) +- your identity secret key (`self.identity_sk`) +- friend public keys and current locators -## Android (SDK + APK) +Full-disk encryption plus `/wipe` / `/wipe-all` is the mitigation. There is no sqlcipher in v1. -Same repository, same protocol. An Android peer and a Linux peer that exchange -invites interoperate. - -- **SDK** — `onionwire-sdk-.aar`. UniFFI Kotlin over the same Rust crate - the TUI runs. See [crates/onionwire-sdk/README.md](crates/onionwire-sdk/README.md). -- **APK** — `onionwire--android-arm64-v8a.apk`. Kotlin + Jetpack Compose. - Build notes: [android/README.md](android/README.md). The UI is a design-token - system (one accent, 16px cards, three-tab shell: Chats / Wallet / Node & - Settings) rather than per-screen styling; see *App shell* in that README. - -The APK build is amd64-only. After the Linux `release` workflow finishes, -dispatch `android-release` with that tag so the APK/AAR attach to the same -Forgejo release. - -```bash -scripts/build-android-local.sh # -> dist/, with .sha256 -PUBLISH_TAG=v0.7.0 scripts/build-android-local.sh # + upload to that release -``` +Threat model: [`docs/THREAT_MODEL.md`](docs/THREAT_MODEL.md). ## Releases (maintainers) -Manual and batched: no merge publishes anything, and neither does a tag push. -Full procedure: [docs/RELEASING.md](docs/RELEASING.md). - -Actions → **release** → Run workflow: - -| Input | Meaning | -|---|---| -| `dry_run` | build + checksum both Linux binaries, no tag, no publish. Run this first. | -| `bump` | `patch` / `minor` / `major` off the newest `v*.*.*` tag. Default `minor`. | -| `version` | explicit `X.Y.Z` — overrides `bump`. | -| `tag` | rebuild / re-publish an existing tag. | - -Then dispatch **android-release** with `tag=` to attach the APK + AAR. +Tags trigger Forgejo Actions on the self-hosted Pi runner. The x86_64 asset has +no runner on this instance, so it is built locally and attached to the same +release. ```bash -FORGEJO_TOKEN= scripts/build-release-local.sh v0.7.0 +# 1. version in Cargo.toml must match the tag without the leading v +cargo update --offline -p onionwire # keep Cargo.lock at the new version +git commit -am "chore: release vX.Y.Z" && git push origin main + +# 2. tag and push — the release workflow builds + publishes aarch64 +git tag -a vX.Y.Z -m "OnionWire vX.Y.Z" +git push origin vX.Y.Z + +# 3. attach x86_64 from an x86_64 host (idempotent — safe to re-run) +FORGEJO_TOKEN= scripts/build-release-local.sh vX.Y.Z ``` -Do not run `cargo publish`; `publish = false`. +Workflows (Forgejo Actions, `.forgejo/workflows/` — jobs run on the `docker` +label of the Pi runner and do their Rust work in a `rust:1.91-bookworm` +sibling container): + +- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` on `main` and PRs (ignored Tor-live tests are not run). +- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — on `v*.*.*` tags: builds `aarch64-unknown-linux-gnu` natively, strips, sha256, publishes to the release. Also runnable via `workflow_dispatch` with a tag input to re-publish. + +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/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 | Symptom | What to do | |---|---| -| `GLIBC_… not found` | Build from source (Option B). | -| `sha256sum: FAILED` | Re-download binary and `.sha256`; check in the same directory. | -| Hang on `bootstrapping Arti…` | Outbound network required. Fail closed after 360s. No C-tor fallback. | -| `onionwire: unknown argument` | No subcommands. `--version` / `--help` only, then the TUI. | -| Blank / broken TUI | Real terminal emulator, not `nohup` / systemd without a TTY. | +| `GLIBC_… not found` | Binary is newer than your libc. Build from source (Option B). | +| `sha256sum: FAILED` | Re-download both the binary and `.sha256`; run the check in the same directory. | +| Hang on `bootstrapping Arti…` | Need outbound network. First consensus fetch is slow. Wait a couple of minutes; if it never publishes, it fails closed — no C-tor fallback. | +| `onionwire: unknown argument` | No subcommands. Flags are `--version` / `--help` only, then the TUI. | +| Blank / broken TUI | Run in a real terminal emulator, not `nohup` / systemd without a TTY. | | Two chats, same laptop | Separate `ONIONWIRE_HOME` per process. | -| Friend cannot find you after F4 | Expected if they were offline. They F3-paste the new invite. | -| Wallet error says “open F7” | `F7` is the node & wallet setup screen: set the RPC endpoint there, or set `ONIONWIRE_WALLET_RPC`. | +| Friend cannot find you after F4 | Expected if they were offline. They must F3-paste the new QR. Same `k` updates the row. | ## Not in v1 -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). +Prosody, XMPP, s2s, MAM, carbons, outbox, multi-device, DHT / name server, sqlcipher. ## License diff --git a/android/CUPRATE_DAEMON.md b/android/CUPRATE_DAEMON.md deleted file mode 100644 index 18b3fcd..0000000 --- a/android/CUPRATE_DAEMON.md +++ /dev/null @@ -1,259 +0,0 @@ -# The in-process chain daemon (`cuprate-daemon`) in the APK - -The wallet's third chain source — Cuprate's chain daemon running **inside the -OnionWire process** — is compiled into the Android build. This document is the -provenance record for that: how the feature is enabled, why the link line looks -the way it does, what CI checks, and what has *not* been proven. - -Companion reading: [docs/WALLET.md](../docs/WALLET.md) ("The in-process chain -daemon") for what the daemon is, [docs/cuprate-android-spike.md](../docs/cuprate-android-spike.md) -for the cross-compile spike this plumbing comes from, -[MONERO_BINARIES.md](MONERO_BINARIES.md) for the `monero-wallet-rpc` executable -(still a child process — Cuprate has no wallet layer), and -[README.md](README.md#wallet-child-and-chain-sources-as-android-sees-them) for -how the Android wallet screen drives it. - -## What changed in the build - -`android/sdk/build.gradle.kts`: - -| | | -|---|---| -| Feature | `--features cuprate-daemon` on the **Android** build only | -| Where | `cargoBuildAndroid` (the `cargo ndk` cross-compile) | -| Not where | `cargoHostLib` / `uniffiBindgen` stay feature-free | - -The host cdylib exists only so `uniffi-bindgen --library` can dlopen it. Building -the Cuprate graph there would add ~152 crates and a C++ RandomX build to every -build for a library that never runs the daemon, and the UniFFI surface does not -fork on a cargo feature (`ChainChoice.InProcessCuprate` is present either way, and -`WalletChildStatus` carries the same fields) — so the generated Kotlin bindings are -the same bytes. - -`cargoBuildAndroid` prints the feature it is building with, so the CI log carries -the request rather than only the task name: - -``` -cargo ndk build for arm64-v8a features=cuprate-daemon api=26 ndk=28.2.13676358 -``` - -There is no `-P` knob that turns the feature off. A build that silently dropped -it would ship an APK whose on-device node can only fail; `android-ci.yml` greps -the artifact (below) so that is not only a log line. - -## The link line - -RandomX is C++ and its aarch64 JIT calls `__clear_cache`, and `randomx-rs`'s build -script emits `rustc-link-lib=static=stdc++` against the NDK's *stub* -`libstdc++.a`. Without libc++ and the compiler-rt builtins the link fails on -`__cxa_allocate_exception` / `std::runtime_error` / `typeinfo` / `__clear_cache`. -`cargo ndk --link-builtins` covers the builtins but not libc++, and -`-static-libstdc++` is ignored by NDK clang, so the full set is spelled out: - -``` --L$NDK/toolchains/llvm/prebuilt//sysroot/usr/lib/ --L$NDK/toolchains/llvm/prebuilt//lib/clang//lib/linux --lclang_rt.builtins--android --lc++_static --lc++abi --Wl,--exclude-libs,libc++_static.a --Wl,--exclude-libs,libc++abi.a -``` - -Five more things the build has to get right, each of which fails as something -else: - -1. **`ANDROID_NDK` must be exported**, not only `ANDROID_NDK_HOME` / `NDK_HOME`. - `cmake-rs` (RandomX's C++ half) aborts with *"Android: Neither the NDK or a - standalone toolchain was found"*, and `randomx-rs`'s build script then panics - inside `cmake`. The task exports all three. -2. **The linker is the NDK clang driver, named explicitly.** The dev machines' - `~/.cargo/config.toml` pins `[target.aarch64-linux-android] linker` to the - **API 21** wrapper, and API 21 fails this link (`pthread_atfork` is API 23+). - `cargo-ndk`'s own linker wrapper is bypassed so the `-Wl,…` args reach clang as - link args. -3. **The flags are `CARGO_TARGET__RUSTFLAGS`, not `RUSTFLAGS`.** A global - rustflags would also apply to build scripts and proc macros, which are - **host**-targeted, where `-lc++_static` breaks the link. Setting the - per-target variable also *replaces* the `target..rustflags` in - `~/.cargo/config.toml`, so the sysroot `-L` it carried is repeated in the list. -4. **The build image needs `cmake`.** RandomX is built by `randomx-rs`'s build - script through `cmake-rs`, and both Android workflows' `debian:bookworm` - containers install their own package list. Without `cmake` the build gets - ~11 minutes in, compiles 400-odd crates, and then dies with a `randomx-rs` - build-script panic — *failed to execute command: No such file or directory … - is `cmake` not installed?* — surfacing as Gradle's "cargo finished with - non-zero exit value 101", which reads like a Rust error and is not one. - `android-ci.yml` and `android-release.yml` both install it. -5. **The Rust toolchain must be >= 1.93.** `tapes`, a Cuprate dependency this - repo cannot patch, calls `VecDeque::pop_front_if`, which is stable only from - 1.93. On 1.91 a job compiles ~400 crates and then dies with - `error[E0658]: use of unstable library feature 'vec_deque_pop_if'`. - `ci.yml`, `release.yml`, `android-ci.yml` and `android-release.yml` all pin - 1.98 (the stable release this graph is built and tested with), and - `Cargo.toml` `rust-version` is `"1.98"` for the same reason: `cuprate-daemon` - is a default feature, so the default build is the floor. - -`:sdk:preBuild` also runs `verifyDynamicLibc`: `libonionwire_sdk.so` must have -`libc.so` in `DT_NEEDED`. Linking the NDK's static `libc.a` instead null-derefs -inside `dlopen` on the first SDK call. - -## What ends up in the APK - -``` -lib/arm64-v8a/libandroidx.graphics.path.so -lib/arm64-v8a/libjnidispatch.so -lib/arm64-v8a/libmonerowalletrpc.so -lib/arm64-v8a/libonionwire_sdk.so -lib/arm64-v8a/librandomx_rs-.so <- new, see below -``` - -`librandomx_rs-.so` is new and is **not a load-time dependency** of the SDK: -`readelf -d libonionwire_sdk.so` lists `liblog.so` and nothing else, and the -RandomX code is statically inside the SDK's own `.so` (its symbols and strings are -there). `cargo-ndk` copies every cdylib the target directory produced into -`jniLibs`, and `randomx-rs` also builds one. It is left in place rather than -filtered out: it is 1,122,296 bytes uncompressed / 387,996 deflated (sizes from -the feature-on CI run in the table below), and dropping it would be a packaging -rule that silently breaks the day something *does* link it. - -## The CI gate - -`.forgejo/workflows/android-ci.yml` extracts `lib//libonionwire_sdk.so` from -the built APK and greps it for `target_max_memory` — a rodata literal from -`src/cuprate.rs`'s config TOML, compiled only under -`#[cfg(feature = "cuprate-daemon")]`. The job **fails** if it is absent. - -The negative control is v0.7.0's shipped APK: its `libonionwire_sdk.so` contains -**zero** occurrences of that string (and of `randomx` / `cuprated`), so a match -means the daemon is in the artifact, not merely requested. The build log line -above is the other half of the proof — request and artifact, separately checkable. - -## What the wallet screen does with it - -`ui/WalletScreen.kt` grew a third chain source beside the daemon field and -**Receive-only** (`ui/WalletChildStatusText.kt` holds the pure model): - -* Selecting **On-device node (Cuprate)** stores `ChainChoice.InProcessCuprate` with - an **empty** `monerod_datadir`, which the SDK resolves to - `$ONIONWIRE_HOME/chain/{testnet,mainnet-pruned,mainnet-full}` from the stored - `mainnet` / `prune` flags — Kotlin never invents an absolute path. -* `monero-wallet-rpc` is still required and still a subprocess: Start is gated on - the bundled binary exactly as before, and an in-process node does not bundle - `arti`, so a `.onion` daemon is still refused. Wallet RPC is loopback only. - Chain traffic stays off until the user opted into a wallet and chose a source. -* The status line renders the core's words verbatim and grows a `node ` - segment from `WalletChildStatus.node_state` for this source only. An unrecognised - word is never rendered as ready. -* **The daemon's sync height is on the line.** `WalletChildStatus.height` / - `target_height` (Rust `u64` → UniFFI/Kotlin `ULong`) carry the blocks the chain - daemon had at the last probe — read from the wallet RPC, or, when that RPC is - refused (the 111 case) and the source is local/in-process, from the daemon over - loopback. The status line appends ` · sync h/t` after the source (and after the - `node` segment) whenever either is non-zero: `0/0` means the last probe failed - or the daemon is not up, so it is *unknown*, not `0%` — there is no percent, no - progress bar and no ETA anywhere in the UI, and a zero target still prints as - `/0` when height is non-zero. This is the **daemon's** chain height, not the - wallet's scan height. The same string is what the status row's screen-reader - `contentDescription` carries (`walletChildStatusDescription`), so the spoken row - is never shorter than the visible one. Cross-compiled and unit-tested on the - JVM; still not device-proven. -* **What writes that snapshot on Android.** The wallet screen's loop - (`WireViewModel.openWalletChild` → `walletChildRefreshLoop`) does one cached - `Wire.walletStatus()` paint, then every 2 s a live - `Wire.walletChildRefresh()` (`Wire::wallet_child_refresh`). The live call is - what makes height/target move between ticks; it never spawns. See - [README.md](README.md#what-the-apk-refresh-loop-actually-calls). -* **Storage honesty.** The card shows the free space on the filesystem the fjall - store grows into (`StatFs` on the app's data dir) and refuses Start below a - floor, or when that filesystem cannot be read at all. The floor is a *floor*, - not a sync estimate, and the doc comment says why: nothing in this stack - exposes one — `WalletChildStatus` has no size field, and Cuprate's restricted RPC - reports a hardcoded 5 GiB `database_size` placeholder. Floors in - `ui/WalletChildStatusText.kt`: 3 GiB testnet, 64 GiB mainnet-pruned, 280 GiB - mainnet-full. -* **Pre-production warning**, above the Start button, in a sentence: - `CUPRATE_PREPRODUCTION_WARNING` — quoted user book, testnet-only / mainnet - unvalidated, and Cuprate issue #278, assertable in `WalletChildStatusTextTest`. - Opt-in, never a default. - -## What it costs in CI - -The Android job runs on the `docker-amd64` runner (it is **not** the Raspberry Pi -runner) with `CARGO_BUILD_JOBS=1` and a warm named volume at `/cargo-target`, so -the numbers below are one runner and one volume: `main` with the feature off, and -the feature on. There are two feature-on regimes, and the second is the one a PR -author feels — the first build after the feature lands compiles the whole cuprated -graph, every later build is incremental against the same volume. - -These figures are the **recorded** costs from the runs that landed the feature -(not re-measured on `fa0e4b2`): - -| | feature off — `main` 773dacb, run 402 | feature on — PR #113 head 3860c3d (merged as 8626da2), run 412 | -|---|---|---| -| Gradle | `BUILD SUCCESSFUL in 6m 10s` | `BUILD SUCCESSFUL in 7m 14s` | -| job | 8m 21s | 11m 12s | -| build step | 484 s | 653 s | -| `/cargo-target` | 3.1 G before the build | 5.6 G after (2.7 G of it `aarch64-linux-android/release`) | -| `libonionwire_sdk.so` in the APK | 33,533,264 B | 55,438,112 B | -| `librandomx_rs-.so` | absent | 1,122,296 B | -| APK | 28,038,401 B | 34,445,514 B | -| AAR | 10,377,416 B | 15,728,039 B | - -The **first** feature-on build is the expensive one: run 406, against a volume that -did not yet hold the cuprated graph, took `BUILD SUCCESSFUL in 44m 7s` and a -47m 44s job — the ~152-crate graph plus the C++ RandomX cross-build, with a single -cargo job on the runner. After that it settles to roughly **+2 minutes over the -feature-off build** (7m 14s vs 6m 10s), because only this repo's own crates -recompile. - -`android-ci.yml`'s job `timeout-minutes` is **120**; `android-release.yml`'s -Android job is **90**. Even the 44-minute first build fits both with room to -spare, and the volume grew to 5.6 G on a runner filesystem with 37 G free (the -`df -h` in the run log). The feature is **not** gated on a build variant, a label -or a manual dispatch — the release path builds exactly what CI verifies. - -`android-ci.yml` prints `du -sh /cargo-target`, the length/method/deflated size of -every native lib, and both artifact digests, and the workflow echoes -`build_wall_clock_seconds`: the next person changing this graph reads the cost and -the artifact's identity out of the run log rather than re-deriving either. - -## What has not been proven - -The daemon was **not executed on a device or an emulator**. There is no -`arm64-v8a` AVD on the build host (the same gap [MONERO_BINARIES.md](MONERO_BINARIES.md) -records), and no aarch64 Android sysroot to run it under `qemu-user`. What is -proven: it cross-compiles and links against the NDK's C++ runtime, the feature is -in the shipped `.so`, the artifact packages, and the Kotlin that drives it -compiles and passes its unit tests. What is not: - -* that `cuprated` starts, opens its fjall store and answers on loopback under - Android's runtime; -* **mainnet remains unvalidated.** Cuprate itself is pre-production and its own - user book says not to use `cuprated` for serious purposes. The Android screen - can store a mainnet-pruned or mainnet-full mode; that is not a claim this build - has run either. Core still surfaces `testnet only — mainnet is unvalidated` - (`cuprate::TESTNET_ONLY`); -* **a daemon that dies after the wallet child came up cannot be reported - `exited`.** The in-process node is a value this app owns, not a process with a - pid. The SDK derives `node_state` from the wallet-child state - (`crates/onionwire-sdk/src/lib.rs`, `node_state`). If the daemon dies after its - wallet child is up, the chain probe fails and the state stays `syncing`. It is - never reported `ready` from that failure. `exited` still means what it says: - the `monero-wallet-rpc` child is gone. - -To close the device gap, on an arm64 device or a software-emulated arm64 AVD: - -```bash -sdkmanager "system-images;android-35;google_apis;arm64-v8a" -avdmanager create avd -n ow-arm64 -k "system-images;android-35;google_apis;arm64-v8a" -emulator -avd ow-arm64 # software-emulated on an x86_64 host: slow -adb install -r dist/onionwire--android-arm64-v8a.apk -``` - -then unlock the node, open Wallet, tap **On-device node (Cuprate)**, read the -warning, press **Start wallet**, and watch the status line for -`connecting → syncing · in-process node · node starting → node syncing`. A wallet -balance needs the chain synced, which on a phone is a long wait — the status line -is the thing to watch, not the balance. After the first cached paint, the APK -loop probes live every 2 s, so `sync h/t` should move once the daemon answers. diff --git a/android/MONERO_BINARIES.md b/android/MONERO_BINARIES.md deleted file mode 100644 index 4409049..0000000 --- a/android/MONERO_BINARIES.md +++ /dev/null @@ -1,191 +0,0 @@ -# Bundled native executables (`jniLibs`) - -The wallet screen starts an **app-owned `monero-wallet-rpc` child** (issue #107, -[`src/wallet_child.rs`](../src/wallet_child.rs)). Monero ships no Android -binaries, so this repository carries one, built here. - -| | | -|---|---| -| File in the tree | `android/app/src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so` | -| Bytes | 19 954 224 (stripped) | -| sha256 | `d9126788030ecd1ccdb40c7764e66e9a14d158a147ad335b256f0577681b5ad4` | -| Format | `ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, for Android 21, built by NDK r17b (4828580), stripped` | -| Needed libs | `libc.so`, `libm.so`, `libdl.so` — everything else is static | -| Source | `https://github.com/monero-project/monero` | -| Tag | `v0.18.4.4` | -| Commit | `516e5355a103a2bf0b7e10328ebcaa2945019445` (peeled annotated tag) | -| Reproduce with | `scripts/build-monero-wallet-rpc-android.sh` | -| Verified by | `android/monero-binaries.sha256`, checked by `scripts/build-android-local.sh` on every build (local and CI) | - -Re-checked on this tree (`fa0e4b2`): `stat -c %s` is 19954224; `sha256sum` of the -blob equals the hash above and equals the line in `android/monero-binaries.sha256` -(that file's path is relative to `android/`: -`app/src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so`). `readelf -d` NEEDED is -`libdl.so`, `libm.so`, `libc.so`. - -Only `arm64-v8a` is built. `-Ponionwire.abis=x86_64` produces an APK with no -wallet binary in it — the screen says so (`NO_WALLET_RPC_MESSAGE`) instead of -offering a Start that cannot work. - -## How it is built - -`scripts/build-monero-wallet-rpc-android.sh` runs upstream's own Android -cross-compile path — `contrib/depends` (boost, openssl, libunbound, libzmq, -libsodium, ncurses, readline, libiconv, expat for `aarch64-linux-android`) plus -the `toolchain.cmake` it emits — and then builds the single CMake target -`wallet_rpc_server`. It takes ~40 min on 12 cores and needs ~15 GB of scratch -space. It is **not** part of the CI path: the Android Gradle jobs already run -on `docker-amd64` for ~9 minutes with warm volumes, and rebuilding Monero's C++ -tree is a separate 30–45 min host job. CI verifies the committed bytes instead -(`sha256sum -c` plus the APK-entry check in `scripts/build-android-local.sh`). - -Four things about the build are worth writing down, because each one is a -failure that looks like something else: - -1. **CMake must be 3.x.** `contrib/depends` emits a *standalone-NDK-toolchain* - `toolchain.cmake` (`CMAKE_ANDROID_STANDALONE_TOOLCHAIN`). CMake 4.x no longer - honours that, silently falls back to the host `clang`, and the configure step - dies with `ld.lld: cannot open /usr/lib/clang/.../libclang_rt.builtins.a`. - The script installs 3.22.6 into a venv when the host CMake is 4.x. - -2. **The NDK r17b prebuilt `clang60` needs `libtinfo.so.5`.** `android_ndk.mk` - pins NDK r17b and drives the long-removed `make_standalone_toolchain.py` - (r17b still has it). Its `clang60` binary is linked against ncurses 5; - current distros ship ncurses 6 only, so every compile fails with - `error while loading shared libraries: libtinfo.so.5`. A shim directory with - `libtinfo.so.5 -> libtinfo.so.6` on `LD_LIBRARY_PATH` fixes it. The script - creates it. - -3. **`/usr` is in `CMAKE_FIND_ROOT_PATH`, and `/usr` is the host.** This is the - one that costs the most time. `CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY` does - not help: `/usr` is listed as a root, so `find_library()` returns host - libraries. Two consequences in this tree: - * `find_package(HIDAPI)` finds the **host** hidapi, defines `HAVE_HIDAPI`, - and `src/device` then fails to compile `hidapi/hidapi.h` — the include dir - it found is `/usr/include/hidapi`, so `` resolves to - `/usr/include/hidapi/hidapi/hidapi.h`. - * Monero's optional zmq extras (`pgm`, `norm`, `gssapi_krb5`, `protolib`, - `bsd`, `md`, `protokit`) are probed with `find_library` and appended to - `ZMQ_LIB`, so the final link gets `/usr/lib/libpgm.so` — an x86-64 shared - object in an aarch64 link line: `error adding symbols: File in wrong - format`. `libzmq.a` does not actually reference openpgm. - - The script rewrites the generated `toolchain.cmake` to - `SET(CMAKE_FIND_ROOT_PATH )`. This is also why upstream's - `make depends target=aarch64-linux-android` is not reproducible: it happens - to work only on a build host with none of those libraries installed. - - A stale `CMakeCache.txt` keeps the host paths after the toolchain is fixed, - and nothing complains until the link, so the script also passes - `-U PGM_LIBRARY -U GSSAPI_LIBRARY …` and configures in a fresh build dir. - -4. **The CMake target is `wallet_rpc_server`, not `monero-wallet-rpc`.** The - latter is the *output* name. `make monero-wallet-rpc` fails with - `No rule to make target`. - -### Not bit-reproducible - -Build paths and timestamps land in the binary, so a fresh run of the script -will not reproduce the sha256 above. That hash is a **provenance record of the -shipped blob** and the thing CI re-verifies — not a reproducible-build -assertion. If you rebuild, update both `android/monero-binaries.sha256` and this -table in the same commit, and say what changed in the tag or the toolchain. - -The reproduce script pins **the tag** (`MONERO_TAG=v0.18.4.4`, shallow clone). -The commit in the table is the peeled object of that annotated tag on GitHub, -recorded here so a rebuild can be compared; it is not a second pin in the -script. - -## Why it is a `jniLibs` `.so` and not an asset - -Since Android 10 (API 29) an app may not `exec()` a file in its own data -directory: the SELinux policy carries no `execute` on `app_data_file`, so the -familiar "ship it in `assets/`, copy it to `filesDir`, `chmod 700`" recipe is -refused by the kernel regardless of the mode bits. The one directory Android -hands out executable is `ApplicationInfo.nativeLibraryDir`, which the package -manager populates from the APK's `lib//` entries at install time. - -So the executable is named `libmonerowalletrpc.so` and shipped through -`jniLibs`, and the path the core is handed is - -``` -/libmonerowalletrpc.so -``` - -resolved at runtime by `wallet/WalletChildBinaries.kt`. This only works with -`android:extractNativeLibs="true"`; with the AGP 8 default -(`extractNativeLibs="false"`) the file stays inside the APK and there is nothing -on disk to run. `app/build.gradle.kts` sets `packaging.jniLibs.useLegacyPackaging -= true` for exactly that reason, and `keepDebugSymbols` for this one entry so -AGP's strip pass cannot rewrite the bytes that CI verifies. - -Cost: the release APK grows from ~9 MB to ~28 MB (the binary is deflate-stored -at 6.9 MB) and installs ~20 MB into the app's native library directory. -(Those packaging sizes are the original measurement when the blob landed; the -committed blob's **uncompressed** size is the 19 954 224 bytes above.) - -## `arti` is NOT bundled - -`WalletChild` runs `arti proxy -p ` as the SOCKS child for a **`.onion`** -daemon, and `ChildConfig::validate` requires a non-empty `arti_bin` for any -chain source that is not receive-only. There is no `arti` executable in this -build, and producing one (a standalone `arti` binary for -`aarch64-linux-android`, from a crate the Rust side does not currently build as -a bin) is a follow-up, not something this document can invent. - -What the app does about it, honestly: - -* `arti_bin` is set to `/libarti.so` — the path the binary - *would* occupy. For a loopback or clearnet daemon the core never spawns it, so - the value is inert. It is deliberately **not** set to a real binary: - `monero-wallet-rpc` named as the SOCKS child would be spawned as the proxy the - moment the user typed an `.onion` host. -* The wallet screen refuses an `.onion` daemon while `libarti.so` is absent, and - says why (`ONION_NEEDS_ARTI_NOTICE`) instead of letting the spawn fail. - -So today: **loopback and clearnet daemons work; `.onion` daemons do not.** - -## Verification in CI - -`.forgejo/workflows/android-ci.yml` (and `android-release.yml`) build the APK on -`docker-amd64` and `scripts/build-android-local.sh` does the checking, so both -CI jobs and local builds get it: - -1. before Gradle, `sha256sum -c android/monero-binaries.sha256` against the - committed blob; -2. after packaging, `unzip -p` the `lib//libmonerowalletrpc.so` entry out - of the produced APK and compare its sha256 with the committed file. A - mismatch fails the build — the bytes that ship are the bytes that were - verified, not the bytes that were hoped for. - -## Not verified - -The binary was **not executed on a device or emulator**. There is no -`arm64-v8a` AVD on the build host (all three existing AVDs are `x86_64`), and no -aarch64 sysroot to run it under `qemu-user`. What is proven: it cross-compiles, -it is a valid `aarch64` Android PIE executable, it packages into the APK with -the expected bytes, and the Kotlin that drives it compiles. What is not: -that `monero-wallet-rpc` starts, opens its wallet file and answers JSON-RPC -under Android's runtime. - -To close that gap: - -```bash -sdkmanager "system-images;android-35;google_apis;arm64-v8a" -avdmanager create avd -n ow-arm64 -k "system-images;android-35;google_apis;arm64-v8a" -emulator -avd ow-arm64 # software-emulated on an x86_64 host: slow -adb install -r dist/onionwire--android-arm64-v8a.apk -``` - -then unlock the node, open Wallet, type a daemon as `host:port`, Save, and watch -the status line for `connecting → syncing → ready`. A `.onion` daemon will stop -at the arti notice above. - -## The other chain source: an in-process daemon, not a binary - -The third chain source — Cuprate's chain daemon running inside the OnionWire -process — is a **linked feature of the SDK's `.so`**, not a `jniLibs` executable, -so it has its own record: [CUPRATE_DAEMON.md](CUPRATE_DAEMON.md) (feature wiring, -the NDK C++ / compiler-rt link line, the CI check that greps the shipped `.so` -for a cuprated-only string, and what has not been verified). `monero-wallet-rpc` -above stays a child process for it — Cuprate has no wallet layer. diff --git a/android/README.md b/android/README.md deleted file mode 100644 index c3005e6..0000000 --- a/android/README.md +++ /dev/null @@ -1,410 +0,0 @@ -# OnionWire for Android - -Two artifacts out of one Gradle build: - -| Module | Output | What it is | -|---|---|---| -| `:sdk` | `sdk-release.aar` | The reusable library. UniFFI Kotlin bindings + `libonionwire_sdk.so`. Any Android app can depend on this. | -| `:app` | `app-release.apk` / `app-debug.apk` | A Jetpack Compose + Material 3 messenger that depends on `:sdk` and nothing else. | - -The Linux TUI in the repository root is a **separate product** with a separate -Cargo workspace. Nothing here turns it into a WebView, and nothing here imports -its TUI code. Same wire protocol: [docs/PROTOCOL.md](../docs/PROTOCOL.md). - -Companion records (not duplicated here): - -* in-process chain daemon in the APK — [CUPRATE_DAEMON.md](CUPRATE_DAEMON.md) -* bundled `monero-wallet-rpc` blob — [MONERO_BINARIES.md](MONERO_BINARIES.md) -* wallet / chain-source behaviour (core + SDK) — [docs/WALLET.md](../docs/WALLET.md) -* consuming the AAR — [crates/onionwire-sdk/README.md](../crates/onionwire-sdk/README.md) -* how a maintainer actually cuts a release — [docs/RELEASING.md](../docs/RELEASING.md) - -## Requirements - -* JDK 17+ (built and tested on JDK 21) -* Android SDK with **platform 36** and **build-tools 36.0.0** -* NDK **28.2.13676358** (NDK r28c) — also what Rust's Android link step uses -* Rust with the `aarch64-linux-android` target and `cargo-ndk` -* `ANDROID_HOME` set, or `sdk.dir` in `android/local.properties` (gitignored) - -One-time setup: - -```bash -sdkmanager --install "platform-tools" "platforms;android-36" \ - "build-tools;36.0.0" "ndk;28.2.13676358" -rustup target add aarch64-linux-android x86_64-linux-android -cargo install cargo-ndk -``` - -## Build - -```bash -cd android -./gradlew :sdk:assembleRelease :app:assembleDebug # or :app:assembleRelease -``` - -The Rust cross-compile and the UniFFI Kotlin bindings are wired into the Gradle -tasks — there is no manual codegen step. `:sdk:preBuild` depends on -`cargoBuildAndroid`, `uniffiBindgen`, and `verifyDynamicLibc`. - -Emulator / x86_64 slice: - -```bash -./gradlew :app:assembleDebug -Ponionwire.abis=arm64-v8a,x86_64 -``` - -That extra ABI does **not** ship `libmonerowalletrpc.so` for x86_64. The wallet -screen says so (`NO_WALLET_RPC_MESSAGE`) instead of offering a Start that cannot -work. See [MONERO_BINARIES.md](MONERO_BINARIES.md). - -Or from the repo root, with checksums and an optional publish step: - -```bash -scripts/build-android-local.sh # -> dist/onionwire--android-arm64-v8a.apk -PUBLISH_TAG=v0.5.0 scripts/build-android-local.sh -``` - -The script re-verifies `android/monero-binaries.sha256` before Gradle, then -again against the bytes inside the APK. It does not create tags. - -## Decisions you should know about - -### `minSdk = 26` (Android 8.0) - -The floor is not NDK-imposed — Rust's `aarch64-linux-android` std and NDK 28 -both happily target API 21. We take 26 deliberately: - -* it is the first API level where adaptive icons and notification channels are - unconditional, so there is one icon path instead of two; -* it keeps a single `arm64-v8a` APK inside Play's currently-supported range - without carrying legacy ART/JIT workarounds for pre-O devices; -* the crypto stack (`ring`, `rustls`, `argon2`, `chacha20poly1305`) is - exercised on 4.4+ kernels here, which is what we actually test. - -**Devices cut:** Android 7.1 and older. If you need those, the change is -`-Ponionwire.api=24` **and** a real device test — do not bump it silently. - -### 16 KB page size - -The NDK r28 link step emits `max-page-size=16384` for 64-bit Android, which is -what Play requires for new apps. Verify with: - -```bash -readelf -l android/sdk/build/rustJniLibs/arm64-v8a/libonionwire_sdk.so | grep LOAD -``` - -### Permissions - -`INTERNET` is the only permission requested at first launch. No camera (invites -are pasted, not scanned), no contacts, no storage permission — the data -directory is `context.filesDir`, which is already app-private. - -The node is **not** process-lifetime-only. After unlock, `KeepAliveService` is -a foreground service (`specialUse`, not `dataSync`) with an ongoing -notification so the onion stays published across Doze and backgrounding. The -manifest therefore also declares: - -* `FOREGROUND_SERVICE` -* `FOREGROUND_SERVICE_SPECIAL_USE` -* `POST_NOTIFICATIONS` (API 33+; denial hides the drawer notification, it does - not stop the service) - -`NodeHost` owns the single `Wire` handle. The service never does. Lock, or the -notification's Stop action, drops the keep-alive anchor; the node stays up -only while another owner (the UI) still holds it. `START_NOT_STICKY`: a -restarted empty service would show "reachable" over a dead onion. - -### Data at rest - -`context.filesDir/onionwire/` (mode 0700), holding `onionwire.db` and the Arti -state dir. `android:allowBackup="false"` plus explicit `data_extraction_rules` -exclusions, because an auto-backup of `onionwire.db` would hand the wrapped -message key *and* the plaintext identity keys to Google Drive. Chat bodies are -encrypted at rest; identity keys are not — that is the locked v1 posture. - -### The store passphrase at rest - -Typing the passphrase on every launch is no longer required. On first unlock -the passphrase can be remembered (checkbox, on by default), and it is then -stored as an AES-256-GCM blob: - -* the wrapping key is generated inside the **Android Keystore** under alias - `onionwire.store`, AES-256-GCM, `setUserAuthenticationRequired(false)` — - deliberately **not** biometric-gated, because a fingerprint prompt would turn - "the node opens or tells you why it did not" into "the node is unusable"; -* **StrongBox is requested first** (`setIsStrongBoxBacked(true)`, guarded by - `FEATURE_STRONGBOX_KEYSTORE` on API 28+) and falls back to an ordinary - TEE-backed or software Keystore key when the chip refuses AES-256 - (`StrongBoxUnavailableException is a ProviderException`). The fallback is - reported, not hidden: the lock screen prints what `KeyInfo` actually said, - and a software key is labelled **NOT hardware-backed**; -* only ciphertext + IV reach disk, at - `filesDir/secrets/store-passphrase.bin` — an `OWSEAL1` envelope of - magic + IV + ciphertext + GCM tag. No second copy, no `SharedPreferences`, - no plaintext in logs, and the typed `CharArray` is zeroed as soon as the - unlock call returns. The text field is a plain `remember`, so the typed - passphrase is never written into saved instance state; -* **Keystore invalidation is a supported path, not a crash.** A factory reset, - an app-data wipe, or a key the platform invalidates leaves a blob that cannot - authenticate: `StoredPassphraseStore.load()` returns `Unavailable`, the lock - screen explains it, and the user types the passphrase again. A failed read - does **not** delete the blob — a transient Keystore failure must not destroy - the only copy; -* `forget` deletes the blob **and** the Keystore key. - -The one plaintext copy this cannot erase is the immutable `String` the UniFFI -binding takes (`openWire(home, passphrase: String)`). A follow-up SDK change -should accept the key (or a `ByteArray`) so the passphrase never becomes a -`String` at all. - -`app/src/test/.../crypto/` covers the envelope and the file handling on the JVM -(the real `StoreSecret` code, with a JVM AES key standing in). The Keystore -provider only exists on a device: - -```bash -./gradlew :app:connectedDebugAndroidTest # prints the KeyInfo/hardware report -``` - -### Signing - -Release APKs are signed with a **repo-owned keystore**, not the debug key. - -* CI reads `ANDROID_KEYSTORE_BASE64`, `ANDROID_KEYSTORE_PASSWORD`, - `ANDROID_KEY_ALIAS`, and `ANDROID_KEY_PASSWORD` from Forgejo repo secrets - and writes them to `~/.android/onionwire-release.env` for the build. -* Locally, `scripts/build-android-local.sh` sources that same env file if - present (`~/.android/onionwire-release.jks` + `.env`, mode 600). Local and - CI APKs then verify as the same cert and can upgrade in place. -* If the env file is missing, Gradle **warns** and signs with the debug - keystore so a laptop build still installs. CI's `android-release.yml` sets - `ONIONWIRE_REQUIRE_RELEASE_KEY=true` and **fails closed** instead — a - per-machine debug key would make every CI APK uninstallable over the last. - `android-ci.yml` deliberately does **not** set that: it is a verification - build and `apksigner` reporting the debug cert there is expected. -* Never commit a keystore, password, or `android/local.properties`. This is - not a Play upload key; nothing here should be uploaded to Play. - -### Release builds are not minified - -`isMinifyEnabled = false` for release. Keeps for the UniFFI/JNI surface already -exist in `sdk/consumer-rules.pro`, but enabling R8 without a mapping-file upload -path and an on-device test of the JNI surface is how you ship an -`UnsatisfiedLinkError` nobody can read. Turn it on together with crash -deobfuscation, not before. - -## Wallet child and chain sources (as Android sees them) - -Chain traffic is **off** until the user opens Wallet, picks a source, and -presses Start. Receive-only is the default: no `monero-wallet-rpc` child, no -daemon, no P2P. - -The app owns `monero-wallet-rpc` (issue #107). It is still a **child process**, -exec'd from `applicationInfo.nativeLibraryDir/libmonerowalletrpc.so`. Cuprate -has no wallet layer — an in-process node does not replace that binary. - -Sources the screen offers: - -1. **Receive-only** — no child, no chain. -2. **A daemon address you type** — loopback or clearnet. Wallet RPC itself is - loopback only. A `.onion` host is refused while `libarti.so` is absent - (`ONION_NEEDS_ARTI_NOTICE`); this APK does not bundle `arti`. -3. **On-device node (Cuprate)** — opt-in. Selecting it stores - `ChainChoice.InProcessCuprate` with an empty `monerod_datadir`, which the - SDK resolves to `$ONIONWIRE_HOME/chain`. Kotlin never invents an absolute - path. The pre-production warning (`CUPRATE_PREPRODUCTION_WARNING`) sits - **above Start**, not after. The screen can store testnet, mainnet-pruned, or - mainnet-full (and applies the matching storage floor); **mainnet remains - unvalidated** and the warning says so. Cross-compiled is not device-proven. - See [CUPRATE_DAEMON.md](CUPRATE_DAEMON.md). - -Start is gated on the bundled wallet-rpc binary, on the storage floor for the -chosen Cuprate mode, and on the `.onion`/arti check. The floors are floors, not -sync estimates — nothing in this stack exposes a chain size: - -| Mode | Floor | -|---|---| -| testnet | 3 GiB | -| mainnet pruned | 64 GiB | -| mainnet full | 280 GiB | - -Unreadable free space (`StatFs` failed) is fail-closed: Start stays blocked. - -### Status line - -`ui/WalletChildStatusText.kt` is the pure model. The line renders the core's -words verbatim (`off` / `connecting` / `syncing` / `ready` / `exited`), then -the chain-source label, then — for the in-process source only — `node ` -from `WalletChildStatus.node_state`. An unrecognised word is never rendered as -ready. - -When the last probe reported a non-zero height or target, the line grows -` · sync h/t`. That is the **daemon's** chain height, not the wallet's scan -height. `0/0` is omitted (unknown), not printed as 0%. There is **no -percentage, no progress bar, and no ETA** anywhere in the UI. The same string -is the row's screen-reader `contentDescription`. - -Honest limit of the in-process node word: a daemon that dies *after* the wallet -child came up cannot be reported `exited` — there is no separate pid for the -in-process daemon, the chain probe fails, and the state stays `syncing`. -`exited` still means the `monero-wallet-rpc` child is gone. Details: -[CUPRATE_DAEMON.md](CUPRATE_DAEMON.md#what-has-not-been-proven). - -### What the APK refresh loop actually calls - -`WireViewModel.openWalletChild()` runs `walletChildRefreshLoop` with a 2 s -tick (`WALLET_CHILD_TICK_MS = 2_000`): - -1. **First paint** — `paintWalletChildCached()` → `Wire.walletStatus()` - (`Wire::wallet_status`). Cached, no dial, so the screen has a record - while the first probe is still in flight. -2. **Every tick after that** — `refreshWalletChild()` → - `Wire.walletChildRefresh()` (`Wire::wallet_child_refresh`). That dials - the child's loopback wallet RPC, and the configured local daemon's - `get_info` when the wallet RPC does not answer, which is what makes - `sync h/t` move without another Start. It never spawns a child. With no - live child the core short-circuits to the cached `off` / `exited` - snapshot, so this cannot invent `ready`. - -The loop suspends on each read before it sleeps: a probe slower than 2 s -delays the next tick instead of overlapping it. Do not run two concurrent -`wallet_child_refresh` calls against one child. - -See [docs/WALLET.md](../docs/WALLET.md) (Android / SDK) for the same two -methods as the UniFFI surface. - -## CI and releases - -A merge to `main` does **not** publish an APK. Neither does a tag push. -Releases are manual and batched: two dispatches. Full procedure: -[docs/RELEASING.md](../docs/RELEASING.md). - -### `android-ci.yml` (verification, not a release) - -Runs on `docker-amd64` (T480 dind) for every `push`/`pull_request` whose paths -include `android/**`, `src/**`, `crates/**`, `Cargo.toml`, `Cargo.lock`, -`scripts/build-android-local.sh`, or the workflow itself — plus -`workflow_dispatch`. Job image is `node:20-bullseye` (EOL) — **do not apt-get -there**. The toolchain runs in a sibling `debian:bookworm` container -(stdin-tar + `docker cp`). Both Android workflows install `cmake` in that -container (RandomX). - -It calls `scripts/build-android-local.sh` with the **debug** key -(`ONIONWIRE_REQUIRE_RELEASE_KEY` unset). Nothing is published. After the APK -is built it greps `lib/arm64-v8a/libonionwire_sdk.so` for `target_max_memory` -and **fails** if that cuprated-only string is missing. - -### `android-release.yml` (the APK that lands on a tag) - -`on:` is `workflow_dispatch` (and a declared `workflow_call` that this Forgejo -10.0.3 instance cannot invoke). **No `push` trigger.** Inputs: - -| Input | Default | Meaning | -|---|---|---| -| `tag` | empty | Existing tag to check out, build, and attach. | -| `dry_run` | `false` | Build and checksum; skip the Pi publish job. | - -Operator path, after `release.yml` has minted the tag (`dry_run=true` on that -workflow first): - -1. Actions → **android-release** → Run workflow, `tag=vX.Y.Z` (the tag core - just created), `dry_run=false`. -2. The Android job **checks out that tag** (`ref:` is the tag, not `main`) and - stamps `versionName` / `versionCode` from it. -3. `versionCode` is `major*10000 + minor*100 + patch` (so 0.5.0 → 500). -4. Publish is a second job on the Pi runner (`docker`). It attaches - `onionwire--android-arm64-v8a.apk`, `onionwire-sdk-.aar`, - and both `.sha256` files to **that same tag**. - -The APK is built from **the tag's tree**. Building from `main` and stamping a -tag you did not check out is how you ship a binary that does not match the -tag. - -**Empty `tag` is the foot-gun.** Checkout then falls back to `github.sha` -(usually `main` HEAD). Version is *not* "latest `v*.*.*` plus patch" as a -rule: - -* no tags at all → `0.1.0`; -* latest `v*.*.*` release is **missing** the Android APK (or the job cannot - inspect the release) → **join** that version: same `versionName` restamped - onto whatever tree was checked out. Android will refuse to install that APK - over an already-installed build of the same `versionName`/`versionCode`; -* latest tag already has an Android APK → `patch+1` of that version, still - built from `github.sha`, and this workflow may then **create** that new tag - at publish time if it does not exist. - -Do not dispatch `android-release` with an empty `tag` to ship a release. Core -owns minting (`release.yml`, default `bump=minor`). This workflow attaches. - -`workflow_dispatch` with `dry_run=true` builds and checksums without -publishing. `scripts/build-android-local.sh` remains the offline fallback; it -does not create tags. - -The Android job image / bookworm-container story is the same as `android-ci.yml`. -The cuprated graph is built with Rust 1.98 here, the same floor as `ci.yml` -(`rust-version = "1.98"`). Job timeout is **90** minutes on `android-release.yml` and **120** -on `android-ci.yml`. - -## App shell - -Three top-level destinations, one persistent bottom tab bar -(`ui/components/BottomTabBar.kt`): **Chats** (default), **Wallet**, and **Node & -Settings**. Sub-screens (chat, invite share, add contact, rotate, profile, saved -wallets) keep a chevron back button and hide the bar. The rare and destructive -actions — rotate identity, delete message history, saved wallets — are behind the -`⋮` overflow and a typed confirmation, not on the home screen. - -Colours, radii and type live in `ui/Theme.kt` as `OwColors` / `OwRadius` / -`OwSize`; new UI takes tokens from there instead of `MaterialTheme` defaults. -Monospace is reserved for pubkeys, truncated onion locators, seeds, `host:port` -and block heights — never for a sentence. - -## Layout - -``` -android/ - settings.gradle.kts - build.gradle.kts # plugin aliases only - gradle/libs.versions.toml # version catalog - gradle/wrapper/ - monero-binaries.sha256 # provenance of the bundled wallet-rpc blob - CUPRATE_DAEMON.md - MONERO_BINARIES.md - sdk/ # -> AAR - build.gradle.kts # cargo-ndk + uniffi-bindgen wiring - consumer-rules.pro - src/main/AndroidManifest.xml - app/ # -> APK - build.gradle.kts - src/main/AndroidManifest.xml - src/main/java/com/siriusdevops/onionwire/ - MainActivity.kt # app shell: bottom tabs + NavHost - WireViewModel.kt # UI-side Wire handle; wallet-child poller - crypto/ # Keystore-wrapped store passphrase - keepalive/ # NodeHost, KeepAliveService, policy, lifetime - wallet/ # ChainStorage, WalletChildBinaries - ui/ # Compose screens (M3) - components/ # design system: OwButton, OwSegmentedControl, - # OwAlertBanner, OwCard, OwTopBar, OwBottomTabBar, - # OwConfirmDialog, OwQrCode, Identicon - WalletScreen.kt - WalletManagerScreen.kt - WalletChildStatusText.kt - ChatScreen.kt - RosterScreen.kt # Chats tab: identity bar + roster - SettingsScreen.kt # Node & Settings tab - ProfileScreen.kt - InviteScreens.kt # share (QR + text) and paste-a-contact - InviteAddFlow.kt - OutboxDetail.kt - MessageDelivery.kt - UnlockScreen.kt - UnlockSubmit.kt - SeedBackupGate.kt - RotateScreen.kt - Insets.kt # systemBars ∪ ime, minus the tab-bar inset - Theme.kt # design tokens: palette, radii, sizes, typography - src/main/res/drawable/ic_ow_*.xml # single-colour design-system icons - src/test/ # JVM: envelope, store, invite, outbox, keepalive, wallet line, refresh loop - src/androidTest/ # device-only: AndroidKeyStore - src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so -``` diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts deleted file mode 100644 index 0f83997..0000000 --- a/android/app/build.gradle.kts +++ /dev/null @@ -1,159 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -plugins { - alias(libs.plugins.android.application) - alias(libs.plugins.kotlin.android) - alias(libs.plugins.kotlin.compose) -} - -fun envOrNull(name: String): String? = - System.getenv(name)?.takeIf { it.isNotBlank() } - -android { - namespace = "com.siriusdevops.onionwire" - compileSdk = 36 - - // Same ABI selection as :sdk. JNA ships libjnidispatch.so for several ABIs; - // without this filter the APK carries native code for ABIs we never built - // our Rust lib for. - val onionwireAbis: List = (findProperty("onionwire.abis") as String?) - ?.split(',')?.map(String::trim)?.filter(String::isNotEmpty) - ?: listOf("arm64-v8a") - - defaultConfig { - applicationId = "com.siriusdevops.onionwire" - minSdk = 26 - targetSdk = 36 - // CI/local release scripts override both via -P. Committed values are - // the offline default and match the first automated tag (v0.1.0 → 100). - versionCode = (findProperty("onionwire.versionCode") as String?)?.toIntOrNull() ?: 100 - versionName = (findProperty("onionwire.versionName") as String?) ?: "0.1.0" - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - ndk { - abiFilters += onionwireAbis - } - } - - signingConfigs { - create("release") { - val ksPath = envOrNull("ANDROID_KEYSTORE_FILE") - if (ksPath != null) { - storeFile = file(ksPath) - storePassword = envOrNull("ANDROID_KEYSTORE_PASSWORD") - ?: error("ANDROID_KEYSTORE_PASSWORD is required when ANDROID_KEYSTORE_FILE is set") - keyAlias = envOrNull("ANDROID_KEY_ALIAS") - ?: error("ANDROID_KEY_ALIAS is required when ANDROID_KEYSTORE_FILE is set") - keyPassword = envOrNull("ANDROID_KEY_PASSWORD") - ?: error("ANDROID_KEY_PASSWORD is required when ANDROID_KEYSTORE_FILE is set") - } - } - } - - buildTypes { - debug { - // Sideload / device-test builds. Signed with the standard debug key. - applicationIdSuffix = ".debug" - versionNameSuffix = "-debug" - } - release { - // Deliberately NOT minified in this card: there is no on-device - // crash-deobfuscation story yet, and shipping R8 without testing - // the JNI/uniffi surface on a real device is how you get a - // mysterious UnsatisfiedLinkError in the field. - // Enable together with mapping-file upload; keeps already exist in - // :sdk/consumer-rules.pro. - isMinifyEnabled = false - isShrinkResources = false - // Repo-owned release keystore via ANDROID_KEYSTORE_* env (Forgejo - // secrets in CI, ~/.android/onionwire-release.env locally). CI sets - // ONIONWIRE_REQUIRE_RELEASE_KEY=true and fails closed if missing — - // the debug keystore is per-machine and would break in-place upgrades. - val requireReleaseKey = - (findProperty("onionwire.requireReleaseKey") as String?) == "true" || - envOrNull("ONIONWIRE_REQUIRE_RELEASE_KEY") == "true" - val releaseSigning = signingConfigs.getByName("release") - val releaseStore = releaseSigning.storeFile - signingConfig = when { - releaseStore != null && releaseStore.isFile -> releaseSigning - requireReleaseKey -> error( - "Release keystore required but ANDROID_KEYSTORE_FILE is missing or not a file" - ) - else -> { - logger.warn( - "No ANDROID_KEYSTORE_FILE; signing the release APK with the debug keystore. " + - "CI must not do this — in-place upgrades will break." - ) - signingConfigs.getByName("debug") - } - } - } - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - - buildFeatures { - compose = true - } - - packaging { - resources { - excludes += "/META-INF/{AL2.0,LGPL2.1}" - } - jniLibs { - // `android:extractNativeLibs="true"`. This is what puts - // `libmonerowalletrpc.so` on disk in `ApplicationInfo.nativeLibraryDir` - // at install time, which is the ONLY directory Android lets an app - // `exec()` from (since API 29 a file in `filesDir` is not executable - // whatever its mode bits say). With the AGP 8 default - // (`extractNativeLibs="false"`) the wallet binary would stay inside - // the APK and `start_wallet_child` would fail with ENOENT on a path - // that looks correct. See android/MONERO_BINARIES.md. - useLegacyPackaging = true - // The wallet child is an executable, not a linked library, and - // scripts/build-monero-wallet-rpc-android.sh already stripped it with - // the target's own strip. Excluding it from AGP's strip pass keeps the - // bytes in the APK identical to the committed blob, which is what - // scripts/build-android-local.sh verifies in CI. - keepDebugSymbols += "**/libmonerowalletrpc.so" - } - } -} - -kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_17) - } -} - -dependencies { - implementation(project(":sdk")) - - implementation(libs.androidx.core.ktx) - implementation(libs.androidx.activity.compose) - implementation(libs.androidx.lifecycle.runtime.compose) - implementation(libs.androidx.lifecycle.viewmodel.compose) - implementation(libs.androidx.navigation.compose) - - implementation(platform(libs.compose.bom)) - implementation(libs.compose.ui) - implementation(libs.compose.ui.graphics) - implementation(libs.compose.ui.tooling.preview) - implementation(libs.compose.material3) - - debugImplementation(libs.compose.ui.tooling) - - testImplementation(libs.junit) - testImplementation(libs.kotlinx.coroutines.test) - - // Device-only: the AndroidKeyStore provider does not exist in the unit-test - // JVM. These run under `./gradlew :app:connectedDebugAndroidTest`. - androidTestImplementation(libs.junit) - androidTestImplementation(libs.androidx.test.ext.junit) - androidTestImplementation(libs.androidx.test.runner) - - // QR code rendering for the wallet receive-address screen. - implementation(libs.zxing) -} diff --git a/android/app/src/androidTest/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipherTest.kt b/android/app/src/androidTest/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipherTest.kt deleted file mode 100644 index fa1ec83..0000000 --- a/android/app/src/androidTest/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipherTest.kt +++ /dev/null @@ -1,450 +0,0 @@ -package com.siriusdevops.onionwire.crypto - -import android.content.Context -import android.content.pm.PackageManager -import android.os.Build -import android.security.keystore.KeyGenParameterSpec -import android.security.keystore.KeyProperties -import android.util.Log -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry -import org.junit.After -import org.junit.Assert.assertArrayEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNotEquals -import org.junit.Assert.assertTrue -import org.junit.Assert.fail -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import java.io.File -import java.security.KeyStore -import javax.crypto.KeyGenerator -import javax.crypto.SecretKey - -/** - * The device half of the Keystore story. The unit-test JVM has no - * `AndroidKeyStore` provider, so nothing here can run as a plain JUnit test. - * - * Run on a real device or an emulator: - * - * ./gradlew :app:connectedDebugAndroidTest - * - * and read the `OnionWireKeystore` tag in logcat for the actual - * `KeyInfo`/`isInsideSecureHardware`/`securityLevel` report — the point of - * [key_backing_is_reported_and_logged] is to print the truth, not to assert a - * hardware-backed key on hardware that does not have one. - * - * The migration tests below are the device half of the device-unlock gate: - * a pre-gate key is retired **only** after the replacement blob opens under the - * new key, and an interrupted migration leaves an install that still unlocks. - * They also log `MANUFACTURER`/`MODEL`/`SDK_INT` and the branch taken, because - * `setUnlockedDeviceRequired` is an OEM-sensitive flag and a red test on a - * specific phone is only diagnosable with that line. - */ -@RunWith(AndroidJUnit4::class) -class KeystorePassphraseCipherTest { - - private val context: Context = - InstrumentationRegistry.getInstrumentation().targetContext - - private val cipher = KeystorePassphraseCipher(context) - - private val passphrase = "correct horse battery staple".toCharArray() - - @Before - fun cleanSlate() { - // Both aliases: a leftover gated key from an aborted run would hide a - // migration that never happened. - val store = keyStore() - for (alias in listOf(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED, KeystorePassphraseCipher.ALIAS)) { - try { - store.deleteEntry(alias) - } catch (_: Exception) { - // Nothing to delete. - } - } - } - - @After - fun tearDown() { - cipher.deleteKey() - } - - @Test - fun seal_open_round_trips_through_the_android_keystore() { - val blob = cipher.seal(passphrase) - assertTrue( - "envelope is magic + IV + ciphertext + tag", - blob.size >= passphrase.size + StoreSecret.IV_BYTES + 16 + 9, - ) - val out = cipher.open(blob) - try { - assertArrayEquals(passphrase, out) - } finally { - StoreSecret.wipe(out) - } - } - - @Test - fun stored_blob_on_a_device_is_not_the_plaintext() { - val dir = File(context.filesDir, "secrets-test") - dir.mkdirs() - val store = StoredPassphraseStore(File(dir, "store-passphrase.bin"), cipher) - try { - store.save(passphrase) - - val raw = File(store.path).readBytes() - val needle = String(passphrase).toByteArray(Charsets.UTF_8) - assertFalse( - "the passphrase must not appear in the file", - String(raw, Charsets.ISO_8859_1).contains(String(needle, Charsets.ISO_8859_1)), - ) - - val loaded = store.load() as StoredPassphraseStore.Load.Loaded - try { - assertArrayEquals(passphrase, loaded.passphrase) - } finally { - StoreSecret.wipe(loaded.passphrase) - } - } finally { - store.forget() - dir.deleteRecursively() - } - } - - @Test - fun key_backing_is_reported_and_logged() { - cipher.seal(passphrase) // force key creation - - val strongBoxAdvertised = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && - context.packageManager.hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE) - val backing = cipher.backing() - val gate = cipher.unlockGateReport() - - Log.i( - TAG, - "alias=${KeystorePassphraseCipher.ALIAS} backing=$backing " + - "strongBoxAdvertised=$strongBoxAdvertised " + - "sdk=${Build.VERSION.SDK_INT} device=${Build.MANUFACTURER} ${Build.MODEL} " + - "gate=${gate.describe()}", - ) - - if (strongBoxAdvertised) { - assertTrue( - "StrongBox is advertised but the key did not land in a secure element: $backing", - backing == KeyBacking.STRONGBOX || backing == KeyBacking.HARDWARE, - ) - } else { - assertNotEquals("the API refused to report the backing at all", KeyBacking.UNKNOWN, backing) - } - } - - @Test - fun open_does_not_require_user_authentication() { - // The card's contract: unlocking must not need a fingerprint. If the - // key had been created with setUserAuthenticationRequired(true), this - // open() would throw UserNotAuthenticatedException. The device-unlock - // gate is a different flag: it only refuses while the lock screen is up, - // which is not the case while this test runs. - val out = cipher.open(cipher.seal(passphrase)) - StoreSecret.wipe(out) - assertTrue(cipher.keyPresent()) - } - - @Test - fun deleted_key_reports_unavailable_instead_of_crashing() { - val blob = cipher.seal(passphrase) - cipher.deleteKey() - - assertFalse(cipher.keyPresent()) - try { - cipher.open(blob) - fail("expected SecretUnavailable after the key was deleted") - } catch (e: SecretUnavailable) { - assertTrue(e.message!!.contains("gone")) - } - } - - @Test - fun a_regenerated_key_cannot_open_an_old_blob() { - val blob = cipher.seal(passphrase) - cipher.deleteKey() // a reset that leaves the app's data dir intact - cipher.seal(passphrase) // same alias, brand-new key - - try { - cipher.open(blob) - fail("expected SecretUnavailable for a blob wrapped by the deleted key") - } catch (_: SecretUnavailable) { - } - } - - // ------------------------------------------------------- device-unlock gate - - /** - * The upgrade path: an install that stored its passphrase before the gate - * landed has one pre-gate key and a blob wrapped by it. The next successful - * unlock re-wraps that blob under a newly generated unlock-gated key, proves - * it, and only then retires the old alias. - */ - @Test - fun a_pre_flag_key_is_migrated_to_the_unlock_gated_alias_on_unlock() { - val branch = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - "unlock-gated (API >= 28)" - } else { - "ungated (API < 28 — setUnlockedDeviceRequired unavailable)" - } - Log.i( - TAG, - "migration: manufacturer=${Build.MANUFACTURER} model=${Build.MODEL} " + - "sdk=${Build.VERSION.SDK_INT} branch=$branch", - ) - - val legacy = createPreFlagKey() - val dir = File(context.filesDir, "secrets-migration") - dir.mkdirs() - val store = StoredPassphraseStore(File(dir, "store-passphrase.bin"), cipher) - try { - val blob = StoreSecret.seal(legacy, passphrase) - try { - File(store.path).writeBytes(blob) - } finally { - StoreSecret.wipe(blob) - } - assertTrue("precondition: the pre-gate alias exists", hasAlias(KeystorePassphraseCipher.ALIAS)) - assertFalse( - "precondition: no gated key yet", - hasAlias(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED), - ) - - // The unlock path: load() is where the passphrase is in hand. - val loaded = store.load() as StoredPassphraseStore.Load.Loaded - try { - assertArrayEquals("the unlock must still return the passphrase", passphrase, loaded.passphrase) - } finally { - StoreSecret.wipe(loaded.passphrase) - } - - val gate = cipher.unlockGateReport() - Log.i(TAG, "migration: after=${gate.describe()} legacyPending=${gate.legacyKeyPending}") - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - assertTrue( - "expected a gated key after the re-wrap: ${gate.describe()}", - hasAlias(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED), - ) - assertFalse( - "the pre-gate key must be retired once the new blob verifies: ${gate.describe()}", - hasAlias(KeystorePassphraseCipher.ALIAS), - ) - assertTrue("the report must say the live key is gated: ${gate.describe()}", gate.keyIsUnlockGated) - assertFalse("nothing may stay pending: ${gate.describe()}", gate.legacyKeyPending) - - // The blob on disk must open under the NEW key alone — this is - // the proof the alias delete was allowed to happen. - val onDisk = File(store.path).readBytes() - val back = try { - StoreSecret.open(requireNotNull(gatedKey()), onDisk) - } finally { - StoreSecret.wipe(onDisk) - } - try { - assertArrayEquals(passphrase, back) - } finally { - StoreSecret.wipe(back) - } - } else { - assertFalse( - "API 26–27 has no flag, so no gated key may be invented", - hasAlias(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED), - ) - assertTrue("below API 28 the pre-gate key stays", hasAlias(KeystorePassphraseCipher.ALIAS)) - } - } finally { - store.forget() - dir.deleteRecursively() - } - } - - /** - * Every failure before "the new blob verified" must leave the previous blob - * and the pre-gate key in place. The simulated failure is the proof step - * itself, which is exactly the step that guards the alias delete. - */ - @Test - fun a_failed_re_wrap_keeps_the_pre_gate_key_and_the_previous_blob() { - val legacy = createPreFlagKey() - val dir = File(context.filesDir, "secrets-failed-migration") - dir.mkdirs() - val file = File(dir, "store-passphrase.bin") - try { - val oldBlob = StoreSecret.seal(legacy, passphrase) - try { - file.writeBytes(oldBlob) - } finally { - StoreSecret.wipe(oldBlob) - } - val before = file.readBytes() - try { - val doomed = StoredPassphraseStore(file, FailingVerifyCipher(cipher)) - try { - doomed.save(passphrase) - fail("expected the simulated verification failure") - } catch (e: SecretUnavailable) { - assertTrue( - "the reason must say the old copy was kept: ${e.message}", - e.message!!.contains("previous blob and key were kept"), - ) - } - - assertTrue( - "the pre-gate key must survive a failed re-wrap", - hasAlias(KeystorePassphraseCipher.ALIAS), - ) - assertFalse( - "a failed re-wrap must not leave a temp blob behind", - File(dir, "store-passphrase.bin.tmp").exists(), - ) - assertArrayEquals( - "the previous blob must be untouched by a failed re-wrap", - before, - file.readBytes(), - ) - } finally { - StoreSecret.wipe(before) - } - - // The previous blob is byte-for-byte intact and still opens with the - // pre-gate key: an install that has not migrated is still usable. - val untouched = file.readBytes() - try { - val back = StoreSecret.open(requireNotNull(legacyKey()), untouched) - try { - assertArrayEquals(passphrase, back) - } finally { - StoreSecret.wipe(back) - } - } finally { - StoreSecret.wipe(untouched) - } - - // A save that can verify finishes the migration on the spot. - StoredPassphraseStore(file, cipher).save(passphrase) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - assertFalse( - "the pre-gate key is retired as soon as the re-wrap verifies", - hasAlias(KeystorePassphraseCipher.ALIAS), - ) - assertTrue(hasAlias(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED)) - } - } finally { - cipher.deleteKey() - dir.deleteRecursively() - } - } - - /** - * The mirror of [a_pre_flag_key_is_migrated_to_the_unlock_gated_alias_on_unlock]: - * the proof step must use the gated key only. A fallback decrypt succeeding - * must never be mistaken for "the new blob is wrapped by the new key" — that - * is what would allow the alias delete to destroy the only working copy. - */ - @Test - fun the_gated_proof_refuses_a_blob_wrapped_by_the_pre_gate_key() { - val legacy = createPreFlagKey() - val blob = StoreSecret.seal(legacy, passphrase) - try { - cipher.seal(passphrase) // creates the gated key; the legacy key still exists - try { - cipher.openWithUnlockGate(blob) - fail("a pre-gate blob must not verify under the unlock-gated key") - } catch (_: SecretUnavailable) { - // On API 26–27 there is no gated key at all, so this is the - // "no key to prove against" refusal. Both are refusals. - } - } finally { - StoreSecret.wipe(blob) - } - } - - /** The crash window: gated key created, blob not yet replaced. Must still open. */ - @Test - fun a_blob_wrapped_by_the_pre_gate_key_still_opens_while_both_keys_exist() { - val legacy = createPreFlagKey() - val blob = StoreSecret.seal(legacy, passphrase) - try { - cipher.seal(passphrase) // gated key now exists too - - val out = cipher.open(blob) - try { - assertArrayEquals(passphrase, out) - } finally { - StoreSecret.wipe(out) - } - } finally { - StoreSecret.wipe(blob) - } - } - - // ------------------------------------------------------------------ helpers - - private fun keyStore(): KeyStore = - KeyStore.getInstance(KeystorePassphraseCipher.PROVIDER).apply { load(null) } - - private fun hasAlias(alias: String): Boolean = keyStore().containsAlias(alias) - - private fun key(alias: String): SecretKey? = keyStore().getKey(alias, null) as? SecretKey - - private fun gatedKey(): SecretKey? = key(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED) - - private fun legacyKey(): SecretKey? = key(KeystorePassphraseCipher.ALIAS) - - /** - * Reproduces the key the app generated before the device-unlock gate - * existed: AES-256-GCM under [KeystorePassphraseCipher.ALIAS], no user-auth - * requirement, no unlock requirement. This is the install state the - * migration test starts from, not a new production path. - */ - private fun createPreFlagKey(): SecretKey { - val spec = KeyGenParameterSpec.Builder( - KeystorePassphraseCipher.ALIAS, - KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT, - ) - .setBlockModes(KeyProperties.BLOCK_MODE_GCM) - .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE) - .setKeySize(StoreSecret.KEY_BITS) - .setRandomizedEncryptionRequired(true) - .setUserAuthenticationRequired(false) - .build() - val generator = KeyGenerator.getInstance( - KeyProperties.KEY_ALGORITHM_AES, - KeystorePassphraseCipher.PROVIDER, - ) - generator.init(spec) - return generator.generateKey() - } - - /** - * Delegates to the real Keystore cipher except for the proof step, so the - * "the old key is deleted only after the new blob verifies" ordering can be - * asserted on a device without a way to corrupt a real Keystore blob. - */ - private class FailingVerifyCipher( - private val real: KeystorePassphraseCipher, - ) : PassphraseCipher by real, PassphraseKeyMigration { - override fun unlockGateInEffect(): Boolean = real.unlockGateInEffect() - - override fun legacyKeyPending(): Boolean = real.legacyKeyPending() - - override fun openWithUnlockGate(blob: ByteArray): CharArray = - throw SecretUnavailable("simulated verify failure") - - override fun retireLegacyKey() = real.retireLegacyKey() - - override fun noteMigrationFailure(reason: String) = real.noteMigrationFailure(reason) - } - - private companion object { - const val TAG = KeystorePassphraseCipher.TAG - } -} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml deleted file mode 100644 index 7c3278d..0000000 --- a/android/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt b/android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt deleted file mode 100644 index 84d98a4..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt +++ /dev/null @@ -1,277 +0,0 @@ -package com.siriusdevops.onionwire - -import android.Manifest -import android.os.Build -import android.os.Bundle -import androidx.activity.ComponentActivity -import androidx.activity.compose.rememberLauncherForActivityResult -import androidx.activity.compose.setContent -import androidx.activity.enableEdgeToEdge -import androidx.activity.result.contract.ActivityResultContracts -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Surface -import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.ui.Modifier -import androidx.core.view.WindowCompat -import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.lifecycle.viewmodel.compose.viewModel -import androidx.navigation.NavHostController -import androidx.navigation.NavType -import androidx.navigation.compose.NavHost -import androidx.navigation.compose.composable -import androidx.navigation.compose.currentBackStackEntryAsState -import androidx.navigation.compose.rememberNavController -import androidx.navigation.navArgument -import com.siriusdevops.onionwire.ui.ChatScreen -import com.siriusdevops.onionwire.ui.LocalBottomBarPresent -import com.siriusdevops.onionwire.ui.OnionWireTheme -import com.siriusdevops.onionwire.ui.PasteInviteScreen -import com.siriusdevops.onionwire.ui.ProfileScreen -import com.siriusdevops.onionwire.ui.RosterScreen -import com.siriusdevops.onionwire.ui.RotateScreen -import com.siriusdevops.onionwire.ui.SettingsScreen -import com.siriusdevops.onionwire.ui.ShareInviteScreen -import com.siriusdevops.onionwire.ui.UnlockScreen -import com.siriusdevops.onionwire.ui.WalletManagerScreen -import com.siriusdevops.onionwire.ui.WalletScreen -import com.siriusdevops.onionwire.ui.components.OwBottomTabBar -import com.siriusdevops.onionwire.ui.components.OwTab -import kotlinx.coroutines.launch - -class MainActivity : ComponentActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - enableEdgeToEdge() - // The shell paints the canvas to the bottom of the screen behind the tab - // bar; the system's translucent three-button scrim would draw a second, - // lighter band over it (edge-to-edge guidance, SDK 29+). - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - window.isNavigationBarContrastEnforced = false - } - // enableEdgeToEdge() from ComponentActivity sets the icon appearance from - // the system theme; the app is dark-only, so the bars are always dark with - // light icons. Re-assert it here in case the theme changes under us. - WindowCompat.getInsetsController(window, window.decorView).apply { - isAppearanceLightStatusBars = false - isAppearanceLightNavigationBars = false - } - setContent { - OnionWireTheme { - Surface( - modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colorScheme.background, - ) { - AppRoot() - } - } - } - } -} - -@Composable -private fun AppRoot(vm: WireViewModel = viewModel()) { - val phase by vm.phase.collectAsStateWithLifecycle() - val unlock by vm.unlock.collectAsStateWithLifecycle() - val keepAliveNote by vm.keepAliveNote.collectAsStateWithLifecycle() - - // Asked in context: the notification is the keep-alive's only visible - // trace, so the prompt lands when the node becomes reachable rather than at - // first launch. Denial is not fatal — the service runs either way and the - // settings screen says the notice is hidden. - val askNotifications = rememberLauncherForActivityResult( - ActivityResultContracts.RequestPermission(), - ) { vm.onNotificationPermissionChanged() } - - LaunchedEffect(phase) { - if (phase is Phase.Ready && - Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && - !vm.notificationsAllowed() - ) { - askNotifications.launch(Manifest.permission.POST_NOTIFICATIONS) - } - } - - when (val p = phase) { - is Phase.Ready -> ReadyGraph(vm, p, keepAliveNote) - else -> UnlockScreen( - phase = p, - unlock = unlock, - onUnlock = vm::unlock, - onUnlockStored = vm::unlockStored, - onForgetStored = vm::forgetStoredPassphrase, - ) - } -} - -/** Top-level destinations. Everything else is a sub-screen with a chevron. */ -private object Routes { - const val Chats = "chats" - const val Wallet = "wallet" - const val Settings = "settings" - const val Share = "share" - const val Paste = "paste" - const val Rotate = "rotate" - const val Profile = "profile" - const val Wallets = "wallets" - const val Chat = "chat/{pk}" - - fun tabOf(route: String?): OwTab? = when (route) { - Chats -> OwTab.Chats - Wallet -> OwTab.Wallet - Settings -> OwTab.Settings - else -> null - } - - fun routeOf(tab: OwTab): String = when (tab) { - OwTab.Chats -> Chats - OwTab.Wallet -> Wallet - OwTab.Settings -> Settings - } -} - -/** - * The app shell. - * - * A `Scaffold` whose only job is the persistent bottom tab bar: it owns the - * navigation-bar inset, the screens keep owning their own top bars and system - * insets (see `screenContentInsets`), and `LocalBottomBarPresent` tells those - * screens not to pad for the bar a second time. - * - * Selecting a tab pops back to the start destination and restores that tab's - * saved state, so a chat left open behind the Wallet tab is still there when the - * user comes back — the standard bottom-nav contract. - */ -@Composable -private fun ReadyGraph(vm: WireViewModel, ready: Phase.Ready, keepAliveNote: String?) { - val nav = rememberNavController() - val friends by vm.friends.collectAsStateWithLifecycle() - val scope = rememberCoroutineScope() - val entry by nav.currentBackStackEntryAsState() - val tab = Routes.tabOf(entry?.destination?.route) - - Scaffold( - // Each screen's Scaffold applies its own bars; zeroing this one keeps the - // status bar from being padded twice and leaves the only inset this - // level owns — the tab bar's height — in `pad`. - contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = MaterialTheme.colorScheme.background, - bottomBar = { - if (tab != null) { - OwBottomTabBar(selected = tab, onSelect = { nav.selectTab(it) }) - } - }, - ) { pad -> - CompositionLocalProvider(LocalBottomBarPresent provides (tab != null)) { - NavHost( - navController = nav, - startDestination = Routes.Chats, - modifier = Modifier.padding(bottom = pad.calculateBottomPadding()), - ) { - composable(Routes.Chats) { - RosterScreen( - fingerprint = ready.fingerprint, - friends = friends, - invite = vm::invite, - onOpenChat = { nav.navigate("chat/${it.pubkeyHex}") }, - onShare = { nav.navigate(Routes.Share) }, - onPaste = { nav.navigate(Routes.Paste) }, - onRotate = { nav.navigate(Routes.Rotate) }, - onWipe = { scope.launch { vm.wipeMessages() } }, - onOpenProfile = { nav.navigate(Routes.Profile) }, - onLock = vm::lock, - onOpenWallets = { nav.navigate(Routes.Wallets) }, - ) - } - - composable(Routes.Wallet) { - // A top-level tab, so no back chevron — same shape as the - // Chats and Node & Settings destinations. The catalogue - // sub-screen still gets one from its own top bar. - WalletScreen( - vm = vm, - onOpenWallets = { nav.navigate(Routes.Wallets) }, - ) - } - - composable(Routes.Settings) { - SettingsScreen( - sdkVersion = ready.sdkVersion, - keepAliveNote = keepAliveNote, - onOpenProfile = { nav.navigate(Routes.Profile) }, - onOpenWallets = { nav.navigate(Routes.Wallets) }, - onRotate = { nav.navigate(Routes.Rotate) }, - onWipe = { scope.launch { vm.wipeMessages() } }, - onLock = vm::lock, - ) - } - - composable(Routes.Share) { - ShareInviteScreen(ownerInvite = vm::invite, onBack = { nav.popBackStack() }) - } - - composable(Routes.Paste) { - PasteInviteScreen( - onDecode = vm::decode, - onAdd = vm::addFriend, - onBack = { nav.popBackStack() }, - ) - } - - composable(Routes.Rotate) { - RotateScreen( - currentOnion = ready.onion, - onRotate = { - val out = vm.rotateOnion() - out.notified.toInt() to out.friends.toInt() - }, - onBack = { nav.popBackStack() }, - ) - } - - composable(Routes.Wallets) { - WalletManagerScreen(vm = vm, onBack = { nav.popBackStack() }) - } - - composable(Routes.Profile) { - ProfileScreen(vm = vm, onBack = { nav.popBackStack() }) - } - - composable( - route = Routes.Chat, - arguments = listOf(navArgument("pk") { type = NavType.StringType }), - ) { chatEntry -> - val pk = chatEntry.arguments?.getString("pk").orEmpty() - val friend = friends.firstOrNull { it.pubkeyHex == pk } - ChatScreen( - vm = vm, - peer = pk, - title = friend?.petname?.takeIf { it.isNotBlank() } - ?: friend?.fingerprint - ?: pk.take(16), - fingerprint = friend?.fingerprint ?: pk.take(16), - onion = friend?.onion.orEmpty(), - onBack = { nav.popBackStack() }, - ) - } - } - } - } -} - -private fun NavHostController.selectTab(target: OwTab) { - val route = Routes.routeOf(target) - if (currentDestination?.route == route) return - navigate(route) { - popUpTo(graph.startDestinationId) { saveState = true } - launchSingleTop = true - restoreState = true - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt b/android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt deleted file mode 100644 index 5da0390..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt +++ /dev/null @@ -1,1182 +0,0 @@ -package com.siriusdevops.onionwire - -import android.app.Application -import android.content.Context -import android.content.SharedPreferences -import androidx.core.app.NotificationManagerCompat -import androidx.lifecycle.AndroidViewModel -import androidx.lifecycle.viewModelScope -import com.siriusdevops.onionwire.crypto.KeyBacking -import com.siriusdevops.onionwire.crypto.KeystorePassphraseCipher -import com.siriusdevops.onionwire.crypto.StoreSecret -import com.siriusdevops.onionwire.crypto.StoredPassphraseStore -import com.siriusdevops.onionwire.keepalive.KeepAliveService -import com.siriusdevops.onionwire.keepalive.KeepAliveStatus -import com.siriusdevops.onionwire.keepalive.NodeHost -import com.siriusdevops.onionwire.ui.SeedBackupGate -import com.siriusdevops.onionwire.ui.WalletKeyOrigin -import com.siriusdevops.onionwire.ui.NO_CHAIN_SOURCE_NOTICE -import com.siriusdevops.onionwire.ui.storedWalletBinBlockedReason -import com.siriusdevops.onionwire.ui.walletBinHealPath -import com.siriusdevops.onionwire.ui.walletFailureText -import com.siriusdevops.onionwire.wallet.ChainStorage -import com.siriusdevops.onionwire.wallet.NO_WALLET_RPC_MESSAGE -import com.siriusdevops.onionwire.wallet.WalletChildBinaries -import com.siriusdevops.onionwire.wallet.WalletChildBinaryPaths -import kotlinx.coroutines.CancellationException -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlinx.coroutines.currentCoroutineContext -import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.flow.update -import kotlinx.coroutines.isActive -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext -import uniffi.onionwire_sdk.ChainChoice -import uniffi.onionwire_sdk.ChainConfig -import uniffi.onionwire_sdk.ChatMessage -import uniffi.onionwire_sdk.FriendInfo -import uniffi.onionwire_sdk.InviteInfo -import uniffi.onionwire_sdk.OutboxRow -import uniffi.onionwire_sdk.RotateOutcome -import uniffi.onionwire_sdk.SelfProfile -import uniffi.onionwire_sdk.SendState -import uniffi.onionwire_sdk.TransferRow -import uniffi.onionwire_sdk.WalletChildStatus -import uniffi.onionwire_sdk.WalletKeys -import uniffi.onionwire_sdk.WalletRow -import uniffi.onionwire_sdk.Wire -import uniffi.onionwire_sdk.decodeInvite -import java.io.File -import java.util.concurrent.atomic.AtomicBoolean - -sealed interface Phase { - /** No identity unlocked. Nothing Tor-related is running. */ - data object Locked : Phase - - /** Bootstrap + onion publish. Cold start is minutes, not seconds. */ - data object Opening : Phase - - data class Ready( - val fingerprint: String, - val onion: String, - val sdkVersion: String, - ) : Phase - - data class Failed(val message: String) : Phase -} - -/** - * How the lock screen expects the next unlock to happen. - * - * This is a probe of local state, not a promise: [OneTap] means a blob exists - * *and* decrypted successfully during this process's lifetime. - */ -sealed interface Unlock { - /** - * The passphrase must be typed. [notice] explains why a stored one is not - * being used (key invalidated, blob corrupt, nothing stored yet). - */ - data class TypeIt(val notice: String? = null) : Unlock - - /** A stored, decryptable passphrase exists — one tap. */ - data class OneTap(val backing: KeyBacking) : Unlock -} - -/** - * Everything one open chat screen renders, refreshed on a single cadence. - * - * [messages] is null until the first read lands — the screen shows its spinner - * on that, exactly as it did reading the SDK itself. [error] is the last load - * failure and is sticky on purpose: it survives the ticks that succeed, so a - * transient store error is still on screen after the next 2s tick rather than - * blinking away. A send clears it (the user has acted on it). - */ -data class ChatState( - val messages: List? = null, - val outbox: List = emptyList(), - val maxAttempts: UInt? = null, - val error: String? = null, -) - -/** - * Owns the UI side of the process's single node. - * - * The node itself lives in [NodeHost], not here, because it now has two - * possible owners: this ViewModel while the UI is up, and [KeepAliveService] - * while the screen is off. A configuration change still must not drop a - * published onion, and neither must the activity being destroyed — that part - * is unchanged. - */ -class WireViewModel(app: Application) : AndroidViewModel(app) { - - /** `context.filesDir` — app-private, never external storage. */ - private val home: File = File(app.filesDir, "onionwire") - - /** - * The Keystore-wrapped passphrase. Two files at most: this blob and the - * KeyStore key under alias [KeystorePassphraseCipher.ALIAS]. Nothing else - * on disk ever sees the plaintext. - */ - private val secrets: StoredPassphraseStore = StoredPassphraseStore( - File(File(app.filesDir, "secrets"), "store-passphrase.bin"), - KeystorePassphraseCipher(app), - ) - - private val _phase = MutableStateFlow(Phase.Locked) - val phase: StateFlow = _phase.asStateFlow() - - private val _unlock = MutableStateFlow(Unlock.TypeIt()) - val unlock: StateFlow = _unlock.asStateFlow() - - private val _friends = MutableStateFlow>(emptyList()) - val friends: StateFlow> = _friends.asStateFlow() - - /** - * One line of battery honesty for the roster: what is still running once - * the screen is off, or why it is not. Null while locked. - */ - private val _keepAliveNote = MutableStateFlow(null) - val keepAliveNote: StateFlow = _keepAliveNote.asStateFlow() - - /** - * The currently open chat, or null when no chat screen is composed. - * - * There is exactly one node and one chat on screen at a time, so this is - * one state object rather than a map keyed by peer: a second poller for a - * second peer would double the SDK traffic for a screen nobody is looking - * at, and the node's store reads are not free. - */ - private val _chat = MutableStateFlow(null) - val chat: StateFlow = _chat.asStateFlow() - - /** The peer [chat] belongs to; guards a stale tick from a previous peer. */ - private var chatPeer: String? = null - - private var chatPoller: Job? = null - - init { - // A node the foreground service kept alive is still open. Adopt it and - // go straight to the roster: showing an unlock screen for a store that - // is already open would be theatre, and unlocking again would race the - // live node for the sqlite file. - val existing = NodeHost.current() - when { - existing != null -> viewModelScope.launch { adopt(existing) } - NodeHost.isOpening() -> { - _phase.value = Phase.Opening - viewModelScope.launch { resumeOpening() } - } - else -> refreshUnlockState() - } - - viewModelScope.launch { - NodeHost.keepAlive.collect { renderKeepAliveNote(it) } - } - } - - /** - * Unlocks with a typed passphrase. Empty fails closed — the SDK maps it - * straight to an error, it is not a "skip" path. - * - * [remember] wraps the passphrase with the Keystore key so later launches - * are one tap. It is opt-in in the UI (and on by default there); it is - * never implied by this call. - */ - fun unlock(passphrase: String, remember: Boolean = false) { - if (passphrase.isEmpty()) return - openWith(passphrase.toCharArray(), storeAfterwards = remember) - } - - /** - * One-tap unlock from the stored blob. - * - * Any failure — key deleted, blob corrupt, GCM tag mismatch — degrades to - * "type it" with the reason on screen. It never crashes and never silently - * unlocks with something else. - */ - fun unlockStored() { - if (_phase.value is Phase.Opening) return - viewModelScope.launch { - val loaded = withContext(Dispatchers.IO) { secrets.load() } - when (loaded) { - is StoredPassphraseStore.Load.Loaded -> - openWith(loaded.passphrase, storeAfterwards = false) - - StoredPassphraseStore.Load.Absent -> { - _unlock.value = Unlock.TypeIt("No passphrase is stored on this device.") - } - - is StoredPassphraseStore.Load.Unavailable -> { - _unlock.value = Unlock.TypeIt(unavailableNotice(loaded.reason)) - } - } - } - } - - /** Drops the stored passphrase and its Keystore key. Irreversible. */ - fun forgetStoredPassphrase() { - viewModelScope.launch { - withContext(Dispatchers.IO) { secrets.forget() } - _unlock.value = Unlock.TypeIt( - "Stored passphrase deleted. Type it to open the store again.", - ) - } - } - - /** - * Explicit Lock: stops the node and the keep-alive with it. - * - * Order matters. The service goes first — a still-running keep-alive would - * re-anchor the node and leave a notification pointing at a dead onion — - * then the policy tears the node down, flush before `shutdown()` so the - * outbox survives. - */ - fun lock() { - if (NodeHost.current() == null) return - // Stop the chat tick before the node goes: the next read of a closed - // store would surface as a chat load error on a screen the user has - // already left, and every tick would keep re-reporting it. - stopChatPoller() - KeepAliveService.stop(getApplication()) - NodeHost.lock() - _friends.value = emptyList() - _phase.value = Phase.Locked - refreshUnlockState() - } - - /** - * The UI is going away: a normal finish, a task swipe, or the process being - * killed. This deliberately does **not** shut the node down — [NodeHost] - * decides between "flush and stay published" (a keep-alive is holding it) - * and "flush and stop" (nothing is). A ViewModel that shut down a node the - * foreground service owns is the bug this card exists to avoid. - */ - override fun onCleared() { - NodeHost.onUiDetached() - super.onCleared() - } - - /** Re-reads the notification state after the runtime prompt resolves. */ - fun onNotificationPermissionChanged() { - renderKeepAliveNote(NodeHost.keepAlive.value) - // Android does not retroactively post a foreground notification that was - // suppressed while POST_NOTIFICATIONS was denied — the service started, - // the user then granted, and the shade stayed empty. Re-announce, so the - // grant actually produces the one honest signal the user has. - if (NodeHost.keepAlive.value is KeepAliveStatus.On) { - viewModelScope.launch { - NodeHost.current()?.let { KeepAliveService.start(getApplication(), it.onion()) } - } - } - } - - /** Whether the keep-alive's notification can actually be posted. */ - fun notificationsAllowed(): Boolean = - NotificationManagerCompat.from(getApplication()).areNotificationsEnabled() - - private fun renderKeepAliveNote(status: KeepAliveStatus) { - val text = getApplication() - _keepAliveNote.value = when (status) { - // Not a null note: "off" is a real state the user should be able to - // read, right after the notification's Stop action. - KeepAliveStatus.Off -> text.getString(R.string.keep_alive_note_off) - - KeepAliveStatus.On -> text.getString( - if (notificationsAllowed()) { - R.string.keep_alive_note_on - } else { - // Denial is not fatal: the service runs either way and - // Android lists it in the Task Manager. Say that instead of - // pretending the notification is there. - R.string.keep_alive_note_hidden - }, - ) - - is KeepAliveStatus.Unavailable -> - text.getString(R.string.keep_alive_note_unavailable, status.reason) - } - } - - /** - * The one path that opens the SDK. - * - * [secret] is wiped in `finally`, including when the Keystore write or the - * SDK call throws. The SDK's UniFFI signature takes a `String`, so one - * immutable copy is unavoidable here — see PR #49 for the follow-up SDK - * signature this card cannot make itself. - */ - private fun openWith(secret: CharArray, storeAfterwards: Boolean) { - if (secret.isEmpty() || _phase.value is Phase.Opening) { - StoreSecret.wipe(secret) - return - } - val existing = NodeHost.current() - if (existing != null) { - // Already open, kept alive while the UI was gone: adopt, never - // re-open. The live node holds the sqlite file and Arti's state - // lock, so a second open would fail — or worse, half-succeed. - StoreSecret.wipe(secret) - viewModelScope.launch { adopt(existing) } - return - } - _phase.value = Phase.Opening - NodeHost.noteOpening() - // Hold the process from this tap, not after Tor publishes: otherwise - // closing the activity cancels viewModelScope and kills bootstrap. - KeepAliveService.start(getApplication(), "") - viewModelScope.launch { - try { - val w = NodeHost.open(home, secret.concatToString()) - if (storeAfterwards) store(secret) - adopt(w) - startKeepAlive(w) - } catch (t: CancellationException) { - throw t - } catch (t: Throwable) { - _phase.value = Phase.Failed(t.message ?: t.toString()) - if (!NodeHost.hasWorkForKeepAlive()) { - KeepAliveService.stop(getApplication()) - } - } finally { - StoreSecret.wipe(secret) - } - } - } - - /** - * Points the UI at a node that is already running. The SDK getters are - * `suspend`, hence the coroutine call sites. - */ - private suspend fun adopt(w: Wire) { - _phase.value = Phase.Ready( - fingerprint = w.fingerprint(), - onion = w.onion(), - sdkVersion = w.version(), - ) - runCatching { refreshFriends() } - } - - /** Re-attach after the activity died mid-bootstrap. */ - private suspend fun resumeOpening() { - try { - val w = NodeHost.awaitOpen() - adopt(w) - startKeepAlive(w) - } catch (t: CancellationException) { - throw t - } catch (t: Throwable) { - _phase.value = Phase.Failed(t.message ?: t.toString()) - } - } - - /** - * Starts the foreground keep-alive. Always reached from a user-visible - * unlock, so the API 31+ background-start restriction does not apply; if - * the system refuses anyway, [NodeHost] records why and the roster says so. - */ - private suspend fun startKeepAlive(w: Wire) { - // Announced even when the keep-alive is already `On`: it was anchored at - // the Open tap with an empty locator, so the notice says "OnionWire is - // starting". The POST_NOTIFICATIONS callback happens to re-announce on a - // fresh install, but on a device that already granted notifications - // there is no callback at all — the notice would then claim bootstrap - // forever. Same notification id, so this replaces it with the address - // the user can actually hand out. - KeepAliveService.start(getApplication(), w.onion()) - } - - private suspend fun store(secret: CharArray) { - val outcome: Result = withContext(Dispatchers.IO) { - try { - secrets.save(secret) - Result.success(secrets.backing()) - } catch (t: Throwable) { - Result.failure(t) - } - } - _unlock.value = outcome.fold( - onSuccess = { Unlock.OneTap(it) }, - onFailure = { - // Unlock succeeded, so this is not fatal — say so plainly - // instead of pretending the passphrase was stored. - Unlock.TypeIt("Could not store the passphrase: ${it.message ?: it}.") - }, - ) - } - - private fun refreshUnlockState() { - viewModelScope.launch { - val state = withContext(Dispatchers.IO) { - when (val loaded = secrets.load()) { - is StoredPassphraseStore.Load.Loaded -> { - // We only needed to know it decrypts. Wipe immediately. - StoreSecret.wipe(loaded.passphrase) - Unlock.OneTap(secrets.backing()) - } - - StoredPassphraseStore.Load.Absent -> Unlock.TypeIt() - - is StoredPassphraseStore.Load.Unavailable -> - Unlock.TypeIt(unavailableNotice(loaded.reason)) - } - } - _unlock.value = state - } - } - - private fun unavailableNotice(reason: String): String = - "The stored passphrase could not be read — $reason. Type it once to store it again." - - private fun requireWire(): Wire = NodeHost.requireOpen() - - suspend fun refreshFriends() { - _friends.value = requireWire().friends() - } - - suspend fun invite(): String = requireWire().invite() - - suspend fun addFriend(invite: String): FriendInfo { - val f = requireWire().addFriend(invite) - refreshFriends() - return f - } - - suspend fun setPetname(pubkeyHex: String, petname: String?) { - requireWire().setPetname(pubkeyHex, petname?.takeIf { it.isNotBlank() }) - refreshFriends() - } - - suspend fun messages(pubkeyHex: String): List = - requireWire().messages(pubkeyHex) - - /** - * The core's outbox rows for one friend: the `"queued"` / `"sending"` / - * `"failed"` rows behind [ChatMessage.delivery], each with the attempt count - * and absolute next-attempt time the store holds. Empty means nothing is - * outstanding for them. Read this instead of guessing a retry schedule in - * the app. - */ - suspend fun outbox(pubkeyHex: String): List = - requireWire().outbox(pubkeyHex) - - /** - * The core's retry budget — the denominator in `try n/8`. A constant of the - * outbox, not per-node state, so it is fetched from the SDK rather than - * duplicated here; the app must not hardcode it. - */ - suspend fun outboxMaxAttempts(): UInt = uniffi.onionwire_sdk.outboxMaxAttempts() - - /** - * Starts the one 2s refresh loop for [pubkeyHex] and resets the chat state. - * - * Called from the chat screen entering the composition. Re-entering the - * same peer while its poller is alive is a no-op — navigating to the chat - * and back must never stack a second loop on top of the first. - */ - fun openChat(pubkeyHex: String) { - if (chatPeer == pubkeyHex && chatPoller?.isActive == true) return - chatPoller?.cancel() - chatPeer = pubkeyHex - _chat.value = ChatState() - chatPoller = viewModelScope.launch { pollChat(pubkeyHex) } - } - - /** - * Stops the loop when the chat screen leaves. Ignored when another peer has - * taken over in the meantime (navigating chat A → chat B disposes A after B - * has already opened). - */ - fun closeChat(pubkeyHex: String) { - if (chatPeer != pubkeyHex) return - stopChatPoller() - } - - private fun stopChatPoller() { - chatPoller?.cancel() - chatPoller = null - chatPeer = null - _chat.value = null - } - - /** - * Drops the last load error. The send path calls this: the user has acted, - * so a stale "could not read" line must not sit under the composer while - * the send is in flight. - */ - fun clearChatError() { - _chat.update { it?.copy(error = null) } - } - - /** - * The cadence, in the ViewModel: inbound messages are appended by the node - * in the background and the retry worker moves queued rows along, and in v1 - * there is no push channel into the UI, so messages and outbox are read - * together on one 2s tick. The outbox rows are read on that tick too — - * their `next_attempt_at` is a fixed instant, so a row saying "retry 45s" - * turns into "retry now" here without the store having to change. - * - * The retry budget is read once per open chat (it is a constant of the - * outbox, not per-peer state); a failure leaves it null and the rows fall - * back to the flat marker. - */ - private suspend fun pollChat(pk: String) { - runCatching { outboxMaxAttempts() }.onSuccess { budget -> - if (chatPeer == pk) _chat.update { it?.copy(maxAttempts = budget) } - } - while (currentCoroutineContext().isActive) { - val loaded = runCatching { messages(pk) } - val out = runCatching { outbox(pk) } - // A cancelled loop can still be sitting in a completed SDK read: - // writing that peer's rows into a state that now belongs to another - // peer would show the wrong conversation. - if (chatPeer != pk) return - _chat.update { state -> - val base = state ?: ChatState() - base.copy( - messages = loaded.getOrNull() ?: base.messages, - outbox = out.getOrNull() ?: base.outbox, - // Same order the screen's own loop reported them in, and - // sticky on success — a new failure replaces the last one, - // a successful tick does not clear the last one. - error = out.exceptionOrNull()?.let { it.message ?: it.toString() } - ?: loaded.exceptionOrNull()?.let { it.message ?: it.toString() } - ?: base.error, - ) - } - delay(2_000) - } - } - - /** - * Sends one chat message and reports what the core did with it. - * - * `SENT` — the peer's onion took the frame during this call. `QUEUED` — it - * was unreachable, so the message is in the local outbox and the retry - * worker will dial again with backoff until it lands or fails terminally. - * The state is returned rather than swallowed so the UI never shows a - * queued message as delivered. - */ - suspend fun send(pubkeyHex: String, body: String): SendState = - requireWire().send(pubkeyHex, body) - - suspend fun wipeMessages() { - requireWire().wipeMessages() - } - - suspend fun rotateOnion(): RotateOutcome { - val out = requireWire().rotateOnion() - _phase.value = (_phase.value as? Phase.Ready)?.copy(onion = requireWire().onion()) - ?: _phase.value - refreshFriends() - return out - } - - suspend fun decode(invite: String): InviteInfo = decodeInvite(invite) - - // --- This identity's own profile --------------------------------------- - // The phone's half of the TUI's `/profile`. `setSelfProfile` only writes - // locally; friends keep showing the old profile until `pushSelfProfile` - // reaches each of them, which is why the screen reports the two separately. - - /** The stored profile (nickname, bio, address). A store read; never dials. */ - suspend fun selfProfile(): Result = - runCatching { requireWire().selfProfile() } - - /** - * Replace the stored profile. Validated in the core before it is written: - * a rejected edit leaves the previous profile untouched. - */ - suspend fun setSelfProfile( - displayName: String, - bio: String, - xmrAddr: String, - ): Result = runCatching { requireWire().setSelfProfile(displayName, bio, xmrAddr) } - - /** - * Send the signed profile to one friend so their view of this identity is - * current. One-shot and fail-closed: an unreachable peer is a failure for - * that peer, and nothing is queued for them. - */ - suspend fun pushSelfProfile(pubkeyHex: String): Result = - runCatching { requireWire().pushSelfProfile(pubkeyHex) } - - // --- Wallet & payments ------------------------------------------------- - // These mirror the SDK surface added for the wallet screen. Payment sends - // are one-shot: if the peer's onion is unreachable, `send_*` fails now. - // They are NOT queued through the outbox like chat messages — that is a - // deliberate choice in the core, not a bug. - - suspend fun walletBalance(): String = requireWire().walletBalance() - - suspend fun walletReceiveAddress(): String? = runCatching { - requireWire().walletReceiveAddress() - }.getOrElse { null } - - suspend fun walletRecentTransfers(cap: Int = 25): List = runCatching { - requireWire().walletRecentTransfers(cap.toUInt()) - }.getOrElse { emptyList() } - - suspend fun sendInvoice(pubkeyHex: String, amountXmr: String, memo: String = ""): Result = - runCatching { requireWire().sendInvoice(pubkeyHex, amountXmr, memo) } - - suspend fun sendTip(pubkeyHex: String, amountXmr: String, memo: String = ""): Result = - runCatching { requireWire().sendTip(pubkeyHex, amountXmr, memo) } - - /** - * Create a wallet and read its seed once. The seed-backup flag is reset - * here, not by the screen: every successful create is a new seed nobody has - * read, and a caller that forgot to reset it would leave a spend key - * unrecoverable. See [SeedBackupGate.afterWallet]. - */ - suspend fun createWallet(password: String): Result = - runCatching { requireWire().createWallet(password) } - .onSuccess { setWalletSeedConfirmed(SeedBackupGate.afterWallet(WalletKeyOrigin.Created)) } - - /** - * Import a wallet from a user-supplied seed. That seed is already on paper — - * the user just pasted it — so the wallet counts as backed up without the - * confirm step. - */ - suspend fun importWallet(password: String, seed: String): Result = - runCatching { requireWire().importWallet(password, seed) } - .onSuccess { setWalletSeedConfirmed(SeedBackupGate.afterWallet(WalletKeyOrigin.Imported)) } - - /** - * Re-read the open wallet's 25-word seed, for the "Back up seed" recovery - * path. A spend key: only ever called from that explicit user action, shown - * on the blocking card, and dropped. Never logged and never persisted. - */ - suspend fun walletSeed(): Result = - runCatching { requireWire().walletSeed() } - - // --- Wallet catalogue, the open wallet, and its secrets ---------------- - // The saved-wallets screen's reads. The catalogue is a store read that - // never dials, so it goes to [Dispatchers.IO] like the other store reads in - // this file — a SQLCipher decrypt on the main thread is an ANR waiting for a - // slow device. - - /** - * Every wallet this install remembers, oldest first. - * - * A store read: it works with the wallet child stopped or never configured, - * and "no wallets" is an empty list rather than a failure — the caller must - * not render the two alike. - */ - suspend fun wallets(): Result> = - withContext(Dispatchers.IO) { runCatching { requireWire().wallets() } } - - /** - * The file name of the wallet the child currently has open, or null when it - * has none. The catalogue's in-use marker is this and nothing else. - */ - suspend fun activeWalletFilename(): Result = - withContext(Dispatchers.IO) { runCatching { requireWire().activeWalletFilename() } } - - /** - * Point the wallet child at a catalogue wallet's file. - * - * Slow on purpose: a live child is stopped and started again onto the new - * file. The core refuses a name the catalogue does not hold, and that - * refusal is surfaced verbatim to the caller. - */ - suspend fun openWallet(filename: String): Result = - withContext(Dispatchers.IO) { runCatching { requireWire().openWallet(filename) } } - - /** - * Open a saved wallet with a passphrase the user just typed, and remember it - * (sealed) once the wallet daemon has accepted it. - * - * This is what ends a `needs_passphrase` status — a wallet created before - * the passphrase was sealed, or created on another install. The core refuses - * an empty passphrase, a name the catalogue does not hold, and an install - * with no configured wallet RPC, all before it dials anything; a passphrase - * the daemon refuses is **not** stored, so the wallet stays `needs_passphrase` - * and the prompt stays up rather than looking fixed. - * - * The passphrase goes to a UniFFI `String` parameter, so one immutable copy - * exists for the life of the call — the same limit `openWith` documents for - * the store passphrase. It is never logged, never persisted here (the core - * seals it), and the caller drops its own reference. The live probe on - * success is a one-shot read, not a second poller: the wallet screen still - * owns the only loop. - */ - suspend fun openWalletWithPassphrase(filename: String, passphrase: String): Result = - withContext(Dispatchers.IO) { - runCatching { requireWire().openWalletWithPassphrase(filename, passphrase) } - }.onSuccess { - // One live probe, so `needs_passphrase` flips and the prompt comes - // off the screen without waiting for the next tick of a loop that is - // only running while the wallet screen is up. - refreshWalletChild() - } - - /** - * The **open** wallet's private keys, for the saved-wallets screen. - * - * Both values are spend secrets: only ever called from an explicit tap, - * never logged, never persisted, and dropped when the screen goes. There is - * deliberately no accessor for another catalogue row's keys — the only way - * to read a saved wallet's keys is to open it first. - */ - suspend fun walletKeys(): Result = - withContext(Dispatchers.IO) { runCatching { requireWire().walletKeys() } } - - fun spendAuthorityWarning(): String = runCatching { - requireWire().spendAuthorityWarning() - }.getOrElse { - "this wallet file can spend. anyone with its passphrase or the RPC creds can move the balance. write down the seed." - } - - // --- Seed backup gate -------------------------------------------------- - // Whether the open wallet's seed has been confirmed written down. This is - // NOT a secret — it is a boolean in app-local prefs, deliberately kept out - // of the Keystore-wrapped store under `filesDir/secrets`, which holds the - // passphrase and nothing else. - // - // The flow is nullable, and the null is load-bearing: nothing stored means - // "this install has never created or imported a wallet through this build", - // which is not the same as "the user created one and has not confirmed it". - // See [SeedBackupGate.warningVisible] for why the screen needs both. - - private val seedBackupPrefs: SharedPreferences = - app.getSharedPreferences(SEED_BACKUP_PREFS, Context.MODE_PRIVATE) - - private val _walletSeedConfirmed = MutableStateFlow( - if (seedBackupPrefs.contains(SEED_BACKED_UP_KEY)) { - seedBackupPrefs.getBoolean(SEED_BACKED_UP_KEY, false) - } else { - null - }, - ) - - /** - * The stored seed-backup flag: `false` unconfirmed, `true` confirmed or - * imported, `null` nothing stored (an install that predates the flag). - */ - val walletSeedConfirmed: StateFlow = _walletSeedConfirmed.asStateFlow() - - /** - * One confirm step from the blocking seed card. The gate decides: a wrong - * word leaves the flag where it was, so this can never un-confirm a wallet. - */ - fun confirmWalletSeed(typed: String) { - setWalletSeedConfirmed(SeedBackupGate.afterConfirm(typed, _walletSeedConfirmed.value == true)) - } - - private fun setWalletSeedConfirmed(confirmed: Boolean) { - seedBackupPrefs.edit().putBoolean(SEED_BACKED_UP_KEY, confirmed).apply() - _walletSeedConfirmed.value = confirmed - } - - // --- App-owned wallet child (issue #107) ------------------------------- - // The app owns `monero-wallet-rpc` instead of asking the user to start one - // and export `ONIONWIRE_WALLET_RPC`. The core's own states are surfaced - // verbatim: off / connecting / syncing / ready / exited. Nothing here - // invents a "starting…" state, and a child that died is never folded into - // "off" — see `ui/WalletChildStatusText.kt`. - - /** The last `wallet_status()` snapshot, or null before the first read. */ - private val _walletChild = MutableStateFlow(null) - val walletChild: StateFlow = _walletChild.asStateFlow() - - /** - * The last failed start/stop/read, display-ready. Sticky on purpose, like - * [ChatState.error]: a transient store read that fails once must not blink - * off the screen on the next successful tick. - */ - private val _walletChildError = MutableStateFlow(null) - val walletChildError: StateFlow = _walletChildError.asStateFlow() - - /** - * Start is in flight. Core status stays `off` until Cuprate/`monerod` answers, - * so the screen must not wait on that snapshot to show that the tap landed. - */ - private val startInFlight = AtomicBoolean(false) - private val _walletChildStarting = MutableStateFlow(false) - val walletChildStarting: StateFlow = _walletChildStarting.asStateFlow() - - /** The stored chain source + binary settings, for prefilling the editor. */ - private val _chainSource = MutableStateFlow(null) - val chainSource: StateFlow = _chainSource.asStateFlow() - - private var walletChildPoller: Job? = null - - /** - * What this install can actually spawn. Read from - * `applicationInfo.nativeLibraryDir` — the only directory Android hands out - * executable — so the screen can say "not bundled" instead of offering a - * Start that can only fail. - */ - fun bundledBinaries(): WalletChildBinaryPaths = - WalletChildBinaries.resolve( - getApplication().applicationInfo.nativeLibraryDir, - ) - - /** - * Starts the one wallet-child refresh loop for the wallet screen. Re-entering - * the screen while the loop is alive is a no-op: navigating to the wallet - * and back must never stack a second poller. - */ - fun openWalletChild() { - if (walletChildPoller?.isActive == true) return - walletChildPoller = viewModelScope.launch { - walletChildRefreshLoop( - tickMs = WALLET_CHILD_TICK_MS, - // The first paint is the cached read: it never dials, so the - // screen has a record to render while the first probe is still - // in flight. - cached = ::paintWalletChildCached, - // Every tick after that is a live probe, so `height` / - // `target_height` move on their own instead of only when a - // chain-mode button is tapped. - live = ::refreshWalletChild, - ) - } - } - - /** Stops the loop when the wallet screen leaves. */ - fun closeWalletChild() { - walletChildPoller?.cancel() - walletChildPoller = null - } - - /** Drops the last failure. The user has acted on it. */ - fun clearWalletChildError() { - _walletChildError.value = null - } - - /** - * The first paint: one `wallet_status()` read. - * - * `Wire::wallet_status` is synchronous in Rust and re-reads the sealed - * wallet-child record out of the SQLCipher store, so it goes to - * [Dispatchers.IO] — a store decrypt on the main thread is an ANR waiting - * for a slow device. It never dials and never spawns, so it is the right - * read to have a record on screen — and the wrong one to poll with. - */ - suspend fun paintWalletChildCached() = readWalletChild { requireWire().walletStatus() } - - /** - * One tick: a live probe, `Wire::wallet_child_refresh()`. - * - * `Wire::wallet_status` above only re-reads what the last probe left behind, - * so polling it pins the `sync h/t` segment on whatever the last - * start/stop saw. This one dials — the child's loopback wallet RPC, and the - * configured local daemon's `get_info` when the wallet RPC does not answer - * — which is what makes the chain's height and target move between ticks. - * - * It never spawns a child, and the core short-circuits with the cached - * snapshot when there is no live child, so it cannot invent `ready` for a - * wallet that is not there. Not free, though: the tick stays on the order of - * seconds rather than frames. - * - * Failure is folded into the sticky [walletChildError], same as the cached - * read: a probe that fails once must not blink the previous error off the - * screen. - */ - suspend fun refreshWalletChild() = readWalletChild { requireWire().walletChildRefresh() } - - /** - * Runs one of the two reads on [Dispatchers.IO] and lands it in the wallet - * state. `requireWire()` throws when the node is locked, so it is called - * *inside* the [runCatching] — a locked node has to surface as - * [walletChildError], not as a crash on the tick. - */ - private suspend fun readWalletChild(read: suspend () -> WalletChildStatus) { - val result = withContext(Dispatchers.IO) { runCatching { read() } } - result.fold( - onSuccess = { _walletChild.value = it }, - onFailure = { _walletChildError.value = walletFailureText(it.message ?: it.toString()) }, - ) - } - - /** Re-reads the stored chain source so the editor can prefill from it. */ - suspend fun refreshChainSource() { - val read = withContext(Dispatchers.IO) { runCatching { requireWire().chainSource() } } - read.onSuccess { _chainSource.value = it } - } - - /** - * Saves a daemon the user typed, then leaves it to [startWalletChild] to - * spawn against it. `set_chain_source` only stores: the core validates the - * config before anything is written and a rejected config leaves the stored - * one — and any running child — untouched. - * - * [bins] is what this install resolved; the paths handed to the core are - * absolute, because nothing in an APK sandbox resolves a bare - * `monero-wallet-rpc` on `PATH`. - */ - suspend fun saveRemoteDaemon( - host: String, - port: Int, - bins: WalletChildBinaryPaths, - ): Result { - val rpc = bins.walletRpc - ?: return Result.failure(IllegalStateException(NO_WALLET_RPC_MESSAGE)) - return withContext(Dispatchers.IO) { - runCatching { - requireWire().setChainSource( - ChainConfig( - kind = ChainChoice.REMOTE, - monerodBin = "", - monerodDatadir = "", - host = host, - port = port.toUShort(), - walletRpcBin = rpc, - // Inert unless the host is a `.onion`; the screen refuses - // an onion daemon outright while no `arti` is bundled. - artiBin = expectedArtiPath(), - walletFilename = WalletChildBinaries.WALLET_FILENAME, - mainnet = false, - prune = false, - ), - ) - } - }.onSuccess { - _walletChildError.value = null - refreshChainSource() - refreshWalletChild() - } - } - - /** - * Back to receive-only: no child, no daemon, no chain traffic. The binary - * paths are still stored so switching back to a daemon does not need them - * re-derived. - */ - suspend fun setReceiveOnly(bins: WalletChildBinaryPaths): Result = - withContext(Dispatchers.IO) { - runCatching { - requireWire().setChainSource( - ChainConfig( - kind = ChainChoice.NONE, - monerodBin = "", - monerodDatadir = "", - host = "", - port = 0u, - walletRpcBin = bins.walletRpc.orEmpty(), - artiBin = expectedArtiPath(), - walletFilename = WalletChildBinaries.WALLET_FILENAME, - mainnet = false, - prune = false, - ), - ) - } - }.onSuccess { - _walletChildError.value = null - refreshChainSource() - refreshWalletChild() - } - - /** - * The third chain source: the chain daemon **inside this app** (Cuprate), no - * `monerod` binary and no remote operator. Stores the setting; [startWalletChild] - * is what launches the node *and* the wallet child (one call in the core). - * - * `monerodDatadir` is left empty on purpose: the SDK resolves that to - * `$ONIONWIRE_HOME/chain/{testnet,mainnet-pruned,mainnet-full}` from - * [mainnet] and [prune], so Kotlin never invents an absolute path. - */ - suspend fun setInProcessCuprate( - bins: WalletChildBinaryPaths, - mainnet: Boolean, - prune: Boolean, - ): Result = - withContext(Dispatchers.IO) { - runCatching { - requireWire().setChainSource( - ChainConfig( - kind = ChainChoice.IN_PROCESS_CUPRATE, - monerodBin = "", - monerodDatadir = "", - host = "", - port = 0u, - walletRpcBin = bins.walletRpc.orEmpty(), - // Inert for this source: an in-process node is loopback - // clearnet, so the core never spawns the SOCKS child. - artiBin = expectedArtiPath(), - walletFilename = WalletChildBinaries.WALLET_FILENAME, - mainnet = mainnet, - prune = prune, - ), - ) - } - }.onSuccess { - _walletChildError.value = null - refreshChainSource() - refreshWalletChild() - } - - /** - * Free bytes on the filesystem the in-process chain store grows into, or - * `null` when it cannot be read. The screen shows this before the user commits - * to a store on the device; it is a measurement, not an estimate. - */ - fun chainFreeBytes(): Long? = ChainStorage.freeBytes(home) - - /** - * Repairs a stored `walletRpcBin` this device cannot execute, and reports - * whether it wrote anything back. - * - * A wallet-child record written by an older install can carry the bare name - * `monero-wallet-rpc` (or an empty string). Nothing in an APK sandbox - * resolves a bare name on `PATH`, so `start_wallet_child` spawns it and dies - * with `No such file or directory` — while the Start gate, which only ever - * looked at the *resolved* bundle, stayed green. This re-points the stored - * record at the absolute `nativeLibraryDir` path this install actually - * carries, before anything is spawned. - * - * What it deliberately does not do: - * - it never changes `kind`, host, port, mode, datadir or wallet filename — - * a repair of the binary is not a change of chain source; - * - it does nothing for receive-only (`ChainChoice.NONE`), which stores a - * bin it never spawns; - * - it never overwrites a stored path that exists and is executable, even - * when that path is not the bundled binary — a user who pointed at a real - * file keeps it; - * - it never fails loudly: a repair that cannot be made leaves the stored - * record alone, and the gate then names the path it will try to spawn. - */ - suspend fun healStoredWalletBin(bins: WalletChildBinaryPaths): Result = - withContext(Dispatchers.IO) { - runCatching { - val wire = requireWire() - val stored = runCatching { wire.chainSource() }.getOrNull() - ?: return@runCatching false - if (stored.kind == ChainChoice.NONE) return@runCatching false - val healed = walletBinHealPath(stored.walletRpcBin, bins.walletRpc) - ?: return@runCatching false - wire.setChainSource( - ChainConfig( - kind = stored.kind, - monerodBin = stored.monerodBin, - monerodDatadir = stored.monerodDatadir, - host = stored.host, - port = stored.port, - walletRpcBin = healed, - artiBin = stored.artiBin, - walletFilename = stored.walletFilename, - mainnet = stored.mainnet, - prune = stored.prune, - ), - ) - true - } - }.onSuccess { healed -> - if (healed) { - refreshChainSource() - refreshWalletChild() - } - } - - /** - * Kick off start on [viewModelScope] so leaving the composition does not - * cancel Cuprate launch. Returns immediately; watch [walletChildStarting] - * and [walletChildError]. Core status stays `off` until the node answers. - * - * Self-heals the stored binary first, then re-reads that stored record and - * refuses to spawn when it still names a path this device cannot run. The - * screen's gate is the primary door, but an auto-start from a mode tap is - * not the only caller: this is the last place that can stop a doomed spawn, - * and the reason it writes is the named path rather than the core's opaque - * `spawn monero-wallet-rpc: …`. - */ - fun startWalletChild() { - if (!startInFlight.compareAndSet(false, true)) return - _walletChildStarting.value = true - _walletChildError.value = null - viewModelScope.launch { - try { - val bins = bundledBinaries() - healStoredWalletBin(bins) - val stored = withContext(Dispatchers.IO) { - runCatching { requireWire().chainSource() }.getOrNull() - } - if (stored == null || stored.kind == ChainChoice.NONE) { - _walletChildError.value = NO_CHAIN_SOURCE_NOTICE - return@launch - } - val blocked = storedWalletBinBlockedReason(stored.walletRpcBin, bins.walletRpc) - if (blocked != null) { - _walletChildError.value = blocked - return@launch - } - val started = withContext(Dispatchers.IO) { - runCatching { requireWire().startWalletChild() } - } - started.fold( - onSuccess = { _walletChild.value = it }, - onFailure = { - _walletChildError.value = walletFailureText(it.message ?: it.toString()) - }, - ) - } finally { - startInFlight.set(false) - _walletChildStarting.value = false - } - } - } - - /** Stops the child and its siblings. Idempotent in the core. */ - suspend fun stopWalletChild(): Result { - _walletChildError.value = null - val stopped = withContext(Dispatchers.IO) { - runCatching { requireWire().stopWalletChild() } - } - stopped.fold( - onSuccess = { refreshWalletChild() }, - onFailure = { _walletChildError.value = walletFailureText(it.message ?: it.toString()) }, - ) - return stopped - } - - /** The absolute path the core would be handed for the `arti` SOCKS child. */ - private fun expectedArtiPath(): String = WalletChildBinaries.expectedPath( - getApplication().applicationInfo.nativeLibraryDir, - WalletChildBinaries.ARTI_LIB, - ) -} - -/** - * The wallet-child refresh loop: one [cached] paint so the screen has something - * to render, then a live [live] probe every [tickMs]. - * - * The reads are parameters only so the JVM test tree can drive this loop - * without a `Wire` — `NodeHost.requireOpen()` is a process-global the unit test - * cannot prime. The two call sites in [WireViewModel.openWalletChild] bind them - * to the cached read and to the live probe. - * - * Serialized by construction, and that is the point: the loop suspends on each - * read before it sleeps, so a probe slower than [tickMs] delays the next tick - * instead of overlapping it. Do not turn this into a `Flow` with - * `collectLatest`, and do not `launch` the probe: two concurrent - * `wallet_child_refresh` calls against one wallet child is a racing probe. - */ -suspend fun walletChildRefreshLoop( - tickMs: Long, - cached: suspend () -> Unit, - live: suspend () -> Unit, -) { - cached() - while (currentCoroutineContext().isActive) { - delay(tickMs) - live() - } -} - -/** Cadence of the wallet-child refresh loop, in milliseconds. */ -private const val WALLET_CHILD_TICK_MS: Long = 2_000 - -/** - * App-local prefs file for the seed-backup flag. Not a secret, so it is a plain - * prefs file rather than anything under `filesDir/secrets`. - */ -private const val SEED_BACKUP_PREFS: String = "wallet_seed_backup" - -/** Key inside [SEED_BACKUP_PREFS]: has the open wallet's seed been written down? */ -private const val SEED_BACKED_UP_KEY: String = "backed_up" - diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipher.kt b/android/app/src/main/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipher.kt deleted file mode 100644 index c40fce4..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipher.kt +++ /dev/null @@ -1,463 +0,0 @@ -package com.siriusdevops.onionwire.crypto - -import android.app.KeyguardManager -import android.content.Context -import android.content.pm.PackageManager -import android.os.Build -import android.security.keystore.KeyGenParameterSpec -import android.security.keystore.KeyInfo -import android.security.keystore.KeyProperties -import android.security.keystore.UserNotAuthenticatedException -import android.util.Log -import java.security.GeneralSecurityException -import java.security.KeyStore -import java.security.ProviderException -import javax.crypto.KeyGenerator -import javax.crypto.SecretKey -import javax.crypto.SecretKeyFactory - -/** - * AES-256-GCM key held by the Android Keystore, wrapping the store passphrase. - * - * The key material is never readable by this process (`SecretKey.encoded` is - * null for AndroidKeyStore keys) — that is the whole point: pulling - * `/data/data/com.siriusdevops.onionwire/` off a rooted device yields the - * ciphertext, not the passphrase. - * - * StrongBox is requested first and falls back to the ordinary TEE-backed (or - * software) Keystore without a crash. The fallback is not silent: call - * [backing] and report what the Keystore actually produced. - * - * `setUserAuthenticationRequired` is deliberately **false**. Requiring a - * fingerprint to unlock the node would turn "fail closed" into "unusable - * unattended", and the SDK's contract is that an unlock either opens the node - * or reports why it did not. - * - * ## Device-unlock gate (what this class adds on top of the flag above) - * - * The key is additionally bound to the device's lock state with - * `setUnlockedDeviceRequired(true)` (API 28+): while the lock screen is up, the - * key refuses to decrypt, so a blob lifted off a powered-on-but-locked device - * is not decryptable by the app's own process either. That is still not a - * fingerprint prompt — an unattended unlock on an unlocked device keeps - * working — it only refuses *while the device is locked*. - * - * Two aliases are in play because a Keystore key cannot be retrofitted and - * cannot be re-aliased: - * - * - [ALIAS] (`onionwire.store`) — the pre-gate key. Never generated by this - * class on API 28+; it exists only on installs that stored a passphrase - * before the gate landed. - * - [ALIAS_UNLOCK_GATED] (`onionwire.store.unlock-gated`) — generated with the - * device-unlock requirement. This is the only key a fresh install ever - * creates. - * - * At most one of the two is live after a migration; both exist only in the - * window between "the re-wrapped blob verified" and "the pre-gate key was - * deleted". [StoredPassphraseStore] drives that window, in that order, and is - * the only thing allowed to delete the pre-gate key. - * - * ## What can be *reported* about the gate, honestly - * - * `KeyInfo` on this API range exposes `isUserAuthenticationRequired` but has - * **no getter for the unlock requirement**, so no code here can ask the - * Keystore whether the flag stuck. [unlockGateReport] therefore reports our own - * bookkeeping — "the live key was generated under the unlock-gated alias" — and - * [UnlockGateReport.platformReportsGate] is a constant `false` saying so. On a - * device whose Keystore refuses the flag, the report shows - * `supported && !keyIsUnlockGated` plus the refusal reason; nothing pretends - * otherwise. - */ -class KeystorePassphraseCipher(private val context: Context) : - PassphraseCipher, - PassphraseKeyMigration { - - private var cached: ActiveKey? = null - - /** Why this process's attempt at an unlock-gated key failed, if it did. */ - private var gateRefusal: String? = null - - /** Why the last re-wrap of the stored blob did not finish. Report-only. */ - private var migrationFailure: String? = null - - override fun seal(plaintext: CharArray): ByteArray { - val key = keyForSeal() - return try { - StoreSecret.seal(key.secret, plaintext) - } catch (e: SecretUnavailable) { - throw gateMessage(e, gatedKeyInPlay = key.gated) - } - } - - /** - * Never creates a key. A freshly generated key cannot decrypt an old blob, - * and generating one here would turn "the key is gone" into a confusing - * GCM tag failure. The caller needs the real reason to tell the user. - * - * A blob written before the gate landed is wrapped by [ALIAS], so an - * unlock-gated key is tried first and the pre-gate key is the fallback — - * that ordering is what makes the crash window of the migration harmless. - */ - override fun open(blob: ByteArray): CharArray { - val active = activeKey() - ?: throw SecretUnavailable("the device's Keystore key for OnionWire is gone") - try { - return StoreSecret.open(active.secret, blob) - } catch (first: SecretUnavailable) { - if (active.gated) { - val legacy = existingKey(ALIAS) - if (legacy != null) { - try { - return StoreSecret.open(legacy, blob) - } catch (_: SecretUnavailable) { - // Fall through to the honest report below. - } - } - } - throw gateMessage(first, gatedKeyInPlay = active.gated) - } - } - - override fun keyPresent(): Boolean = activeKey() != null - - override fun backing(): KeyBacking { - val key = activeKey() ?: return KeyBacking.UNKNOWN - val info = try { - SecretKeyFactory.getInstance(key.secret.algorithm, PROVIDER) - .getKeySpec(key.secret, KeyInfo::class.java) as KeyInfo - } catch (_: Exception) { - // Some OEM Keystore implementations refuse getKeySpec. Report - // UNKNOWN rather than guessing hardware backing. - return KeyBacking.UNKNOWN - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && - info.securityLevel == KeyProperties.SECURITY_LEVEL_STRONGBOX - ) { - return KeyBacking.STRONGBOX - } - // Deprecated in API 31 in favour of securityLevel, but it is the only - // TEE/software answer available on 26–30, and minSdk is 26. - @Suppress("DEPRECATION") - val inSecureHardware = info.isInsideSecureHardware - return if (inSecureHardware) KeyBacking.HARDWARE else KeyBacking.SOFTWARE - } - - /** Deletes both aliases: `forget()` must leave nothing that can decrypt. */ - override fun deleteKey() { - cached = null - val store = try { - keyStore() - } catch (_: Exception) { - return - } - for (alias in listOf(ALIAS_UNLOCK_GATED, ALIAS)) { - try { - store.deleteEntry(alias) - } catch (_: Exception) { - // Nothing usable to delete under that alias. - } - } - } - - // ---------------------------------------------------------------- report - - /** - * What can honestly be said about the device-unlock gate on the live key. - * See the class doc: there is no platform getter for the flag itself. - */ - fun unlockGateReport(): UnlockGateReport { - val active = activeKey() - return UnlockGateReport( - supported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P, - sdkInt = Build.VERSION.SDK_INT, - keyIsUnlockGated = active?.gated == true, - legacyKeyPending = existingKey(ALIAS) != null, - backing = if (active == null) KeyBacking.UNKNOWN else backing(), - gateRefusal = gateRefusal, - migrationFailure = migrationFailure, - ) - } - - private fun logBranch(branch: String) { - Log.i( - TAG, - "wrap key: branch=$branch sdk=${Build.VERSION.SDK_INT} " + - "manufacturer=${Build.MANUFACTURER} model=${Build.MODEL}", - ) - } - - // --------------------------------------------------- PassphraseKeyMigration - - /** - * True when the key [seal] just wrapped with is the unlock-gated one. False - * on API 26–27 and on a device whose Keystore refused the flag — in both - * cases there is nothing to migrate to, and the caller must not delete the - * pre-gate key. - */ - override fun unlockGateInEffect(): Boolean = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && existingKey(ALIAS_UNLOCK_GATED) != null - - override fun legacyKeyPending(): Boolean = existingKey(ALIAS) != null - - /** Decrypts [blob] with the unlock-gated key alone — never the fallback. */ - override fun openWithUnlockGate(blob: ByteArray): CharArray { - val key = existingKey(ALIAS_UNLOCK_GATED) - ?: throw SecretUnavailable("no unlock-gated key exists to prove the blob against") - return try { - StoreSecret.open(key, blob) - } catch (e: SecretUnavailable) { - throw gateMessage(e, gatedKeyInPlay = true) - } - } - - /** - * Deletes [ALIAS]. [StoredPassphraseStore] calls this only after the - * replacement blob is on disk and has been opened back under the new key; - * a blob wrapped by this alias becomes undecryptable the moment it runs. - */ - override fun retireLegacyKey() { - if (!legacyKeyPending()) return - try { - keyStore().deleteEntry(ALIAS) - } catch (e: Exception) { - noteMigrationFailure("could not delete the pre-gate key under $ALIAS (${e.message})") - return - } - if (cached?.gated == false) cached = null - Log.i(TAG, "retired the pre-gate Keystore key under $ALIAS; only $ALIAS_UNLOCK_GATED remains") - } - - override fun noteMigrationFailure(reason: String) { - migrationFailure = reason - Log.w(TAG, "unlock-gated key migration did not complete: $reason (blob and pre-gate key kept)") - } - - // ------------------------------------------------------------------ keys - - private class ActiveKey(val secret: SecretKey, val gated: Boolean) - - /** Existing key we would decrypt with, unlock-gated first. Never creates. */ - private fun activeKey(): ActiveKey? { - cached?.let { return it } - existingKey(ALIAS_UNLOCK_GATED)?.let { return ActiveKey(it, gated = true).also { k -> cached = k } } - existingKey(ALIAS)?.let { return ActiveKey(it, gated = false).also { k -> cached = k } } - return null - } - - /** - * The key [seal] uses. Prefers the unlock-gated alias (creating it if the - * platform allows), which is what turns a pre-gate install into a gated one - * the next time a passphrase is stored. - */ - private fun keyForSeal(): ActiveKey { - val active = activeKey() - if (active?.gated == true) return active - return gatedKeyOrCreate() ?: active ?: legacyKeyOrCreate() - } - - private fun gatedKeyOrCreate(): ActiveKey? { - cached?.let { if (it.gated) return it } - existingKey(ALIAS_UNLOCK_GATED)?.let { return ActiveKey(it, gated = true).also { k -> cached = k } } - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) return null - // One attempt per process: a Keystore that refused the flag will refuse - // it again, and unlock must not retry key generation on every call. - if (gateRefusal != null) return null - return try { - val key = generateWithFallback(ALIAS_UNLOCK_GATED, unlockGated = true) - logBranch("unlock-gated alias=$ALIAS_UNLOCK_GATED") - ActiveKey(key, gated = true).also { cached = it } - } catch (e: GeneralSecurityException) { - recordGateRefusal(e) - null - } catch (e: ProviderException) { - recordGateRefusal(e) - null - } - } - - private fun legacyKeyOrCreate(): ActiveKey { - cached?.let { if (!it.gated) return it } - existingKey(ALIAS)?.let { return ActiveKey(it, gated = false).also { k -> cached = k } } - val key = generateWithFallback(ALIAS, unlockGated = false) - logBranch( - "ungated alias=$ALIAS" + - (gateRefusal?.let { " (unlock gate refused: $it)" } ?: ""), - ) - return ActiveKey(key, gated = false).also { cached = it } - } - - private fun recordGateRefusal(e: Exception) { - gateRefusal = "${e.javaClass.simpleName}: ${e.message}" - Log.w( - TAG, - "Keystore refused setUnlockedDeviceRequired(true) under $ALIAS_UNLOCK_GATED; " + - "falling back to the pre-gate alias $ALIAS (=$gateRefusal) " + - "sdk=${Build.VERSION.SDK_INT} manufacturer=${Build.MANUFACTURER} model=${Build.MODEL}", - ) - } - - private fun existingKey(alias: String): SecretKey? = try { - keyStore().getKey(alias, null) as? SecretKey - } catch (_: Exception) { - null - } - - private fun strongBoxAdvertised(): Boolean = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && - context.packageManager.hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE) - - private fun generateWithFallback(alias: String, unlockGated: Boolean): SecretKey { - if (strongBoxAdvertised()) { - try { - return generate(alias, strongBox = true, unlockGated = unlockGated) - } catch (e: ProviderException) { - // StrongBoxUnavailableException is a ProviderException: the chip - // exists but its slots are full, or it refuses AES-256. Fall - // through to a normal Keystore key instead of failing unlock. - Log.i(TAG, "StrongBox refused a key under $alias (${e.javaClass.simpleName}: ${e.message})") - } catch (e: GeneralSecurityException) { - Log.i(TAG, "StrongBox refused a key under $alias (${e.javaClass.simpleName}: ${e.message})") - } - } - return generate(alias, strongBox = false, unlockGated = unlockGated) - } - - private fun generate(alias: String, strongBox: Boolean, unlockGated: Boolean): SecretKey { - val builder = KeyGenParameterSpec.Builder( - alias, - KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT, - ) - .setBlockModes(KeyProperties.BLOCK_MODE_GCM) - .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE) - .setKeySize(StoreSecret.KEY_BITS) - // Our IV comes from Cipher.init, and the Keystore supplies it. - .setRandomizedEncryptionRequired(true) - // Locked decision: no fingerprint gate on an unattended node. - .setUserAuthenticationRequired(false) - if (unlockGated && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - // Refuses while the lock screen is up. No user-auth prompt is - // involved, so this does not turn "fail closed" into "unusable - // unattended" — it narrows *when* the key works, not who is awake. - builder.setUnlockedDeviceRequired(true) - } - if (strongBox && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - builder.setIsStrongBoxBacked(true) - } - val generator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, PROVIDER) - generator.init(builder.build()) - return generator.generateKey() - } - - private fun keyStore(): KeyStore = KeyStore.getInstance(PROVIDER).apply { load(null) } - - /** - * A gated key refuses to work while the lock screen is up, and the Keystore - * surfaces that as a plain crypto failure. "the stored secret did not - * authenticate" would read as a corrupt blob, so say what happened. - */ - private fun gateMessage(e: SecretUnavailable, gatedKeyInPlay: Boolean): SecretUnavailable { - if (!gatedKeyInPlay) return e - val lockRefusal = e.cause is UserNotAuthenticatedException || deviceLocked() - if (!lockRefusal) return e - return SecretUnavailable( - "the device is locked — the passphrase key is only usable while the device is unlocked", - e, - ) - } - - private fun deviceLocked(): Boolean = - context.getSystemService(KeyguardManager::class.java)?.isDeviceLocked == true - - companion object { - const val PROVIDER = "AndroidKeyStore" - - /** Logcat tag; also what `adb logcat -s OnionWireKeystore` filters on. */ - const val TAG = "OnionWireKeystore" - - /** - * The pre-gate key's alias. Kept as the app's original name: a Keystore - * alias cannot be renamed, so an upgraded install keeps this one until - * [retireLegacyKey] deletes it. - */ - const val ALIAS = "onionwire.store" - - /** The key that carries `setUnlockedDeviceRequired(true)`. */ - const val ALIAS_UNLOCK_GATED = "onionwire.store.unlock-gated" - } -} - -/** - * Re-wrapping a stored blob under a key that carries the device-unlock - * requirement. - * - * Deliberately **not** part of [PassphraseCipher]: an implementation without a - * Keystore (the JVM fakes in `StoredPassphraseStoreTest`) has nothing to - * migrate, and adding methods to the cipher interface would force every fake to - * grow a no-op. [StoredPassphraseStore] asks for this capability with a safe - * cast and skips migration entirely when it is absent. - */ -interface PassphraseKeyMigration { - - /** - * True when the key the cipher just sealed with is the unlock-gated one. - * When false — API 26/27, or a Keystore that refused the flag — there is - * nothing to migrate to and the pre-gate key must be left alone. - */ - fun unlockGateInEffect(): Boolean - - /** A pre-gate key still exists under [KeystorePassphraseCipher.ALIAS]. */ - fun legacyKeyPending(): Boolean - - /** - * Decrypts [blob] with the unlock-gated key **only**. Used to prove a - * freshly written blob before the pre-gate key is deleted, so a fallback - * decrypt cannot masquerade as proof. - * - * @throws SecretUnavailable when the blob is not wrapped by that key. - */ - fun openWithUnlockGate(blob: ByteArray): CharArray - - /** - * Deletes the pre-gate key. Only valid once the replacement blob is durable - * and [openWithUnlockGate] has proven it. - */ - fun retireLegacyKey() - - /** Records why a re-wrap attempt stopped, for logs and [unlockGateReport]. */ - fun noteMigrationFailure(reason: String) -} - -/** - * What we can honestly say about the device-unlock gate on the live key. - * - * [platformReportsGate] is always `false`: `KeyInfo` has no getter for - * `setUnlockedDeviceRequired`, so the gate state is our own bookkeeping about - * which alias the key was generated under, not a Keystore attestation. - */ -data class UnlockGateReport( - /** API 28+ can carry the flag at all. */ - val supported: Boolean, - val sdkInt: Int, - /** The live key was generated under the unlock-gated alias. */ - val keyIsUnlockGated: Boolean, - /** The pre-gate key still exists — a migration has not completed yet. */ - val legacyKeyPending: Boolean, - val backing: KeyBacking, - /** Set when this process's attempt at a gated key was refused. */ - val gateRefusal: String?, - /** Set when a re-wrap of the stored blob did not finish. */ - val migrationFailure: String?, - /** No platform getter exists for the unlock requirement. Always false. */ - val platformReportsGate: Boolean = false, -) { - /** One honest sentence for logcat / a status line. Never claims hardware proof. */ - fun describe(): String = when { - keyIsUnlockGated -> "key: ${backing.name.lowercase()}, unusable while the device is locked" - !supported -> "key: ${backing.name.lowercase()}, unlock gate unsupported on SDK $sdkInt" - gateRefusal != null -> - "key: ${backing.name.lowercase()}, NOT unlock-gated — the Keystore refused the flag" - legacyKeyPending -> - "key: ${backing.name.lowercase()}, NOT unlock-gated — pre-gate key, migrates on the next unlock" - else -> "key: ${backing.name.lowercase()}, NOT unlock-gated" - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/PassphraseCipher.kt b/android/app/src/main/java/com/siriusdevops/onionwire/crypto/PassphraseCipher.kt deleted file mode 100644 index 50cd2b9..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/PassphraseCipher.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.siriusdevops.onionwire.crypto - -/** - * Wraps the store passphrase with a key that never leaves the Keystore. - * - * Implementations must not persist the plaintext anywhere, and must not log it. - */ -interface PassphraseCipher { - - /** Encrypts [plaintext]. The returned blob is the only thing that may hit disk. */ - fun seal(plaintext: CharArray): ByteArray - - /** - * Decrypts a blob produced by [seal]. - * - * @throws SecretUnavailable when the key is gone, invalidated, or the blob - * does not authenticate. Callers fall back to asking the user to type. - */ - fun open(blob: ByteArray): CharArray - - /** True when a usable key is already in the Keystore. */ - fun keyPresent(): Boolean - - /** - * Where the key actually lives, as reported by the Keystore itself. - * - * This is an observation, not a claim: on a device without a StrongBox or - * TEE the honest answer is [KeyBacking.SOFTWARE], and the UI says so. - */ - fun backing(): KeyBacking - - /** Removes the key. The ciphertext becomes permanently undecryptable. */ - fun deleteKey() -} - -/** Result of asking the Keystore where the key lives. */ -enum class KeyBacking { - /** Dedicated security chip (API 28+, Pixel 3-class and up). */ - STRONGBOX, - - /** Key is inside a TEE. Good. */ - HARDWARE, - - /** Keystore software implementation. Passphrase is still not plaintext on disk. */ - SOFTWARE, - - /** No key created yet, or the API could not be queried. Never claim hardware here. */ - UNKNOWN, -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/StoreSecret.kt b/android/app/src/main/java/com/siriusdevops/onionwire/crypto/StoreSecret.kt deleted file mode 100644 index 89b9e7b..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/StoreSecret.kt +++ /dev/null @@ -1,130 +0,0 @@ -package com.siriusdevops.onionwire.crypto - -import java.nio.CharBuffer -import java.nio.charset.StandardCharsets -import java.security.GeneralSecurityException -import java.util.Arrays -import javax.crypto.Cipher -import javax.crypto.SecretKey -import javax.crypto.spec.GCMParameterSpec - -/** - * AES-256-GCM envelope for the store passphrase. - * - * This file is deliberately free of `android.*` imports so the exact - * seal/open code that runs on a device can also run in a plain JVM unit test - * with a JVM-generated AES key. The Android Keystore only supplies the key — - * the framing and the AEAD call are these functions. - * - * Wire format (little of it is secret, all of it is authenticated): - * - * magic "OWSEAL1\n" 8 bytes - * iv length 1 byte (always [IV_BYTES]) - * iv [IV_BYTES] bytes, from the cipher - * ciphertext n + [TAG_BITS]/8 bytes (GCM tag is appended) - * - * The IV is generated by `Cipher.init` rather than by us: an AndroidKeyStore - * key created with `setRandomizedEncryptionRequired(true)` refuses an - * app-supplied IV, and SunJCE likewise default-generates one. Nothing here - * ever writes the plaintext passphrase to disk. - */ -object StoreSecret { - - /** AES-256 per the card. Keystore key size and this constant must agree. */ - const val KEY_BITS: Int = 256 - - /** 96-bit IV is the GCM-recommended size; AndroidKeyStore defaults to it. */ - const val IV_BYTES: Int = 12 - - /** Full-length GCM tag. Truncating it saves 6 bytes and buys nothing. */ - private const val TAG_BITS: Int = 128 - - private val MAGIC = byteArrayOf('O'.code.toByte(), 'W'.code.toByte(), 'S'.code.toByte(), 'E'.code.toByte(), 'A'.code.toByte(), 'L'.code.toByte(), '1'.code.toByte(), '\n'.code.toByte()) - - private const val TRANSFORMATION = "AES/GCM/NoPadding" - - /** - * Encrypts [plaintext] under [key]. The passphrase is never converted to a - * `String` on this path: the UTF-8 encoder reads the `CharArray` directly. - */ - fun seal(key: SecretKey, plaintext: CharArray): ByteArray { - require(plaintext.isNotEmpty()) { "refusing to seal an empty passphrase" } - val bytes = utf8(plaintext) - try { - val cipher = Cipher.getInstance(TRANSFORMATION) - cipher.init(Cipher.ENCRYPT_MODE, key) - val iv = cipher.iv - val ct = cipher.doFinal(bytes) - return ByteArray(MAGIC.size + 1 + iv.size + ct.size).also { out -> - var p = 0 - MAGIC.copyInto(out, p); p += MAGIC.size - out[p] = iv.size.toByte(); p += 1 - iv.copyInto(out, p); p += iv.size - ct.copyInto(out, p) - } - } catch (e: GeneralSecurityException) { - throw SecretUnavailable("could not encrypt the passphrase", e) - } finally { - wipe(bytes) - } - } - - /** - * Reverses [seal]. Throws [SecretUnavailable] on a wrong key, a truncated - * blob, or a failed GCM tag check — never returns partial plaintext. - */ - fun open(key: SecretKey, blob: ByteArray): CharArray { - if (blob.size < MAGIC.size + 1 + IV_BYTES + TAG_BITS / 8) { - throw SecretUnavailable("stored secret is truncated") - } - for (i in MAGIC.indices) { - if (blob[i] != MAGIC[i]) throw SecretUnavailable("stored secret is not an OnionWire envelope") - } - var p = MAGIC.size - val ivLen = blob[p].toInt() and 0xFF - p += 1 - if (ivLen != IV_BYTES) throw SecretUnavailable("unexpected IV length $ivLen") - if (blob.size < p + ivLen + TAG_BITS / 8) throw SecretUnavailable("stored secret is truncated") - val iv = blob.copyOfRange(p, p + ivLen) - val ct = blob.copyOfRange(p + ivLen, blob.size) - val plain = try { - val cipher = Cipher.getInstance(TRANSFORMATION) - cipher.init(Cipher.DECRYPT_MODE, key, GCMParameterSpec(TAG_BITS, iv)) - cipher.doFinal(ct) - } catch (e: GeneralSecurityException) { - throw SecretUnavailable("stored secret did not authenticate", e) - } - return try { - decodeUtf8(plain) - } finally { - wipe(plain) - } - } - - /** Zeroes [bytes]. Cheap, and it shortens the window a heap dump can read. */ - fun wipe(bytes: ByteArray) { - Arrays.fill(bytes, 0) - } - - /** Zeroes [chars]. Kotlin/Java strings are immutable, so this is the best we get. */ - fun wipe(chars: CharArray) { - Arrays.fill(chars, '\u0000') - } - - private fun utf8(chars: CharArray): ByteArray { - val bb = StandardCharsets.UTF_8.newEncoder().encode(CharBuffer.wrap(chars)) - return ByteArray(bb.remaining()).also(bb::get) - } - - private fun decodeUtf8(bytes: ByteArray): CharArray { - val cb = StandardCharsets.UTF_8.newDecoder().decode(java.nio.ByteBuffer.wrap(bytes)) - return CharArray(cb.remaining()).also(cb::get) - } -} - -/** - * The passphrase could not be recovered. The caller must fall back to typing - * it — a Keystore key does not survive a factory reset, a lock-screen change - * that invalidates keys, or an app-data wipe. - */ -class SecretUnavailable(message: String, cause: Throwable? = null) : RuntimeException(message, cause) diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/StoredPassphraseStore.kt b/android/app/src/main/java/com/siriusdevops/onionwire/crypto/StoredPassphraseStore.kt deleted file mode 100644 index 40c89fc..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/StoredPassphraseStore.kt +++ /dev/null @@ -1,204 +0,0 @@ -package com.siriusdevops.onionwire.crypto - -import java.io.File -import java.io.IOException - -/** - * The only on-disk copy of the passphrase: an AES-GCM blob under - * `context.filesDir`, which is app-private and excluded from backup and - * device transfer (`AndroidManifest.xml`, `res/xml/data_extraction_rules.xml`). - * - * The blob is the envelope from [StoreSecret] — magic + IV + ciphertext + tag. - * There is no second copy, no SharedPreferences mirror, and nothing outside the - * app's data dir. - * - * ## Migrating the wrapping key to the device-unlock gate - * - * A Keystore key cannot be retrofitted with `setUnlockedDeviceRequired`, so an - * install that stored a passphrase before the gate landed keeps an ungated key - * until the passphrase is in hand again. The only two places that happens are - * the ones below, and both go through the same crash-safe order: - * - * 1. `cipher.seal()` wraps under the unlock-gated key, creating it if needed. - * 2. The new blob is written to `…bin.tmp`. - * 3. Those exact bytes are read back and opened with the unlock-gated key and - * compared to the passphrase in hand. Failure ⇒ temp file dropped, - * everything else untouched (a [SecretUnavailable] with the reason, not a - * bare "did not authenticate"). - * 4. Only then is the temp file renamed over the real blob. - * 5. Only then is the pre-gate Keystore alias deleted. - * - * A crash anywhere before 4 leaves the previous blob and the previous key - * intact; a crash between 4 and 5 leaves a working gated blob plus a stale - * alias that the next save/unlock retires. The pre-gate key is therefore never - * deleted before a blob that supersedes it is proven. - */ -class StoredPassphraseStore( - private val file: File, - private val cipher: PassphraseCipher, -) { - - sealed interface Load { - /** Decrypted for this call only. The caller must wipe the array. */ - class Loaded(val passphrase: CharArray) : Load - - /** Nothing stored yet — first run, or the user forgot it. */ - data object Absent : Load - - /** - * Something is stored but cannot be read: the Keystore key is gone or - * unusable, the device is locked, or the file is corrupt. Fall back to - * typing. - */ - data class Unavailable(val reason: String) : Load - } - - /** - * The optional key-migration capability. Absent for any cipher that is not - * the Keystore one (the JVM fakes in tests), which simply means there is - * nothing to migrate and the pre-gate order above does not apply. - */ - private fun migrator(): PassphraseKeyMigration? = cipher as? PassphraseKeyMigration - - fun exists(): Boolean = file.isFile && file.length() > 0L - - /** Where the wrapping key actually lives. See [PassphraseCipher.backing]. */ - fun backing(): KeyBacking = cipher.backing() - - /** True when the stored blob is wrapped by a device-unlock-gated key. */ - fun unlockGated(): Boolean = migrator()?.unlockGateInEffect() == true - - /** Path for diagnostics in tests. Never logged with its contents. */ - val path: String get() = file.absolutePath - - /** - * Encrypts and replaces the stored blob, then retires a pre-gate key. - * - * Replaces the blob atomically: written to a sibling temp file, proven to - * open under the key that produced it, and only then renamed, so a crash - * mid-write cannot leave half a blob or a blob nobody can decrypt. - * - * @throws SecretUnavailable when the blob could not be written or could not - * be proven under the unlock-gated key. The previous blob is still in - * place in that case. - */ - fun save(passphrase: CharArray) { - require(passphrase.isNotEmpty()) { "refusing to store an empty passphrase" } - // seal() may create the unlock-gated key, so ask about the gate only - // afterwards — on a fresh install there is no gated key before this. - val blob = cipher.seal(passphrase) - try { - val migration = migrator() - val gated = migration?.unlockGateInEffect() == true - writeVerified(blob, passphrase, if (gated) migration else null) - // The replacement blob is durable and proven. Only now may the - // pre-gate alias go: deleting it earlier would strand a blob. - if (gated) migration?.retireLegacyKey() - } finally { - StoreSecret.wipe(blob) - } - } - - /** - * Reads and decrypts the blob. The returned array is the caller's to wipe. - * - * A successful read is also the moment the wrapping key can be upgraded: the - * passphrase is in hand, so a pre-gate key is re-wrapped here rather than - * asking the user to type it again. - * - * A failed decrypt does **not** delete the blob: a transient Keystore - * failure must not silently destroy the user's only copy. Use [forget] to - * drop it deliberately. - */ - fun load(): Load { - if (!exists()) return Load.Absent - val blob = try { - file.readBytes() - } catch (e: IOException) { - return Load.Unavailable("the stored passphrase file could not be read (${e.message})") - } - val passphrase = try { - cipher.open(blob) - } catch (e: SecretUnavailable) { - return Load.Unavailable(e.message ?: "the stored passphrase did not authenticate") - } finally { - StoreSecret.wipe(blob) - } - migrateOnSuccessfulUnlock(passphrase) - return Load.Loaded(passphrase) - } - - /** Drops the ciphertext and the Keystore key. Irreversible. */ - fun forget() { - file.delete() - File(file.parentFile, file.name + ".tmp").delete() - cipher.deleteKey() - } - - /** - * Best effort, after a successful unlock. The unlock itself already - * succeeded, so a failed re-wrap must not fail it — but it must not be - * silent either: the reason goes to logcat and to - * [KeystorePassphraseCipher.unlockGateReport], and the install stays - * honestly "not unlock-gated" until a later save/unlock succeeds. - */ - private fun migrateOnSuccessfulUnlock(passphrase: CharArray) { - val migration = migrator() ?: return - if (!migration.unlockGateInEffect() || !migration.legacyKeyPending()) return - try { - save(passphrase) - } catch (e: Exception) { - migration.noteMigrationFailure(e.message ?: e.toString()) - } - } - - /** - * Writes [blob] to the temp file, proves the written bytes open under the - * unlock-gated key alone, and renames it into place. - * - * [verifier] is null when no unlock-gated key exists on this device (API - * 26–27, or a Keystore that refused the flag): the blob is then wrapped by - * the pre-gate key, which is the only key there is. - */ - private fun writeVerified( - blob: ByteArray, - passphrase: CharArray, - verifier: PassphraseKeyMigration?, - ) { - file.parentFile?.mkdirs() - val tmp = File(file.parentFile, file.name + ".tmp") - tmp.writeBytes(blob) - if (verifier != null) { - val written = tmp.readBytes() - try { - val back = try { - verifier.openWithUnlockGate(written) - } catch (e: SecretUnavailable) { - tmp.delete() - throw SecretUnavailable( - "the new passphrase blob did not open under the unlock-gated key; " + - "the previous blob and key were kept", - e, - ) - } - try { - if (!back.contentEquals(passphrase)) { - tmp.delete() - throw SecretUnavailable( - "the new passphrase blob did not read back identically; " + - "the previous blob and key were kept", - ) - } - } finally { - StoreSecret.wipe(back) - } - } finally { - StoreSecret.wipe(written) - } - } - if (!tmp.renameTo(file)) { - file.writeBytes(blob) - tmp.delete() - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/KeepAlivePolicy.kt b/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/KeepAlivePolicy.kt deleted file mode 100644 index b2add16..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/KeepAlivePolicy.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.siriusdevops.onionwire.keepalive - -/** - * Whether the foreground service has anything to hold. - * - * Bootstrap used to not count: the service bailed when `Wire` was still null, - * and `openWire` ran on the UI ViewModel scope, so closing the activity - * cancelled Tor bring-up. Opening is work; a published node is work; locked - * and idle is not. - */ -fun keepAliveHasWork(nodeOpen: Boolean, bootstrapInFlight: Boolean): Boolean = - nodeOpen || bootstrapInFlight diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/KeepAliveService.kt b/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/KeepAliveService.kt deleted file mode 100644 index bb0b52a..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/KeepAliveService.kt +++ /dev/null @@ -1,189 +0,0 @@ -package com.siriusdevops.onionwire.keepalive - -import android.app.Notification -import android.app.NotificationChannel -import android.app.NotificationManager -import android.app.PendingIntent -import android.app.Service -import android.content.Context -import android.content.Intent -import android.content.pm.ServiceInfo -import android.os.Build -import android.os.IBinder -import android.util.Log -import androidx.core.app.NotificationCompat -import com.siriusdevops.onionwire.MainActivity -import com.siriusdevops.onionwire.R - -/** - * Holds the process (and therefore the in-process Arti node) in the foreground - * so the onion stays published after the screen goes off. - * - * The service does *not* own the node — [NodeHost] does. This reports its - * anchor and lets the policy decide: starting the keep-alive keeps the node - * alive, and losing it (user tapped Stop, or the system killed us) shuts the - * node down only if nothing else is holding it. - * - * Returns `START_NOT_STICKY` deliberately. A sticky restart would bring the - * service back with no node behind it — the passphrase is not held in memory - * after unlock — and a notification claiming "OnionWire is reachable" over a - * dead onion is worse than no service at all. - */ -class KeepAliveService : Service() { - - override fun onBind(intent: Intent?): IBinder? = null - - override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { - if (intent?.action == ACTION_STOP) { - // The user ended the keep-alive from the notification. `onDestroy()` - // reports the lost anchor: the node stops if nothing else holds it, - // and stays up while the app is still open in front of them (the UI - // anchor). The action is labelled "Stop keep-alive", not "Lock", so - // that is the behaviour it promises. - stopSelf() - return START_NOT_STICKY - } - - if (!NodeHost.hasWorkForKeepAlive()) { - // Nothing to keep alive. A notification here would be a lie. - // Bootstrap counts: the node is not `current()` until Tor has - // published, and that is exactly the window Android used to kill. - stopSelf() - return START_NOT_STICKY - } - - if (!startInForeground(intent?.getStringExtra(EXTRA_ONION).orEmpty())) { - stopSelf() - return START_NOT_STICKY - } - - NodeHost.onKeepAliveStarted() - return START_NOT_STICKY - } - - override fun onDestroy() { - NodeHost.onKeepAliveStopped() - super.onDestroy() - } - - /** - * @return false when the system refused the foreground start, in which case - * the anchor was never taken and the node stays foreground-only. - */ - private fun startInForeground(onion: String): Boolean { - return try { - createChannel() - val notification = buildNotification(onion) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { - startForeground( - NOTIFICATION_ID, - notification, - ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE, - ) - } else { - // API 26-33: the manifest-declared type is what the platform - // records; the three-arg overload only exists from 29. - startForeground(NOTIFICATION_ID, notification) - } - true - } catch (t: Throwable) { - // API 31+: a start from the background throws - // ForegroundServiceStartNotAllowedException. Degrade to "the node - // lives only while the app does" instead of taking the process - // down; the roster says so on screen. - Log.w(TAG, "foreground start refused; node stays foreground-only", t) - NodeHost.onKeepAliveRefused(t.message ?: t.toString()) - false - } - } - - private fun createChannel() { - val manager = getSystemService(NotificationManager::class.java) ?: return - val channel = NotificationChannel( - CHANNEL_ID, - getString(R.string.keep_alive_channel_name), - // LOW: present in the shade, never a sound or a heads-up. This is a - // status light, not an alert. - NotificationManager.IMPORTANCE_LOW, - ).apply { - description = getString(R.string.keep_alive_channel_description) - setShowBadge(false) - } - manager.createNotificationChannel(channel) - } - - private fun buildNotification(onion: String): Notification { - val open = PendingIntent.getActivity( - this, - 0, - Intent(this, MainActivity::class.java), - PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT, - ) - val stop = PendingIntent.getService( - this, - 1, - Intent(this, KeepAliveService::class.java).setAction(ACTION_STOP), - PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT, - ) - // Never the full v3 locator: a notification body is lock-screen public. - val short = onion.take(ONION_PREFIX) - val opening = short.isEmpty() && NodeHost.isOpening() - val title = if (opening) { - getString(R.string.keep_alive_title_opening) - } else { - getString(R.string.keep_alive_title) - } - val text = when { - opening -> getString(R.string.keep_alive_text_opening) - short.isEmpty() -> getString(R.string.keep_alive_text) - else -> getString(R.string.keep_alive_text_onion, short) - } - return NotificationCompat.Builder(this, CHANNEL_ID) - .setSmallIcon(R.drawable.ic_stat_onion) - .setContentTitle(title) - .setContentText(text) - .setContentIntent(open) - .addAction(0, getString(R.string.keep_alive_stop), stop) - .setCategory(NotificationCompat.CATEGORY_SERVICE) - .setPriority(NotificationCompat.PRIORITY_LOW) - .setOngoing(true) - .setOnlyAlertOnce(true) - .setShowWhen(false) - .build() - } - - companion object { - private const val TAG = "OnionWireKeepAlive" - - const val ACTION_STOP = "com.siriusdevops.onionwire.keepalive.STOP" - const val EXTRA_ONION = "onion" - - private const val CHANNEL_ID = "keep-alive" - private const val NOTIFICATION_ID = 1 - - /** Characters of the onion address shown, prefix only. */ - private const val ONION_PREFIX = 10 - - /** - * Brings up the keep-alive. Must be called while the app is visible — - * an unlock is, and that is the only caller — so the API 31+ - * background-start restriction does not apply. - */ - fun start(context: Context, onion: String) { - val intent = Intent(context, KeepAliveService::class.java) - .putExtra(EXTRA_ONION, onion) - try { - context.startForegroundService(intent) - } catch (t: Throwable) { - // Same refusal as in the service, just one call earlier. - Log.w(TAG, "startForegroundService refused", t) - NodeHost.onKeepAliveRefused(t.message ?: t.toString()) - } - } - - /** Ends the keep-alive; `onDestroy()` reports the lost anchor. */ - fun stop(context: Context) { - context.stopService(Intent(context, KeepAliveService::class.java)) - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/NodeHost.kt b/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/NodeHost.kt deleted file mode 100644 index 925fd3e..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/NodeHost.kt +++ /dev/null @@ -1,211 +0,0 @@ -package com.siriusdevops.onionwire.keepalive - -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Deferred -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.async -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.launch -import uniffi.onionwire_sdk.Wire -import uniffi.onionwire_sdk.openWire -import java.io.File - -/** - * How visible the keep-alive currently is, for the one line of battery honesty - * the roster shows. - */ -sealed interface KeepAliveStatus { - /** No foreground service. The node lives only while the app does. */ - data object Off : KeepAliveStatus - - /** A foreground service is holding the node, notification and all. */ - data object On : KeepAliveStatus - - /** - * The system refused the foreground start (API 31+ background-start rules, - * an OEM battery policy). The node is still up, but it dies with the app. - */ - data class Unavailable(val reason: String) : KeepAliveStatus -} - -/** - * Process-wide owner of the single `Wire` node. - * - * Ownership rule: whoever opens the node hands the handle here, and **only this - * object ever calls `shutdown()` or `flush()` on it**. The ViewModel and - * [KeepAliveService] report lifecycle transitions; [NodeLifetime] decides - * whether the node survives, and this object executes that decision. - * - * That indirection is the point. `WireViewModel.onCleared()` used to shut the - * node down unconditionally, so a foreground service holding the same node - * would have been torn down by the first configuration change — or worse, the - * service would have kept a notification up for a node the UI had already - * killed. Neither side owns the node now; the policy does. - * - * Threading: [open] runs on [scope] (IO). [wire] is volatile so the main - * thread can read [current] while bootstrap completes off-main. - */ -object NodeHost { - - /** - * Teardown must outlive the object graph that asked for it: `onCleared()` - * runs *after* `viewModelScope` is already cancelled, and stopping the node - * means draining the outbox and stopping Arti, not dropping a reference. - * One process-wide scope is enough — there is one node per process. - */ - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) - - private val lifetime = NodeLifetime() - - @Volatile - private var wire: Wire? = null - - /** - * In-flight `openWire`. Lives on [scope], not the UI ViewModel: closing the - * activity must not cancel Tor bootstrap. Null when idle or already open. - */ - @Volatile - private var bootstrap: Deferred? = null - - /** - * Set before the keep-alive starts, before [bootstrap] exists, so the - * service does not `stopSelf` in the gap between Unlock and `openWire`. - */ - @Volatile - private var claimedOpening: Boolean = false - - /** - * The in-flight teardown, if any. Re-opening has to wait for it: the old - * node holds the sqlite file and Arti's state lock until `shutdown()` - * returns, and racing it makes the new node fail to open. - */ - private var stopping: Job? = null - - private val _keepAlive = MutableStateFlow(KeepAliveStatus.Off) - val keepAlive: StateFlow = _keepAlive.asStateFlow() - - /** The live node, or null when locked. */ - fun current(): Wire? = wire - - /** Tor bring-up is running on [scope]. The UI may be gone. */ - fun isOpening(): Boolean = claimedOpening || bootstrap?.isActive == true - - /** The foreground service holds a published node *or* an in-flight open. */ - fun hasWorkForKeepAlive(): Boolean = - keepAliveHasWork(nodeOpen = wire != null, bootstrapInFlight = isOpening()) - - /** - * Call *before* [KeepAliveService.start] on the unlock path so the service - * sees bootstrap work before `openWire` has a job. - */ - fun noteOpening() { - claimedOpening = true - } - - /** The live node, or a hard error. Callers are UI paths that require unlock. */ - fun requireOpen(): Wire = wire ?: error("locked") - - /** - * Opens the node and anchors it to the UI. - * - * Suspends inside Arti's bootstrap — minutes on a cold start — so this must - * never run on the main thread. The *work* runs on [scope], not the caller's - * job: a `viewModelScope` cancellation (activity gone) must not abort Tor. - * A second call while bootstrap is in flight joins the same job. - */ - suspend fun open(home: File, passphrase: String): Wire { - stopping?.join() - wire?.let { return it } - bootstrap?.let { return it.await() } - val job = scope.async { - val opened = openWire(home.absolutePath, passphrase) - wire = opened - // Keep-alive may already be On: it starts at unlock so Android - // will not kill us mid-bootstrap. Do not stomp that. - if (_keepAlive.value !is KeepAliveStatus.On) { - _keepAlive.value = KeepAliveStatus.Off - } - lifetime.onOpened() - opened - } - bootstrap = job - job.invokeOnCompletion { - if (bootstrap === job) bootstrap = null - claimedOpening = false - } - return job.await() - } - - /** Join an in-flight [open] without starting a second `openWire`. */ - suspend fun awaitOpen(): Wire { - wire?.let { return it } - return bootstrap?.await() ?: error("locked") - } - - /** The UI is going away: finish, task swipe, or process death. */ - fun onUiDetached(): NodeAction = apply(lifetime.onUnanchored(NodeAnchor.UI)) - - /** The keep-alive reached the foreground with its notification. */ - fun onKeepAliveStarted(): NodeAction { - _keepAlive.value = KeepAliveStatus.On - return apply(lifetime.onAnchored(NodeAnchor.KEEP_ALIVE)) - } - - /** The keep-alive stopped, or the system destroyed it. */ - fun onKeepAliveStopped(): NodeAction { - if (_keepAlive.value is KeepAliveStatus.On) _keepAlive.value = KeepAliveStatus.Off - return apply(lifetime.onUnanchored(NodeAnchor.KEEP_ALIVE)) - } - - /** - * `startForeground()` was refused. Nothing is anchoring the node at the OS - * level, so fail over to the honest pre-existing behaviour: the node lives - * as long as the app does, and the roster says why. - */ - fun onKeepAliveRefused(reason: String): NodeAction { - _keepAlive.value = KeepAliveStatus.Unavailable(reason) - return apply(lifetime.onUnanchored(NodeAnchor.KEEP_ALIVE)) - } - - /** - * Explicit Lock, from the UI or the notification's Stop action. The caller - * stops the keep-alive first — a service that is still running would - * re-anchor a node that no longer exists. - */ - fun lock(): NodeAction { - bootstrap?.cancel() - bootstrap = null - claimedOpening = false - return apply(lifetime.onLocked()) - } - - private fun apply(action: NodeAction): NodeAction { - when (action) { - NodeAction.Keep -> Unit - NodeAction.Flush -> scope.launch { runCatching { wire?.flush() } } - NodeAction.Stop -> stopNode() - } - return action - } - - private fun stopNode() { - val dying = wire ?: return - wire = null - lifetime.onClosed() - // Best effort, both steps: teardown runs on a process-scope job after - // the UI is gone, so there is nobody to show an error to and nothing - // useful to retry. `shutdown()` drains again with a shorter budget, so - // a flush that times out is not fatal. - stopping = scope.launch { - runCatching { dying.flush() } - // A second shutdown — `lock()` and then `onCleared()`, say — lands - // here too: the SDK reports it as a typed WireException.Stopped, - // never a panic, so swallowing it is correct. - runCatching { dying.shutdown() } - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/NodeLifetime.kt b/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/NodeLifetime.kt deleted file mode 100644 index e195867..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/keepalive/NodeLifetime.kt +++ /dev/null @@ -1,99 +0,0 @@ -package com.siriusdevops.onionwire.keepalive - -/** - * Who currently requires the in-process Tor node to stay alive. - * - * [UI] is a live `WireViewModel`; [KEEP_ALIVE] is a running [KeepAliveService]. - * Both can be present at the same time — that is the interesting case: the - * screen can go away while the keep-alive stays up, and the node must survive - * it. This enum exists so "who owns the node" is a value, not a convention. - */ -enum class NodeAnchor { - UI, - KEEP_ALIVE, -} - -/** What the caller must do to the node after reporting a transition. */ -sealed interface NodeAction { - /** Nothing to do; the node's fate is unchanged. */ - data object Keep : NodeAction - - /** Drain the outbox, leave the node published. */ - data object Flush : NodeAction - - /** Drain the outbox, then `shutdown()`. The node is gone. */ - data object Stop : NodeAction -} - -/** - * Pure policy for the single node's lifetime: no Android, no coroutines, no - * SDK. The ViewModel and the foreground service both report transitions here - * and execute the returned [NodeAction]. - * - * The rule the whole card turns on: **the UI going away does not stop the node - * while a keep-alive anchor is held.** Before this, `WireViewModel.onCleared()` - * called `shutdown()` unconditionally, which is exactly the bug a foreground - * service would have walked into. - * - * Threading: state is mutated only from the main thread — [NodeHost] is the - * only caller, and it hops back to the main thread after the SDK's blocking - * open. There is no lock here on purpose. - */ -class NodeLifetime { - - private var open = false - private val anchors = LinkedHashSet() - - /** True between [onOpened] and [onClosed]/[onLocked]. */ - val isOpen: Boolean get() = open - - fun anchoredBy(anchor: NodeAnchor): Boolean = anchor in anchors - - /** - * The unlock path opened a node. The UI is by definition present — the user - * typed the passphrase into it. - */ - fun onOpened(): NodeAction { - open = true - anchors.add(NodeAnchor.UI) - return NodeAction.Keep - } - - /** Teardown finished; the node no longer exists. */ - fun onClosed(): NodeAction { - open = false - anchors.clear() - return NodeAction.Keep - } - - /** A keep-alive reached the foreground. */ - fun onAnchored(anchor: NodeAnchor): NodeAction { - anchors.add(anchor) - return NodeAction.Keep - } - - /** - * An anchor went away: the UI was destroyed, or the keep-alive stopped or - * was killed. Removing the anchor first means a repeat report (the service - * action and `onDestroy()` both fire) cannot double-count. - */ - fun onUnanchored(anchor: NodeAnchor): NodeAction { - anchors.remove(anchor) - if (!open) return NodeAction.Keep - // Flush rather than Keep when another anchor remains: the process may - // be killed at any moment once the screen is gone, and the outbox is - // the whole point of surviving that. - return if (anchors.isEmpty()) NodeAction.Stop else NodeAction.Flush - } - - /** - * The user pressed Lock. Every anchor is dropped: a keep-alive that outlived - * an explicit lock would leave a notification pointing at a dead onion. - */ - fun onLocked(): NodeAction { - val wasOpen = open - open = false - anchors.clear() - return if (wasOpen) NodeAction.Stop else NodeAction.Keep - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt deleted file mode 100644 index a5369b4..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt +++ /dev/null @@ -1,453 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.foundation.text.KeyboardActions -import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.CircularProgressIndicator -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.IconButton -import androidx.compose.material3.LocalContentColor -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar -import androidx.compose.material3.TopAppBarDefaults -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.focus.FocusRequester -import androidx.compose.ui.focus.focusRequester -import androidx.compose.ui.platform.testTag -import androidx.compose.ui.semantics.contentDescription -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.input.ImeAction -import androidx.compose.ui.text.input.KeyboardCapitalization -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwIconButton -import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.siriusdevops.onionwire.WireViewModel -import uniffi.onionwire_sdk.SendState - -@OptIn(ExperimentalMaterial3Api::class) -@Composable -fun ChatScreen( - vm: WireViewModel, - /** The peer's public key, hex — the key the open chat's poller runs for. */ - peer: String, - title: String, - fingerprint: String, - onion: String, - onBack: () -> Unit, - /** - * Wall clock in unix seconds. `next_attempt_at` is absolute, so the - * countdown is computed here rather than baked into the store — injectable - * so a test can pin "now" instead of racing the clock. - */ - nowSeconds: () -> Long = { System.currentTimeMillis() / 1_000L }, -) { - // The refresh cadence lives in the ViewModel: one poller per open chat, not - // one per composition. Collecting here means a re-composition (or a - // configuration change) does not start a second loop against the SDK. - val chat by vm.chat.collectAsStateWithLifecycle() - val messages = chat?.messages - val outbox = chat?.outbox.orEmpty() - // The core's retry budget, fetched once per open chat: `try 3/8` renders - // against this and never against a constant in the app. - val maxAttempts = chat?.maxAttempts - - var draft by remember { mutableStateOf("") } - var pending by remember { mutableStateOf(null) } - // Send-path failures are the screen's own state; load failures come back on - // [ChatState.error]. Both render in the same place under the list. - var sendError by remember { mutableStateOf(null) } - var notice by remember { mutableStateOf(null) } - val error = sendError ?: chat?.error - val listState = rememberLazyListState() - - // Auto-scroll bookkeeping. `firstFillDone` keeps the one-jump-to-the-bottom - // on the first load (and again after leaving and re-entering the chat); - // `ownSendPending` is the user's own message asking for the list to follow - // even though they may have scrolled up in history. - var firstFillDone by remember { mutableStateOf(false) } - var ownSendPending by remember { mutableStateOf(false) } - - // The composer is the only place a message can be sent from, so after a - // send the keyboard is left up and the caret goes back into the field — - // the next message is one keystroke away instead of a re-tap. - val inputFocus = remember { FocusRequester() } - val send: () -> Unit = { - if (draft.isNotBlank() && pending == null) { - pending = draft - draft = "" - // The user's own message is the one case where the list is allowed - // to move while they are scrolled up in history. - ownSendPending = true - inputFocus.requestFocus() - } - } - - // The poller's lifetime is the chat screen's: entering starts it, leaving - // stops it, and re-entering the same peer is a no-op in the ViewModel, so - // there is exactly one loop no matter how the nav stack is walked. - DisposableEffect(peer) { - vm.openChat(peer) - onDispose { vm.closeChat(peer) } - } - - // Send. An unreachable peer's onion is not an error any more: the core - // stores the message in its local outbox and the retry worker dials again - // with backoff (30s doubling, capped at 30 min, 8 attempts, then terminal - // `failed`). A protocol error is still a real failure here — nothing is - // queued for those. - LaunchedEffect(pending) { - val body = pending ?: return@LaunchedEffect - sendError = null - notice = null - // The user has acted on whatever the poller last reported. - vm.clearChatError() - runCatching { vm.send(peer, body) } - .onSuccess { - if (it == SendState.QUEUED) { - notice = "Queued: their onion is unreachable. The message stays on " + - "this device and is retried until it lands." - } - } - .onFailure { sendError = it.message ?: it.toString() } - pending = null - } - - // Known and accepted: this is keyed on the message count, so a delivery-only - // change (a row flipping `queued` → `sent`, same size, different marker) - // does not re-run it. That has always been the behaviour here and it is the - // safe one — the list never moves for a marker. - LaunchedEffect(messages?.size) { - val n = messages?.size ?: 0 - if (n == 0) return@LaunchedEffect - if (!firstFillDone) { - // First load: one jump to the bottom so the newest message is the - // one on screen, without an animation nobody asked for. - listState.scrollToItem(n - 1) - firstFillDone = true - return@LaunchedEffect - } - // Follow the tail only when the reader is already there. `n - 2` - // rather than `!canScrollForward`: the append has already made the list - // scrollable by the time this runs, so "can I scroll further" is true - // even for someone who was glued to the bottom a frame ago — and - // `lastVisible >= n - 2` tolerates the last row being partly on screen. - val lastVisible = listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: -1 - if (ownSendPending || lastVisible >= n - 2) { - listState.animateScrollToItem(n - 1) - } - ownSendPending = false - } - - Scaffold( - topBar = { - TopAppBar( - title = { - Column { - Text(title, style = MaterialTheme.typography.titleSmall) - Text( - fingerprint, - style = MaterialTheme.typography.labelSmall, - fontFamily = FontFamily.Monospace, - color = MaterialTheme.colorScheme.primary, - ) - } - }, - navigationIcon = { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - ) - }, - colors = TopAppBarDefaults.topAppBarColors( - containerColor = MaterialTheme.colorScheme.background, - ), - ) - }, - // The top bar carries its own status-bar inset; the content root applies - // systemBars + IME once (see `screenContentInsets`) so the navigation - // bar is not counted twice while the keyboard is up. - contentWindowInsets = WindowInsets(0, 0, 0, 0), - ) { pad -> - Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets(), - ) { - Text( - "onion: $onion", - style = MaterialTheme.typography.labelSmall, - fontFamily = FontFamily.Monospace, - color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.padding(horizontal = 12.dp), - ) - - val list = messages - when { - list == null -> { - // The body region always claims the leftover height, so the - // composer below it can never be pushed off the bottom — - // least of all by the keyboard. - Box(Modifier.weight(1f).fillMaxWidth(), contentAlignment = Alignment.Center) { - CircularProgressIndicator(Modifier.padding(16.dp)) - } - } - - list.isEmpty() -> { - Column( - Modifier - .weight(1f) - .fillMaxWidth() - .verticalScroll(rememberScrollState()) - .padding(24.dp), - ) { - Text("No messages", style = MaterialTheme.typography.titleSmall) - Spacer(Modifier.height(6.dp)) - Text( - "If their onion is unreachable the message is queued in a " + - "local outbox on this device and retried with backoff " + - "(30s doubling, up to 30 min, 8 attempts) — never handed " + - "to a third party. A queued message is local-only until " + - "their onion takes it.", - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - } - } - - else -> { - // The outbox rows behind the pending sends: `queued (try - // 3/8, retry 45s)` needs the store's own counters and the - // core's retry budget. With either missing, or with a join - // that cannot prove itself, the rows keep the flat state - // marker — wrong numbers would be worse than none. - val max = maxAttempts - val details = if (max == null) { - List(list.size) { null } - } else { - outboxDetails( - rows = list.map { ChatRowInput(it.direction, it.delivery) }, - outbox = outbox.map { - OutboxRowInput( - messageId = it.messageId, - status = it.status, - attempts = it.attempts, - nextAttemptAt = it.nextAttemptAt, - ) - }, - maxAttempts = max, - now = nowSeconds(), - ) - } - LazyColumn( - state = listState, - modifier = Modifier.weight(1f).fillMaxWidth(), - contentPadding = PaddingValues(12.dp), - verticalArrangement = Arrangement.spacedBy(6.dp), - ) { - itemsIndexed(list) { i, m -> - val mine = m.direction == "out" - Row( - Modifier.fillMaxWidth(), - horizontalArrangement = - if (mine) Arrangement.End else Arrangement.Start, - ) { - Column( - horizontalAlignment = if (mine) Alignment.End - else Alignment.Start, - ) { - Text( - m.body, - style = MaterialTheme.typography.bodyMedium, - color = if (mine) MaterialTheme.colorScheme.onPrimary - else MaterialTheme.colorScheme.onSurface, - modifier = Modifier - .background( - if (mine) MaterialTheme.colorScheme.primary - else MaterialTheme.colorScheme.surfaceVariant, - RoundedCornerShape(10.dp), - ) - .padding(horizontal = 10.dp, vertical = 8.dp), - ) - parseDelivery(m.direction, m.delivery)?.let { d -> - DeliveryMarker(d, details.getOrNull(i)) - } - } - } - } - } - } - } - - // Chat-level outbox state: what is still coming, and whether - // anything has terminated as failed. - val summary = outboxSummary( - messages.orEmpty().map { parseDelivery(it.direction, it.delivery) }, - ) - summary.note?.let { note -> - Text( - note, - style = MaterialTheme.typography.labelSmall, - color = if (summary.hasFailures) MaterialTheme.colorScheme.error - else MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier - .padding(horizontal = 12.dp, vertical = 2.dp) - .testTag("outbox-summary"), - ) - } - - notice?.let { - Text( - it, - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp), - ) - } - - error?.let { - Text( - it, - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.error, - modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp), - ) - } - - // The composer sticks to the bottom of the window: `screenContentInsets` - // already lifted it above the keyboard, and its row is never allowed - // to be squeezed out by the messages above it (they hold the weight). - Row( - Modifier - .fillMaxWidth() - .padding(8.dp) - .testTag("chat-composer"), - verticalAlignment = Alignment.Bottom, - ) { - OutlinedTextField( - value = draft, - onValueChange = { draft = it }, - modifier = Modifier - .weight(1f) - .focusRequester(inputFocus) - .testTag("chat-input"), - maxLines = 4, - label = { Text("message") }, - // DECISION (item 3 of the follow-up card): the IME's action - // key sends; the soft keyboard cannot insert a manual - // newline. `ImeAction.Send` and `maxLines = 4` are not in - // conflict — `maxLines` is a wrap limit (a long message - // grows to four lines, then scrolls inside the field), not - // a newline affordance. Chat convention wins: Enter-to-send - // is what a messenger's users reach for, and the Send button - // is on the same row. Nothing is unreachable either — a - // hardware keyboard's Enter never goes through the IME - // action, so Shift+Enter still inserts a real newline in - // the field. - keyboardOptions = KeyboardOptions( - capitalization = KeyboardCapitalization.Sentences, - imeAction = ImeAction.Send, - ), - keyboardActions = KeyboardActions(onSend = { send() }), - ) - Spacer(Modifier.width(8.dp)) - // Always drawn, never swapped out for a spinner: a button that - // changes size under the thumb — or disappears — is how "I hit - // send and nothing happened" gets reported. - OwButton( - text = "Send", - enabled = draft.isNotBlank() && pending == null, - onClick = send, - modifier = Modifier.testTag("chat-send"), - ) { - if (pending != null) { - CircularProgressIndicator( - modifier = Modifier.size(14.dp), - strokeWidth = 2.dp, - color = LocalContentColor.current, - ) - Spacer(Modifier.width(6.dp)) - } - Text("Send") - } - } - } - } -} - -/** - * One message's delivery marker, straight from the core's outbox state. - * - * The row carries an explicit announcement so a screen reader says - * "Queued, not delivered yet: retrying their onion (try 3/8, retry 45s)" - * instead of reading a clock glyph, and a [Delivery.testTag] so a UI test can - * find the state without depending on the glyph. [detail] is the outbox row's - * own counters when the join landed; when it is `null` the row keeps the flat - * marker. `send` shows a small indeterminate spinner while the worker has an - * attempt in flight. - */ -@Composable -private fun DeliveryMarker(d: Delivery, detail: QueuedRowDetail?) { - val tint = when (d) { - is Delivery.Failed -> MaterialTheme.colorScheme.error - Delivery.Sent -> MaterialTheme.colorScheme.onSurfaceVariant - else -> MaterialTheme.colorScheme.primary - } - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .padding(horizontal = 4.dp, vertical = 1.dp) - .testTag(d.testTag) - .semantics(mergeDescendants = true) { - contentDescription = deliveryAnnouncement(d, detail) - }, - ) { - if (d is Delivery.Sending) { - CircularProgressIndicator( - modifier = Modifier.size(10.dp), - strokeWidth = 1.5.dp, - color = tint, - ) - Spacer(Modifier.width(4.dp)) - } - Text( - deliveryMarkerText(d, detail), - style = MaterialTheme.typography.labelSmall, - color = tint, - ) - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt deleted file mode 100644 index 88a7629..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt +++ /dev/null @@ -1,64 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.WindowInsetsSides -import androidx.compose.foundation.layout.ime -import androidx.compose.foundation.layout.only -import androidx.compose.foundation.layout.systemBars -import androidx.compose.foundation.layout.union -import androidx.compose.foundation.layout.windowInsetsPadding -import androidx.compose.runtime.Composable -import androidx.compose.runtime.staticCompositionLocalOf -import androidx.compose.ui.Modifier - -/** - * True while a screen is rendered inside the shell that owns the bottom tab bar. - * - * The tab bar applies the navigation-bar inset itself, so a screen inside the - * shell must not pad for it a second time — that is the difference between the - * list ending just above the tabs and the list floating 48dp above them. - */ -val LocalBottomBarPresent = staticCompositionLocalOf { false } - -/** - * The bottom + horizontal window insets one screen's content root must apply - * itself. - * - * `MainActivity` calls `enableEdgeToEdge()`, which means - * `setDecorFitsSystemWindows(window, false)`. On API 30+ that stops the - * framework from resizing the window for the soft keyboard: the manifest's - * `android:windowSoftInputMode="adjustResize"` has nothing left to resize, and - * the IME arrives as a *window inset* instead. `Scaffold`'s - * `contentWindowInsets` only covers `systemBars`, so anything anchored to the - * bottom of the window — the chat composer, a submit button under a text field - * — ends up drawn behind the keyboard, reachable only by dismissing it. - * - * The IME's bottom inset already covers the navigation bar, so the two are - * unioned (per-side `max`), never summed: keyboard height while typing, - * navigation-bar height otherwise, and no double padding in between. Inside the - * tab shell the vertical bar inset is dropped entirely — see - * [LocalBottomBarPresent]. - * - * The `Top` side is deliberately excluded — a `Scaffold`'s `pad.top` is the app - * bar's own measured height, and the app bar carries its own status-bar inset - * (`TopAppBarDefaults.windowInsets`). - * - * Pair every use with `Scaffold(contentWindowInsets = WindowInsets(0, 0, 0, 0))` - * so the same inset is not applied twice. - * - * `@Composable` because `WindowInsets.systemBars` / `WindowInsets.ime` are - * composable reads — call it from a composable (every call site is one). - */ -@Composable -fun Modifier.screenContentInsets(): Modifier { - val sides = if (LocalBottomBarPresent.current) { - WindowInsetsSides.Horizontal - } else { - WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom - } - return windowInsetsPadding( - WindowInsets.systemBars.only(sides) - .union(WindowInsets.ime) - .only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom), - ) -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteAddFlow.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteAddFlow.kt deleted file mode 100644 index 0f50a48..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteAddFlow.kt +++ /dev/null @@ -1,60 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue - -/** - * JVM-testable holder for the paste-invite verify/add flow. - * - * Verify and add own independent in-flight flags. They must never share a - * single `busy` boolean — that is what made Approve & add a no-op: the - * verify path reset the flag the add path was waiting on. - */ -class InviteAddFlow( - private val onDecode: suspend (String) -> P, - private val onAdd: suspend (String) -> A, -) { - var preview: P? by mutableStateOf(null) - private set - var added: A? by mutableStateOf(null) - private set - var error: String? by mutableStateOf(null) - private set - var verifying: Boolean by mutableStateOf(false) - private set - var adding: Boolean by mutableStateOf(false) - private set - - fun clear() { - preview = null - error = null - added = null - } - - suspend fun verify(raw: String) { - if (verifying) return - verifying = true - error = null - try { - preview = onDecode(raw.trim()) - } catch (t: Throwable) { - error = t.message ?: t.toString() - } finally { - verifying = false - } - } - - suspend fun add(raw: String) { - if (adding || added != null) return - adding = true - error = null - try { - added = onAdd(raw.trim()) - } catch (t: Throwable) { - error = t.message ?: t.toString() - } finally { - adding = false - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt deleted file mode 100644 index a519bb7..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt +++ /dev/null @@ -1,314 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import android.content.ClipData -import android.content.ClipDescription -import android.os.Build -import android.os.PersistableBundle -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.CircularProgressIndicator -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.ClipEntry -import androidx.compose.ui.platform.LocalClipboard -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwAlertBanner -import com.siriusdevops.onionwire.ui.components.OwAlertVariant -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwDivider -import com.siriusdevops.onionwire.ui.components.OwQrCode -import com.siriusdevops.onionwire.ui.components.OwTopBar -import kotlinx.coroutines.launch -import uniffi.onionwire_sdk.FriendInfo -import uniffi.onionwire_sdk.InviteInfo - -/** - * Your invite, as a code and as text. - * - * The invite is the one artifact that leaves the device on purpose, so this - * screen is deliberately plain about what it is: one person, one trusted channel, - * nothing published. Both the QR and the text are here because a person pointing - * a camera at a screen and a person pasting into a chat client are different - * people, and neither is wrong. - */ -@Composable -fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) { - var invite by remember { mutableStateOf(null) } - var error by remember { mutableStateOf(null) } - var copied by remember { mutableStateOf(false) } - val clipboard = LocalClipboard.current - val scope = rememberCoroutineScope() - - LaunchedEffect(Unit) { - runCatching { ownerInvite() } - .onSuccess { invite = it } - .onFailure { error = it.message ?: it.toString() } - } - - Scaffold( - topBar = { OwTopBar(title = "Your invite", onBack = onBack) }, - // The root applies systemBars + IME itself (see `screenContentInsets`), - // so Scaffold must not also pad for the navigation bar. - contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, - ) { pad -> - Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets() - .verticalScroll(rememberScrollState()) - .padding(horizontal = 16.dp), - ) { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Not published anywhere", - description = "Hand this to one person over a channel you already " + - "trust. There is no directory and no lookup — that is the point.", - ) - Spacer(Modifier.height(16.dp)) - - when { - error != null -> OwAlertBanner( - variant = OwAlertVariant.Error, - title = "Could not read your invite", - description = error, - ) - - invite == null -> Row( - Modifier.fillMaxWidth().padding(vertical = 32.dp), - horizontalArrangement = Arrangement.Center, - ) { CircularProgressIndicator(color = OwColors.Accent) } - - else -> { - val payload = invite!! - Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) { - OwQrCode(payload = payload, size = 220.dp) - } - Spacer(Modifier.height(16.dp)) - // Four lines, ellipsised: the payload is ~1 KB, and a card - // that grows to fill the screen pushes Copy and Done out of - // reach — the copyable text is a fallback for the QR, not - // the main event. `Copy invite` always carries the whole - // string. - OwCard(Modifier.fillMaxWidth(), padding = 12.dp) { - Text( - payload, - style = MonoStyle.copy(color = OwColors.TextSecondary), - textAlign = TextAlign.Start, - maxLines = 4, - overflow = TextOverflow.Ellipsis, - ) - } - Spacer(Modifier.height(12.dp)) - Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) { - OwButton( - text = if (copied) "Copied" else "Copy invite", - onClick = { - scope.launch { - val clip = ClipData.newPlainText("onionwire invite", payload) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - clip.description.extras = PersistableBundle().apply { - putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true) - } - } - clipboard.setClipEntry(ClipEntry(clip)) - copied = true - } - }, - leadingIconRes = R.drawable.ic_ow_copy, - ) - OwButton( - text = "Done", - variant = OwButtonVariant.Outline, - onClick = onBack, - ) - } - Spacer(Modifier.height(24.dp)) - OwCard(Modifier.fillMaxWidth()) { - Text( - "What is in it", - style = MaterialTheme.typography.titleSmall, - color = OwColors.TextPrimary, - ) - Spacer(Modifier.height(8.dp)) - InviteField("k", "ed25519 identity pubkey — who you are") - InviteField("o", "current onion locator — where you are now") - InviteField("spk", "x25519 signed prekey — session start material") - InviteField("sig", "signature over k‖o‖spk — reject if it fails") - Spacer(Modifier.height(10.dp)) - OwDivider() - Spacer(Modifier.height(10.dp)) - Text( - "The onion in here goes stale when you rotate. The key does " + - "not. If you re-share later, the same k updates their entry — " + - "it never creates a second friend.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - } - Spacer(Modifier.height(24.dp)) - } - } - } - } -} - -@Composable -private fun InviteField(key: String, meaning: String) { - Row(Modifier.padding(vertical = 2.dp), verticalAlignment = Alignment.CenterVertically) { - Text( - key, - style = MonoStyle.copy(color = OwColors.Accent), - modifier = Modifier.padding(end = 10.dp), - ) - Label(meaning) - } -} - -/** - * Paste someone else's invite. - * - * Verification is a separate, explicit step from adding: the preview shows who - * they are and where they are reachable *before* anything is written to the - * roster, because a mistyped or swapped invite is the one thing a human can - * still catch. - */ -@Composable -fun PasteInviteScreen( - onDecode: suspend (String) -> InviteInfo, - onAdd: suspend (String) -> FriendInfo, - onBack: () -> Unit, -) { - var raw by remember { mutableStateOf("") } - val flow = remember { InviteAddFlow(onDecode, onAdd) } - val scope = rememberCoroutineScope() - val preview = flow.preview - val error = flow.error - val added = flow.added - val verifying = flow.verifying - val adding = flow.adding - - Scaffold( - topBar = { OwTopBar(title = "Add contact", onBack = onBack) }, - // Same inset handoff as the chat composer: with the keyboard up, the - // Verify / Approve buttons under the invite field must still be - // reachable by scrolling, not by dismissing the keyboard. - contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, - ) { pad -> - Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets() - .verticalScroll(rememberScrollState()) - .padding(horizontal = 16.dp), - ) { - Spacer(Modifier.height(8.dp)) - OutlinedTextField( - value = raw, - onValueChange = { - raw = it - flow.clear() - }, - label = { Text("onionwire:v2:…") }, - minLines = 4, - shape = RoundedCornerShape(OwRadius.Control), - modifier = Modifier.fillMaxWidth(), - ) - Spacer(Modifier.height(12.dp)) - - Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) { - OwButton( - text = "Verify", - enabled = raw.isNotBlank() && !verifying && !adding, - onClick = { scope.launch { flow.verify(raw) } }, - ) - if (added != null) { - OwButton(text = "Done", variant = OwButtonVariant.Outline, onClick = onBack) - } - } - - Spacer(Modifier.height(16.dp)) - - error?.let { - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "That invite was not accepted", - description = "$it — unsigned or tampered invites are rejected " + - "here, before anything is stored.", - ) - Spacer(Modifier.height(12.dp)) - } - - preview?.let { p -> - OwCard(Modifier.fillMaxWidth()) { - Label("THEY ARE") - Spacer(Modifier.height(2.dp)) - Mono(shortId(p.pubkeyHex, head = 12, tail = 8)) - Spacer(Modifier.height(6.dp)) - Text( - "Compare this fingerprint with them over a second channel " + - "before you trust it.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(10.dp)) - OwDivider() - Spacer(Modifier.height(10.dp)) - Label("REACHABLE AT") - Spacer(Modifier.height(2.dp)) - Mono(shortOnion(p.onion)) - } - Spacer(Modifier.height(12.dp)) - OwButton( - text = "Approve & add", - enabled = !adding && added == null, - onClick = { scope.launch { flow.add(raw) } }, - leadingIconRes = R.drawable.ic_ow_add, - ) - } - - added?.let { f -> - Spacer(Modifier.height(16.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Added ${f.petname ?: shortId(f.fingerprint)}", - description = "If that key was already in your roster, only the " + - "locator was updated. One key is always one friend.", - ) - } - Spacer(Modifier.height(24.dp)) - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/MessageDelivery.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/MessageDelivery.kt deleted file mode 100644 index e82bb37..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/MessageDelivery.kt +++ /dev/null @@ -1,181 +0,0 @@ -package com.siriusdevops.onionwire.ui - -/** - * Delivery state of one outgoing chat row. - * - * The states are the core's own — `Queued` / `Sending` / `Sent` / `Failed` - * (`src/store.rs::OutboxStatus`), surfaced verbatim over UniFFI as - * `ChatMessage.delivery` (`crates/onionwire-sdk/src/lib.rs::delivery_of`, fed by - * `Node::outbox_status_of_message`). There is no parallel model here and nothing - * is inferred from a timeout: if the state is not in that string it is not - * rendered. - * - * [testTag] and [contentDescription] are the assertable handles: the Composable - * applies exactly these values, and `MessageDeliveryTest` asserts on them, so a - * change to the marker without a change to the announcement fails a test. - * A screen reader must never be left hearing a bare glyph like "clock" — that is - * why every state carries a sentence. - */ -sealed interface Delivery { - - /** Stable handle for Compose semantics and tests. */ - val testTag: String - - /** What a screen reader announces. Always a sentence, never a glyph. */ - val contentDescription: String - - /** Marker drawn next to the message body. */ - val glyph: String - - /** Short text drawn after the glyph. Empty for a wordless state. */ - val label: String - - /** The frame reached the peer's onion during the send call. */ - data object Sent : Delivery { - override val testTag: String = "delivery-sent" - override val contentDescription: String = "Delivered" - override val glyph: String = "✓✓" - override val label: String = "" - } - - /** - * The peer's onion was unreachable: the message is in the local outbox and - * the retry worker will dial again with backoff. Local-only — not delivered. - */ - data object Queued : Delivery { - override val testTag: String = "delivery-queued" - override val contentDescription: String = - "Queued, not delivered yet: retrying their onion" - override val glyph: String = "◷" - override val label: String = "queued" - } - - /** The worker has a delivery attempt in flight right now. */ - data object Sending : Delivery { - override val testTag: String = "delivery-sending" - override val contentDescription: String = "Sending" - override val glyph: String = "»" - override val label: String = "sending" - } - - /** Terminal: retries are exhausted or the failure cannot be retried. */ - data class Failed(val reason: String) : Delivery { - override val testTag: String = "delivery-failed" - override val contentDescription: String = "Failed: $reason" - override val glyph: String = "✗" - override val label: String = "failed: $reason" - } - - /** `"◷ queued"`, `"✓✓"`, `"✗ failed: no route"` — the row's marker text. */ - val marker: String - get() = if (label.isEmpty()) glyph else "$glyph $label" -} - -/** Longest short-form failure reason rendered in a chat row. Mirrors - * `src/tui.rs::FAIL_REASON_BUDGET` so both clients cut the same way. */ -const val FAIL_REASON_BUDGET: Int = 24 - -private val STRIPPED: CharRange = '\u0000'..'\u001f' -private val STRIPPED_C1: CharRange = '\u007f'..'\u009f' - -/** C0/C1 controls and bidi/format marks — mirrors `src/sanitize.rs`. */ -internal fun isControlOrBidi(c: Char): Boolean = - c in STRIPPED || c in STRIPPED_C1 || - c in '\u202a'..'\u202e' || c in '\u2066'..'\u2069' || - c == '\u200e' || c == '\u200f' || c == '\u200b' || c == '\u200c' - -/** - * Transport failure text, short form: sanitized, tail of the `a: b: c` chain, - * capped at [budget] cells so one peer's error cannot blow out the row. - * Mirrors `src/tui.rs::short_send_reason`. - */ -fun shortSendReason(why: String, budget: Int = FAIL_REASON_BUDGET): String { - val clean = why.filterNot(::isControlOrBidi) - val tail = clean.split(": ").lastOrNull().orEmpty().trim() - val text = tail.ifEmpty { clean.trim() } - if (text.length <= budget) return text - if (budget <= 1) return "…".take(budget) - return text.take(budget - 1) + "…" -} - -/** - * Maps one history row onto a [Delivery], or `null` for anything that is not an - * outgoing message. - * - * [delivery] is `ChatMessage.delivery`: `"sent"`, `"queued"`, `"sending"`, - * `"failed: "`, or `null` for inbound rows. The SDK already resolves an - * outgoing row with no outbox row to `"sent"` (it was accepted on the first - * attempt), so a *missing* value on an outgoing row means the core did not - * confirm anything — and that is reported as [Delivery.Queued], never as - * delivered. Same rule for a status this build does not recognise: the only - * direction that cannot lie is "not confirmed delivered yet". - */ -fun parseDelivery(direction: String, delivery: String?): Delivery? { - if (direction != "out") return null - return when (val raw = delivery?.trim().orEmpty()) { - "" -> Delivery.Queued - "sent" -> Delivery.Sent - "sending" -> Delivery.Sending - "queued" -> Delivery.Queued - else -> - if (raw.startsWith("failed")) { - val why = raw.substringAfter(':', "").trim().ifEmpty { "unknown" } - Delivery.Failed(shortSendReason(why)) - } else { - Delivery.Queued - } - } -} - -/** - * Chat-level delivery summary derived from the rendered rows. - * - * 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, - val failed: Int = 0, - val firstError: String? = null, -) { - /** Footer note, or `null` when nothing is outstanding. */ - val note: String? - get() { - val reason = shortSendReason(firstError ?: "unknown") - return when { - queued == 0 && failed == 0 -> null - failed == 0 -> "$queued queued" - queued == 0 && failed == 1 -> "send failed: $reason" - queued == 0 -> "send failed: $reason ($failed failed)" - else -> "$queued queued, send failed: $reason" - } - } - - /** `true` when at least one send has terminated as failed. */ - val hasFailures: Boolean get() = failed > 0 -} - -/** Summarizes the rows currently on screen. */ -fun outboxSummary(deliveries: Iterable): OutboxSummary { - var queued = 0 - var failed = 0 - var firstError: String? = null - for (d in deliveries) { - when (d) { - null, Delivery.Sent -> Unit - - is Delivery.Failed -> { - failed++ - if (firstError == null) firstError = d.reason - } - - Delivery.Queued, Delivery.Sending -> queued++ - } - } - return OutboxSummary(queued = queued, failed = failed, firstError = firstError) -} \ No newline at end of file diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/OutboxDetail.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/OutboxDetail.kt deleted file mode 100644 index 4940cfa..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/OutboxDetail.kt +++ /dev/null @@ -1,141 +0,0 @@ -package com.siriusdevops.onionwire.ui - -/** - * Why a chat row is still queued, read from the SDK's outbox rows - * (`Wire.outbox(pubkeyHex)` → `OutboxRow { messageId, status, attempts, - * nextAttemptAt, lastError }`). - * - * [Delivery] answers *what* state a row is in; this file answers *how far along* - * it is — `queued (try 3/8, retry 45s)` — from the store's own counters, never - * from a time the app invented. Mirrors `src/tui.rs::retry_in_text` / - * `delivery_tag` so both clients word the same state the same way. - * - * Nothing here is Android-specific: the join and the wording are pure functions - * so `OutboxDetailTest` can assert them on the JVM without a device or the - * native binding. - */ - -/** - * Next-attempt age for a queued row, from the absolute `next_attempt_at` the - * store holds. Mirrors `src/tui.rs::retry_in_text`: - * `<= 0` → `retry now`; `< 60` → `retry {n}s`; else → `retry {ceil-minutes}m`. - */ -fun retryInText(nextInSecs: Long): String = when { - nextInSecs <= 0L -> "retry now" - nextInSecs < 60L -> "retry ${nextInSecs}s" - else -> "retry ${(nextInSecs + 59L) / 60L}m" -} - -/** - * The outbox row's own numbers for one queued chat row. - * - * Only `"queued"` rows produce one: a terminal `"failed"` row keeps the last - * time it was *scheduled* for, so rendering it as a countdown would be a lie — - * a failed row is rendered from [Delivery.Failed] alone. `"sending"` has an - * attempt in flight and no next-attempt time worth showing, matching the TUI's - * bare `sending` tag. - */ -data class QueuedRowDetail( - val attempts: UInt, - val maxAttempts: UInt, - val nextInSecs: Long, -) { - /** `queued (try 3/8, retry 45s)` — the row text, mirroring the TUI. */ - val text: String = "queued (try $attempts/$maxAttempts, ${retryInText(nextInSecs)})" - - /** - * `try 3/8, retry 45s` — the same numbers without the state word, for a - * screen reader that has already heard "Queued, not delivered yet". - */ - val announcement: String = "try $attempts/$maxAttempts, ${retryInText(nextInSecs)}" -} - -/** One SDK `ChatMessage`, narrowed to the fields the join reads. */ -data class ChatRowInput(val direction: String, val delivery: String?) - -/** One SDK `OutboxRow`, narrowed to the fields the join reads. */ -data class OutboxRowInput( - val messageId: Long, - val status: String, - val attempts: UInt, - val nextAttemptAt: Long, -) - -/** The store's own three pending encodings, trimmed and lowercased. */ -private fun outboxKind(status: String): String? = when (val s = status.trim().lowercase()) { - "queued", "sending", "failed" -> s - else -> null -} - -/** The same kind, read off the status the SDK already resolved for the message. */ -private fun deliveryKind(d: Delivery?): String? = when (d) { - Delivery.Queued -> "queued" - Delivery.Sending -> "sending" - is Delivery.Failed -> "failed" - Delivery.Sent, null -> null -} - -/** - * The SDK's `OutboxRow.message_id` is `messages.id` — the key the chat list is - * ordered by. The SDK's `ChatMessage` does not carry that id yet, so this join - * is positional: `messages()` is `ORDER BY m.id` and the outbox rows are one - * per pending send, so the *n*th pending chat row owns the *n*th outbox row - * (rows are sorted by `messageId` to make that explicit rather than trusting the - * core's row order). - * - * A positional join is only allowed to speak when it can prove itself: if the - * counts disagree, if a row carries a status this build does not know, or if a - * row's status does not match the status the SDK already resolved for the - * message in that slot, *every* detail is dropped and the rows fall back to the - * flat `queued` / `sending` / `failed` markers. Wrong numbers are worse than - * none. (`ChatMessage.id` would remove the positional part entirely; tracked - * as follow-up work.) - * - * Returns one entry per input row, `null` wherever there is nothing to add. - */ -fun outboxDetails( - rows: List, - outbox: List, - maxAttempts: UInt, - now: Long, -): List { - val none: List = List(rows.size) { null } - - val pending = rows.indices.filter { - deliveryKind(parseDelivery(rows[it].direction, rows[it].delivery)) != null - } - val ordered = outbox.sortedBy { it.messageId } - if (pending.size != ordered.size) return none - - val details = arrayOfNulls(rows.size) - for ((slot, index) in pending.withIndex()) { - val row = ordered[slot] - val kind = outboxKind(row.status) ?: return none - if (kind != deliveryKind(parseDelivery(rows[index].direction, rows[index].delivery))) { - return none - } - if (kind == "queued") { - details[index] = QueuedRowDetail( - attempts = row.attempts, - maxAttempts = maxAttempts, - nextInSecs = row.nextAttemptAt - now, - ) - } - } - return details.toList() -} - -/** - * Marker text for one row: the outbox row's own numbers when the join landed, - * otherwise the flat state marker `MessageDelivery` already produced. - */ -fun deliveryMarkerText(d: Delivery, detail: QueuedRowDetail?): String = - if (detail == null) d.marker else "${d.glyph} ${detail.text}" - -/** - * What a screen reader announces for one row. The detail is appended to the - * sentence [Delivery] carries, never replaces it: a bare `try 3/8` is not a - * sentence. - */ -fun deliveryAnnouncement(d: Delivery, detail: QueuedRowDetail?): String = - if (detail == null) d.contentDescription else "${d.contentDescription} (${detail.announcement})" diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt deleted file mode 100644 index 5ef799d..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt +++ /dev/null @@ -1,453 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.Card -import androidx.compose.material3.CardDefaults -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.material3.TextButton -import androidx.compose.material3.TopAppBar -import androidx.compose.material3.TopAppBarDefaults -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.testTag -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwIconButton -import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.siriusdevops.onionwire.WireViewModel -import kotlinx.coroutines.launch -import uniffi.onionwire_sdk.checkAddress - -/** - * This identity's own profile — nickname, bio, Monero receiving address — the - * phone's half of the TUI's `/profile`. - * - * The screen is a thin shell over three SDK calls (`self_profile`, - * `set_self_profile`, `push_self_profile`) and every decision it makes is a - * pure function at the bottom of this file, covered by `ProfileDraftTest` on - * the JVM. Nothing here invents policy the core does not have: - * - * - The write goes through the core's own validation (nickname ≤ 64 bytes, - * bio ≤ 512, no newlines, a non-empty address must pass `check_address`). - * The screen pre-checks the address so a typo is refused *before* the write, - * with the typed text still in the field, instead of being reported as a - * store error after it. - * - An **empty** address is a real, allowed value: it clears the profile - * address. It is labelled with its consequence, because with no profile - * address and no running wallet the core has nothing to hand a payer - * (`Node::wallet_receive_address`) and the invoice path fails. - * - The bio is carried, not owned: a save that did not touch the bio field - * writes back the value read from the store immediately before the write, so - * a bio set in the TUI cannot be blanked from the phone. - * - The push is per friend and one-shot, exactly like the TUI's `save_profile` - * (which pushes to the selected friend): a peer whose onion is down fails - * and nothing is queued. A push failure is *not* a save failure — the local - * write already happened — so the two are reported separately. - */ -@OptIn(ExperimentalMaterial3Api::class) -@Composable -fun ProfileScreen( - vm: WireViewModel, - onBack: () -> Unit, -) { - val friends by vm.friends.collectAsStateWithLifecycle() - val scope = rememberCoroutineScope() - - // What the store held when this screen opened, and the live edits. Both - // null until the first read lands; the save button is dead until then. - var loaded by remember { mutableStateOf(null) } - var draft by remember { mutableStateOf(null) } - var loadError by remember { mutableStateOf(null) } - var addressError by remember { mutableStateOf(null) } - var saveError by remember { mutableStateOf(null) } - var status by remember { mutableStateOf(null) } - var busy by remember { mutableStateOf(false) } - - LaunchedEffect(Unit) { - vm.selfProfile().fold( - onSuccess = { p -> - val d = ProfileDraft(p.displayName, p.bio, p.xmrAddr) - loaded = d - draft = d - }, - onFailure = { loadError = it.message ?: it.toString() }, - ) - } - - Scaffold( - contentWindowInsets = WindowInsets(0, 0, 0, 0), - topBar = { - TopAppBar( - title = { Text("Profile") }, - navigationIcon = { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - ) - }, - colors = TopAppBarDefaults.topAppBarColors( - containerColor = MaterialTheme.colorScheme.background, - ), - ) - }, - ) { pad -> - Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets() - .verticalScroll(rememberScrollState()), - ) { - val form = draft - if (form == null) { - Text( - loadError ?: "loading…", - style = MaterialTheme.typography.bodySmall, - color = if (loadError != null) { - MaterialTheme.colorScheme.error - } else { - MaterialTheme.colorScheme.onSurfaceVariant - }, - modifier = Modifier - .padding(12.dp) - .testTag("profile-load-error"), - ) - return@Column - } - - Card( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 12.dp, vertical = 8.dp), - colors = CardDefaults.cardColors( - containerColor = MaterialTheme.colorScheme.surfaceVariant, - ), - ) { - Column(Modifier.padding(12.dp)) { - Text( - "Friends see this nickname and pay to this address.", - style = MaterialTheme.typography.bodySmall, - ) - Spacer(Modifier.height(4.dp)) - Text( - "Nothing is published anywhere: each friend gets it only when " + - "this is saved and sent to them.", - style = MaterialTheme.typography.labelSmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - } - } - - OutlinedTextField( - value = form.nickname, - onValueChange = { draft = form.copy(nickname = it) }, - singleLine = true, - label = { Text("nickname") }, - supportingText = { - Text( - "What friends call you. Empty is allowed — they fall back to " + - "your fingerprint.", - style = MaterialTheme.typography.labelSmall, - ) - }, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 12.dp) - .testTag("profile-nickname"), - ) - Spacer(Modifier.height(8.dp)) - - OutlinedTextField( - value = form.bio, - onValueChange = { draft = form.copy(bio = it) }, - singleLine = true, - label = { Text("bio") }, - supportingText = { - Text( - "Kept when you save without touching it, including one set in " + - "the TUI.", - style = MaterialTheme.typography.labelSmall, - ) - }, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 12.dp) - .testTag("profile-bio"), - ) - Spacer(Modifier.height(8.dp)) - - OutlinedTextField( - value = form.address, - onValueChange = { - draft = form.copy(address = it) - addressError = null - }, - singleLine = true, - isError = addressError != null, - label = { Text("Monero address") }, - supportingText = { - Text( - // The consequence, on the screen, before a payment fails: - // `Node::wallet_receive_address` uses the wallet process's - // subaddress while it is up and this address otherwise, - // and with neither there is nothing to be paid to. - profileAddressNotice(form.address), - style = MaterialTheme.typography.labelSmall, - ) - }, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 12.dp) - .testTag("profile-address"), - ) - addressError?.let { - Text( - it, - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.error, - modifier = Modifier - .padding(horizontal = 12.dp, vertical = 4.dp) - .testTag("profile-address-error"), - ) - } - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(12.dp), - horizontalArrangement = Arrangement.End, - ) { - OwButton( - text = if (busy) "Saving…" else "Save", - onClick = { - addressError = null - saveError = null - status = null - val clean = form.normalized() - // The address check first: a typo must be refused before - // the write, and the field keeps exactly what was typed. - val problem = profileAddressProblem(clean.address) { addr -> - runCatching { checkAddress(addr) } - } - if (problem != null) { - addressError = problem - return@OwButton - } - scope.launch { - busy = true - try { - // Read the stored profile again for the bio - // alone: a bio edited elsewhere since this - // screen loaded must not be blanked by a save - // that never touched the field. - val storedBio = vm.selfProfile().getOrNull()?.bio - val bio = bioToWrite( - draftBio = clean.bio, - loadedBio = loaded?.bio.orEmpty(), - storedBio = storedBio ?: clean.bio, - ) - vm.setSelfProfile(clean.nickname, bio, clean.address).fold( - onSuccess = { - // Every friend in the roster, like the - // TUI pushes on save. One-shot each: a - // peer that is down is a failure for - // that peer, never a save failure. - val outcomes = friends.map { f -> - ProfilePushOutcome( - label = friendLabel(f.petname, f.fingerprint), - error = vm.pushSelfProfile(f.pubkeyHex) - .exceptionOrNull() - ?.let { it.message ?: it.toString() }, - ) - } - status = profileStatusLine(outcomes) - // Re-read so the form matches the store - // and the save button goes back to dead. - vm.selfProfile().onSuccess { p -> - val d = ProfileDraft(p.displayName, p.bio, p.xmrAddr) - loaded = d - draft = d - } - }, - onFailure = { saveError = it.message ?: it.toString() }, - ) - } finally { - busy = false - } - } - }, - enabled = !busy && profileSaveEnabled(loaded, form), - modifier = Modifier.testTag("profile-save"), - ) - } - - status?.let { - Text( - it, - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.primary, - modifier = Modifier - .padding(horizontal = 12.dp, vertical = 4.dp) - .testTag("profile-status"), - ) - } - saveError?.let { - Text( - it, - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.error, - modifier = Modifier - .padding(horizontal = 12.dp, vertical = 4.dp) - .testTag("profile-save-error"), - ) - } - Spacer(Modifier.height(12.dp)) - } - } -} - -// --- the whole decision surface, pure --------------------------------------- - -/** - * The three fields this screen edits, as they sit on screen. - * - * A local mirror of the SDK's `SelfProfile`, deliberately: the rules below are - * JVM-testable without UniFFI, and a `data class` gives the dirty check an - * equality that is the fields themselves rather than an identity. - */ -internal data class ProfileDraft( - val nickname: String = "", - val bio: String = "", - val address: String = "", -) - -/** One friend's push outcome: the label the roster shows, and the failure if any. */ -internal data class ProfilePushOutcome( - val label: String, - val error: String? = null, -) - -/** - * Edge whitespace out of every field. - * - * A paste from a clipboard or a soft keyboard's autocorrect habitually carries - * leading/trailing spaces, and none of the three fields can mean anything with - * them: the core refuses a nickname or address carrying a newline, and - * `check_address` is a base58 decode that fails on a stray space. Interior - * whitespace is untouched — the user may well want it in a bio. - */ -internal fun ProfileDraft.normalized(): ProfileDraft = copy( - nickname = nickname.trim(), - bio = bio.trim(), - address = address.trim(), -) - -/** - * The save button's rule. - * - * Dead until the first read lands (`loaded == null`), dead while the form is - * byte-identical to what was loaded, live as soon as it differs. Comparison is - * on the normalised forms, so typing a trailing space into a field does not - * offer a save that would write the same value back. - * - * An **empty nickname is allowed**: the core accepts it (it only bounds the - * length and forbids newlines), the TUI's `/profile` accepts it, and the roster - * already renders a friend with no nickname as their fingerprint. Clearing a - * nickname is therefore a real edit that must be saveable. - */ -internal fun profileSaveEnabled(loaded: ProfileDraft?, draft: ProfileDraft): Boolean = - loaded != null && draft.normalized() != loaded.normalized() - -/** - * Why the typed address cannot be saved, or `null` when it can. - * - * Empty is *allowed* and returns `null` without calling [check] at all — it - * clears the profile address, which the core permits. A non-empty address is - * handed to [check] (`uniffi.onionwire_sdk.checkAddress` in production) and its - * message is the reason shown, so the words match the core's own. - */ -internal fun profileAddressProblem(address: String, check: (String) -> Result): String? { - val trimmed = address.trim() - if (trimmed.isEmpty()) return null - return check(trimmed).exceptionOrNull()?.let { it.message ?: it.toString() } -} - -/** - * The bio that actually gets written. - * - * The field wins only when it differs from what was loaded — i.e. the user - * edited it. Otherwise the value read from the store immediately before the - * write is passed through unchanged, which is what keeps a bio set in the TUI - * alive through a phone save that only changed the nickname. - */ -internal fun bioToWrite(draftBio: String, loadedBio: String, storedBio: String): String = - if (draftBio.trim() != loadedBio.trim()) draftBio.trim() else storedBio - -/** The label the roster would show for a friend: petname, else the short id. */ -internal fun friendLabel(petname: String?, fingerprint: String): String = - petname?.takeIf { it.isNotBlank() } ?: shortId(fingerprint) - -/** - * The one line under the Save button, in the TUI's shape. - * - * `src/tui.rs` `save_profile` reports `profile saved · sent` on a clean push - * and `profile saved` with no friends; here the count and the per-friend - * failures are spelled out, because the phone pushes to **every** friend and - * "some of them failed" has to name which. - */ -internal fun profileStatusLine(outcomes: List): String { - if (outcomes.isEmpty()) return PROFILE_SAVED - val failed = outcomes.filter { it.error != null } - if (failed.isEmpty()) { - return "$PROFILE_SAVED · sent to ${friendCount(outcomes.size)}" - } - val sent = outcomes.size - failed.size - val detail = failed.joinToString("; ") { "${it.label}: ${it.error}" } - return "$PROFILE_SAVED · sent to $sent of ${friendCount(outcomes.size)} · failed: $detail" -} - -private fun friendCount(n: Int): String = if (n == 1) "1 friend" else "$n friends" - -/** The TUI's word for a local write that reached nobody. */ -internal const val PROFILE_SAVED: String = "profile saved" - -/** - * What an empty address means, stated where the address is typed. - * - * `Node::wallet_receive_address` answers with the wallet process's own subaddress - * while it is up, and this address otherwise; with neither, the invoice path - * fails outright. The user should read that here, not after a friend's payment - * bounces. - */ -internal fun profileAddressNotice(address: String): String = - if (address.trim().isEmpty()) { - "Empty is allowed, and it clears the profile address. Your receive address " + - "then comes from the running wallet — with no address " + - "here and no wallet running, nobody can send you an invoice." - } else { - "What friends pay to. Validated before it is saved; an invalid address is " + - "refused and nothing is written." - } \ No newline at end of file diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt deleted file mode 100644 index edfae7a..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt +++ /dev/null @@ -1,379 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import android.content.ClipData -import android.content.ClipDescription -import android.os.Build -import android.os.PersistableBundle -import android.widget.Toast -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.layout.widthIn -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.platform.ClipEntry -import androidx.compose.ui.platform.Clipboard -import androidx.compose.ui.platform.LocalClipboard -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Identicon -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonRow -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwConfirmDialog -import com.siriusdevops.onionwire.ui.components.OwDivider -import com.siriusdevops.onionwire.ui.components.OwIcon -import com.siriusdevops.onionwire.ui.components.OwIconButton -import com.siriusdevops.onionwire.ui.components.OwOverflowMenu -import com.siriusdevops.onionwire.ui.components.OwStatusDot -import com.siriusdevops.onionwire.ui.components.OwTopBar -import com.siriusdevops.onionwire.ui.components.TorStatusPill -import kotlinx.coroutines.launch -import uniffi.onionwire_sdk.FriendInfo - -/** - * Home: your identity, and the roster. - * - * Three things changed from the alpha build and they are deliberate: - * - * - The identity block is one compact bar. The old expandable card, the version - * and key-type footnote and the keep-alive paragraph are gone from here: the - * technical lines moved to Node & Settings, and reachability is a status row - * there too. A home screen does not explain the transport before it shows the - * people. - * - The five text-link actions are gone. Invite and Add are the two first-class - * actions (in the empty state, and in the bar); the rare and destructive ones - * live behind the overflow menu. - * - The empty state says what to do next, with the two buttons that do it. - * - * Behaviour is unchanged: every callback here is the ViewModel call the old - * screen made — this screen only decides where the entry points sit. - */ -@Composable -fun RosterScreen( - fingerprint: String, - friends: List, - invite: suspend () -> String, - onOpenChat: (FriendInfo) -> Unit, - onShare: () -> Unit, - onPaste: () -> Unit, - onRotate: () -> Unit, - onWipe: () -> Unit, - onOpenProfile: () -> Unit, - onLock: () -> Unit, - onOpenWallets: () -> Unit, -) { - val context = LocalContext.current - val clipboard = LocalClipboard.current - val scope = rememberCoroutineScope() - var confirmDeleteAll by remember { mutableStateOf(false) } - - Scaffold( - // The content root below consumes systemBars ∪ ime itself (see - // `screenContentInsets`), and the tab bar above this screen consumes the - // navigation-bar inset; zeroing the Scaffold's own insets is what keeps - // the list from being padded twice. - contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, - topBar = { - OwTopBar( - title = "OnionWire", - status = { TorStatusPill() }, - actions = { - OwIconButton( - iconRes = R.drawable.ic_ow_lock, - contentDescription = "Lock and stop the node", - onClick = onLock, - ) - OwOverflowMenu( - onOpenProfile = onOpenProfile, - onOpenWallets = onOpenWallets, - onRotate = onRotate, - onWipe = { confirmDeleteAll = true }, - ) - }, - ) - }, - ) { pad -> - Column(Modifier.padding(pad).fillMaxSize().screenContentInsets()) { - IdentityBar( - fingerprint = fingerprint, - onCopyInvite = { - scope.launch { - runCatching { invite() } - .onSuccess { payload -> - copyInvite(clipboard, payload) - Toast.makeText(context, "Invite address copied", Toast.LENGTH_SHORT).show() - } - .onFailure { - Toast.makeText(context, "Could not read the invite", Toast.LENGTH_SHORT).show() - } - } - }, - onShare = onShare, - ) - - Spacer(Modifier.height(12.dp)) - - if (friends.isEmpty()) { - EmptyRoster( - modifier = Modifier.weight(1f), - onPaste = onPaste, - onShare = onShare, - ) - } else { - LazyColumn(Modifier.weight(1f).fillMaxWidth()) { - items(friends, key = { it.pubkeyHex }) { f -> - FriendRow(f) { onOpenChat(f) } - OwDivider(Modifier.padding(horizontal = 16.dp)) - } - } - } - } - } - - if (confirmDeleteAll) { - OwConfirmDialog( - title = "Delete all message history?", - body = "Every message body on this device is deleted. Your identity, " + - "your friends and the pending queue are untouched.", - confirmationWord = "DELETE", - confirmLabel = "Delete history", - destructive = true, - onConfirm = { - confirmDeleteAll = false - onWipe() - }, - onDismiss = { confirmDeleteAll = false }, - ) - } -} - -/** - * Your identity, as one bar: identicon, label, truncated pubkey, then the two - * actions a person actually performs here — copy the invite, show it as a code. - */ -@Composable -private fun IdentityBar( - fingerprint: String, - onCopyInvite: () -> Unit, - onShare: () -> Unit, -) { - OwCard( - modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp), - padding = 12.dp, - ) { - Row(verticalAlignment = Alignment.CenterVertically) { - Identicon(seed = fingerprint, size = 40.dp) - Spacer(Modifier.width(12.dp)) - Column(Modifier.weight(1f)) { - Label("Your identity") - Spacer(Modifier.height(2.dp)) - Mono(shortId(fingerprint)) - } - OwIconButton( - iconRes = R.drawable.ic_ow_copy, - contentDescription = "Copy invite address", - onClick = onCopyInvite, - ) - Spacer(Modifier.width(8.dp)) - OwIconButton( - iconRes = R.drawable.ic_ow_qr, - contentDescription = "Show your invite", - onClick = onShare, - ) - } - } -} - -/** - * The empty roster. - * - * The honest sentence stays: invites are not discoverable, nothing is published. - * The two buttons are the two ways out of this state, in the order that helps — - * paste a peer's invite, or hand yours out. - */ -@Composable -private fun EmptyRoster( - modifier: Modifier = Modifier, - onPaste: () -> Unit, - onShare: () -> Unit, -) { - Column( - modifier = modifier.fillMaxWidth().padding(horizontal = 24.dp), - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Box( - Modifier - .width(64.dp) - .height(64.dp) - .clip(CircleShape) - .background(OwColors.Surface), - contentAlignment = Alignment.Center, - ) { - // Muted on purpose: the empty state is an invitation, not an alarm. - // The accent stays reserved for the one primary action below it. - OwIcon( - iconRes = R.drawable.ic_ow_shield, - contentDescription = null, - tint = OwColors.TextSecondary, - size = 30.dp, - ) - } - Spacer(Modifier.height(16.dp)) - Text( - "No contacts yet", - style = MaterialTheme.typography.titleMedium.copy(fontSize = 18.sp, lineHeight = 24.sp), - color = OwColors.TextPrimary, - ) - Spacer(Modifier.height(8.dp)) - Text( - "Share your invite over a channel you already trust, or paste a peer's " + - "invite to start an end-to-end encrypted chat. Invites are not " + - "discoverable — nothing is published.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - textAlign = TextAlign.Center, - modifier = Modifier.widthIn(max = 280.dp), - ) - Spacer(Modifier.height(20.dp)) - OwButtonRow(Modifier.widthIn(max = 320.dp)) { - OwButton( - text = "Add contact", - onClick = onPaste, - variant = OwButtonVariant.Primary, - modifier = Modifier.weight(1f), - leadingIconRes = R.drawable.ic_ow_add, - ) - OwButton( - text = "Share my invite", - onClick = onShare, - variant = OwButtonVariant.Secondary, - modifier = Modifier.weight(1f), - ) - } - } -} - -@Composable -private fun FriendRow(f: FriendInfo, onClick: () -> Unit) { - Row( - Modifier - .fillMaxWidth() - .clickable(onClick = onClick) - .padding(horizontal = 16.dp, vertical = 12.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - Column(Modifier.weight(1f)) { - Row(verticalAlignment = Alignment.CenterVertically) { - Text( - f.petname?.takeIf { it.isNotBlank() } ?: f.fingerprint, - style = MaterialTheme.typography.titleSmall, - color = OwColors.TextPrimary, - ) - if (!f.lastConnectOk) { - Spacer(Modifier.width(8.dp)) - OwStatusDot(OwColors.Warning) - Spacer(Modifier.width(6.dp)) - Text( - "locator stale", - style = MaterialTheme.typography.labelSmall, - color = OwColors.Warning, - ) - } - } - Spacer(Modifier.height(3.dp)) - Text( - shortId(f.fingerprint), - style = MonoStyle, - color = OwColors.TextSecondary, - ) - Text( - shortOnion(f.onion), - style = MonoStyle.copy(color = OwColors.TextMuted), - ) - } - Text("›", style = MaterialTheme.typography.titleMedium, color = OwColors.TextMuted) - } -} - -/** - * Clipboard handling for the invite. - * - * The invite is a locator plus a prekey: it is a secret-ish string that opens a - * conversation with you, so the clip is marked sensitive (API 33+) — it will not - * be previewed on the lock screen or indexed by the clipboard UI. Nothing here - * is logged, persisted, or drawn anywhere but the share sheet. - */ -private suspend fun copyInvite(clipboard: Clipboard, text: String) { - val clip = ClipData.newPlainText("onionwire invite", text) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - clip.description.extras = PersistableBundle().apply { - putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true) - } - } - clipboard.setClipEntry(ClipEntry(clip)) -} - -/** - * The compact stand-in for a long identity string: `head` characters, an - * ellipsis, then `tail` characters. Pure, so the roster's line and its unit test - * agree on what "short" means. - * - * A string no longer than the abbreviation is returned unchanged — the - * abbreviation must never grow a value, and a short value must never come back - * mangled. Kotlin strings are UTF-16, but these IDs are hex, so `take`/`takeLast` - * cannot split a surrogate pair here. - */ -fun shortId(id: String, head: Int = 6, tail: Int = 4): String { - if (id.length < head + tail + 1) return id - return id.take(head) + "…" + id.takeLast(tail) -} - -/** - * A v3 onion locator shortened for a roster row, with the `.onion` suffix kept - * visible: `abcdefghij…uvwxyz.onion`. - * - * The suffix is the part that tells a reader this is an onion address at all, so - * it is never the part that gets truncated. The full value lives on the profile - * and invite screens, and a v3 locator is never soft-wrapped — a wrapped address - * cannot be copied reliably. - */ -fun shortOnion(onion: String, head: Int = 10, tail: Int = 6): String { - val suffix = ".onion" - if (onion.isEmpty()) return onion - if (!onion.endsWith(suffix)) return onion - val body = onion.removeSuffix(suffix) - if (body.length <= head + tail + 1) return onion - return body.take(head) + "…" + body.takeLast(tail) + suffix -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt deleted file mode 100644 index b84dd11..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt +++ /dev/null @@ -1,165 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.CircularProgressIndicator -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.IconButton -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar -import androidx.compose.material3.TopAppBarDefaults -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwIconButton - -/** - * Rotating publishes a brand new onion service and hard-cuts the old one. - * - * It is a typed confirmation on purpose: it is not a single tap, and it is not - * hidden. Friends who are online get a signed `loc` update; friends who are - * offline cannot find you again until they re-scan your invite. Your identity - * key — and therefore your fingerprint — does not change. - */ -@OptIn(ExperimentalMaterial3Api::class) -@Composable -fun RotateScreen( - currentOnion: String, - onRotate: suspend () -> Pair, // notified to friends - onBack: () -> Unit, -) { - var typed by remember { mutableStateOf("") } - var busy by remember { mutableStateOf(false) } - var result by remember { mutableStateOf?>(null) } - var error by remember { mutableStateOf(null) } - - Scaffold( - topBar = { - TopAppBar( - title = { Text("Rotate onion") }, - navigationIcon = { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - ) - }, - colors = TopAppBarDefaults.topAppBarColors( - containerColor = MaterialTheme.colorScheme.background, - ), - ) - }, - // Root owns systemBars + IME (see `screenContentInsets`) so the confirm - // button under the passphrase field stays reachable with the keyboard up. - contentWindowInsets = WindowInsets(0, 0, 0, 0), - ) { pad -> - Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets() - .verticalScroll(rememberScrollState()) - .padding(16.dp), - ) { - Text("Rotate onion address?", style = MaterialTheme.typography.titleLarge) - Spacer(Modifier.height(12.dp)) - Text("Your identity key stays the same.", style = MaterialTheme.typography.bodyMedium) - Text( - "Online friends get a signed location update.", - style = MaterialTheme.typography.bodyMedium, - ) - Text( - "Offline friends CANNOT find you until they re-scan your invite.", - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.error, - ) - Spacer(Modifier.height(16.dp)) - Label("CURRENT") - Mono(currentOnion) - Spacer(Modifier.height(20.dp)) - - if (result == null) { - OutlinedTextField( - value = typed, - onValueChange = { typed = it }, - singleLine = true, - label = { Text("Type ROTATE to confirm") }, - modifier = Modifier.fillMaxWidth(), - ) - Spacer(Modifier.height(12.dp)) - Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { - OwButton( - text = "Rotate", - variant = OwButtonVariant.Destructive, - enabled = typed.trim().equals("ROTATE", ignoreCase = true) && - !busy, - onClick = { busy = true; error = null }, - ) - if (busy) CircularProgressIndicator() - } - } - - LaunchedEffect(busy) { - if (!busy) return@LaunchedEffect - runCatching { onRotate() } - .onSuccess { result = it } - .onFailure { error = it.message ?: it.toString() } - busy = false - } - - error?.let { - Spacer(Modifier.height(16.dp)) - Text( - it, - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.error, - ) - } - - result?.let { (notified, friends) -> - Spacer(Modifier.height(20.dp)) - Text( - "Rotated · notified $notified/$friends friends", - style = MaterialTheme.typography.titleSmall, - color = MaterialTheme.colorScheme.primary, - ) - Spacer(Modifier.height(8.dp)) - Text( - "The old onion service is already gone. Anyone still holding the old " + - "invite will fail to connect — that is the documented v1 behaviour, " + - "not a bug.", - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - Spacer(Modifier.height(16.dp)) - OwButton( - text = "Share the new invite", - variant = OwButtonVariant.Secondary, - onClick = onBack, - ) - } - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/SeedBackupGate.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/SeedBackupGate.kt deleted file mode 100644 index ee0c303..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/SeedBackupGate.kt +++ /dev/null @@ -1,113 +0,0 @@ -package com.siriusdevops.onionwire.ui - -/** - * Where the open wallet's key material came from. - * - * The distinction is the whole gate. A seed the user *supplied* (import) is a - * seed the user already has on paper, so that wallet is backed up from the - * start. A seed the app *generated* (create) has been read by nobody until it - * is put on screen, so that wallet starts unbacked and stays unbacked until the - * user proves it is written down. - */ -enum class WalletKeyOrigin { - Created, - Imported, -} - -/** - * The seed-backup gate: every decision the wallet screen makes about an - * unconfirmed seed, as pure Kotlin — no Compose, no Android, no prefs — so the - * rules are covered by `SeedBackupGateTest` on the JVM without a device. - * - * The gate exists because a seed shown once and then lost is an unrecoverable - * wallet: XMR received into a wallet whose 25 words were never written down - * cannot be spent or recovered by anyone, including this app. So the answer is - * not advisory — while it says the seed is unbacked, the wallet screen keeps a - * warning up and hides the receive address and its QR. - * - * The confirm word and its case-insensitivity mirror the TUI's own seed screen - * (`src/tui.rs`, `WalletSetup::CreateSeed`, which compares with - * `eq_ignore_ascii_case("SEEN")`) instead of inventing a second convention for - * the same wallet. - */ -object SeedBackupGate { - - /** The word that releases the block. The TUI's word, not a new one. */ - const val CONFIRM_WORD: String = "SEEN" - - /** - * True when [typed] releases the block. - * - * Trimmed and case-insensitive, so a soft keyboard's auto-capitalised `Seen` - * and a trailing space from a paste both count. Everything else — including - * the empty string — stays blocked. - */ - fun accepts(typed: String): Boolean = - typed.trim().equals(CONFIRM_WORD, ignoreCase = true) - - /** - * The flag right after a wallet is created or imported. - * - * A create always resets it: the wallet file is new, and the seed it was - * built from has never been read by anyone. - */ - fun afterWallet(origin: WalletKeyOrigin): Boolean = when (origin) { - WalletKeyOrigin.Created -> false - WalletKeyOrigin.Imported -> true - } - - /** - * The flag after one confirm step. - * - * Only a correct [typed] can flip it to `true`; a wrong word can never - * un-confirm a wallet that is already backed up. - */ - fun afterConfirm(typed: String, backedUp: Boolean): Boolean = - backedUp || accepts(typed) - - /** Done is dead until the word is right. */ - fun confirmEnabled(typed: String): Boolean = accepts(typed) - - /** - * The persistent strip is up while this install has an unconfirmed seed. - * - * [confirmed] is the stored flag, and it is nullable on purpose: - * - * - `false` — this install created a wallet and nobody has confirmed the - * seed. The wallet exists whether or not its balance reads, so the strip - * is up regardless. - * - `true` — confirmed, or imported. Nothing to say. - * - `null` — nothing stored: an install that predates this flag, or one - * that has never created or imported a wallet here. "We never asked" is - * not "the user wrote it down", but it is also not evidence that a wallet - * exists — so the strip waits for [walletReadable], the core's own proof - * that the child has a wallet open. - * - * Without that last distinction the strip would fire on every install that - * has configured a chain source but not yet created a wallet, which is - * exactly the state a first-run user is in. - */ - fun warningVisible(confirmed: Boolean?, walletReadable: Boolean): Boolean = when (confirmed) { - true -> false - false -> true - null -> walletReadable - } - - /** - * The receive address and its QR are shown only while there is no unbacked - * seed to worry about. Receiving into an unbacked wallet is the one mistake - * this gate exists to prevent, so the address is hidden rather than merely - * warned about. - */ - fun receiveAddressVisible(confirmed: Boolean?, walletReadable: Boolean): Boolean = - !warningVisible(confirmed, walletReadable) - - /** - * The strip's words. One source: the screen renders this verbatim, so the - * reason the address disappeared travels with the hiding. - */ - const val WARNING: String = - "seed not backed up. write down the 25 words before you receive anything — " + - "a wallet whose seed was never written down cannot be recovered. " + - "the receive address stays hidden until you do." -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/SettingsScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/SettingsScreen.kt deleted file mode 100644 index c5e5c68..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/SettingsScreen.kt +++ /dev/null @@ -1,215 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwConfirmDialog -import com.siriusdevops.onionwire.ui.components.OwDivider -import com.siriusdevops.onionwire.ui.components.OwIconButton -import com.siriusdevops.onionwire.ui.components.OwSectionTitle -import com.siriusdevops.onionwire.ui.components.OwTopBar -import com.siriusdevops.onionwire.ui.components.TorStatusPill - -/** - * The third tab: everything that is not a conversation or a balance. - * - * This is where the alpha build's honest-but-noisy bits went — the SDK line, the - * keep-alive paragraph, the identity rotation and the history wipe. They are not - * hidden; they are one tap away instead of on the screen a person opens twenty - * times a day. No behaviour lives here: every callback is a ViewModel call the - * old roster made. - */ -@Composable -fun SettingsScreen( - sdkVersion: String, - keepAliveNote: String?, - onOpenProfile: () -> Unit, - onOpenWallets: () -> Unit, - onRotate: () -> Unit, - onWipe: () -> Unit, - onLock: () -> Unit, -) { - var confirmDeleteAll by remember { mutableStateOf(false) } - - Scaffold( - contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, - topBar = { - OwTopBar( - title = "Node & Settings", - status = { TorStatusPill() }, - actions = { - OwIconButton( - iconRes = R.drawable.ic_ow_lock, - contentDescription = "Lock and stop the node", - onClick = onLock, - ) - }, - ) - }, - ) { pad -> - Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets() - .verticalScroll(rememberScrollState()) - .padding(horizontal = 16.dp), - ) { - Spacer(Modifier.height(8.dp)) - - OwCard(Modifier.fillMaxWidth()) { - Label("ACCOUNT") - Spacer(Modifier.height(4.dp)) - SettingsRow( - title = "Your profile", - subtitle = "Name, bio and Monero address", - onClick = onOpenProfile, - ) - OwDivider() - SettingsRow( - title = "Saved wallets", - subtitle = "Open a wallet file, or check its backup", - onClick = onOpenWallets, - ) - } - - Spacer(Modifier.height(12.dp)) - - OwCard(Modifier.fillMaxWidth()) { - Label("REACHABILITY") - Spacer(Modifier.height(6.dp)) - Text( - keepAliveNote ?: "Checking how this app is kept reachable…", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - } - - Spacer(Modifier.height(12.dp)) - - OwCard(Modifier.fillMaxWidth()) { - Label("SECURITY & DATA") - Spacer(Modifier.height(4.dp)) - SettingsRow( - title = "Rotate identity", - subtitle = "New onion address. Offline contacts must re-scan your invite.", - onClick = onRotate, - ) - OwDivider() - SettingsRow( - title = "Delete message history", - subtitle = "Removes every message body on this device. Identity and contacts stay.", - danger = true, - onClick = { confirmDeleteAll = true }, - ) - } - - Spacer(Modifier.height(12.dp)) - - OwCard(Modifier.fillMaxWidth()) { - OwSectionTitle("About") - Spacer(Modifier.height(8.dp)) - Row(verticalAlignment = Alignment.CenterVertically) { - Label("IDENTITY") - Spacer(Modifier.width(10.dp)) - Mono("ed25519") - } - Spacer(Modifier.height(4.dp)) - Row(verticalAlignment = Alignment.CenterVertically) { - Label("SDK") - Spacer(Modifier.width(10.dp)) - Mono(sdkVersion) - } - Spacer(Modifier.height(10.dp)) - Text( - "Tor and the chain node run in-process. The wallet is an RPC the app " + - "owns and starts itself.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - } - - Spacer(Modifier.height(24.dp)) - } - } - - if (confirmDeleteAll) { - OwConfirmDialog( - title = "Delete all message history?", - body = "Every message body on this device is deleted. Your identity, " + - "your friends and the pending queue are untouched.", - confirmationWord = "DELETE", - confirmLabel = "Delete history", - destructive = true, - onConfirm = { - confirmDeleteAll = false - onWipe() - }, - onDismiss = { confirmDeleteAll = false }, - ) - } -} - -@Composable -private fun SettingsRow( - title: String, - subtitle: String, - onClick: () -> Unit, - danger: Boolean = false, -) { - Row( - Modifier - .fillMaxWidth() - .clickable(onClick = onClick) - .padding(vertical = 12.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Column(Modifier.weight(1f)) { - Text( - title, - style = MaterialTheme.typography.titleSmall, - color = if (danger) OwColors.Danger else OwColors.TextPrimary, - ) - Spacer(Modifier.height(2.dp)) - Text( - subtitle, - style = MaterialTheme.typography.bodySmall, - color = if (danger) Color(0xCCFF5C5C) else OwColors.TextSecondary, - ) - } - Spacer(Modifier.width(12.dp)) - Text( - "›", - style = MaterialTheme.typography.titleMedium, - color = if (danger) OwColors.Danger else OwColors.TextMuted, - ) - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Theme.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Theme.kt deleted file mode 100644 index 7133a98..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Theme.kt +++ /dev/null @@ -1,149 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Typography -import androidx.compose.material3.darkColorScheme -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp - -/** - * OnionWire design tokens. - * - * One canvas, two surfaces, one accent. The palette is deliberately small: - * every screen used to invent its own pill and its own grey, which is what made - * the alpha build read as a debug harness. - * - * Typography rule — the reason this file carries a [MonoStyle]: monospace is - * reserved for cryptographic material and numbers (pubkeys, truncated onion - * locators, seeds, `host:port`, block heights). Chrome is sans. A screen that - * sets `fontFamily = FontFamily.Monospace` on a sentence is a bug. - */ -object OwColors { - /** App canvas. */ - val Canvas = Color(0xFF0A0C0E) - - /** Cards and elevated surfaces. */ - val Surface = Color(0xFF12161A) - - /** Inputs, secondary buttons, segmented-control track. */ - val SurfaceInteractive = Color(0xFF1C2228) - - /** The one border. 1dp, never a gradient. */ - val Border = Color(0xFF262E36) - - /** Primary brand / accent. Text on top of it is [Canvas], semibold. */ - val Accent = Color(0xFF2EE59D) - - val TextPrimary = Color(0xFFF3F5F7) - val TextSecondary = Color(0xFF9BA3AE) - val TextMuted = Color(0xFF5E6773) - - /** Success / connected is the accent — there is no second green. */ - val Success = Accent - - /** Warning / syncing. Text, 12% tint, 30% border. */ - val Warning = Color(0xFFF5A623) - val WarningTint = Color(0x1FF5A623) - val WarningBorder = Color(0x4DF5A623) - - /** Danger / error / destructive. */ - val Danger = Color(0xFFFF5C5C) - val DangerTint = Color(0x1FFF5C5C) - val DangerBorder = Color(0x4DFF5C5C) - - /** Info banner — the accent at banner tints, no third hue. */ - val InfoTint = Color(0x142EE59D) - val InfoBorder = Color(0x3D2EE59D) -} - -/** Geometry. Buttons and inputs are 12dp squircles, never 999dp pills. */ -object OwRadius { - /** Cards and the identity bar. */ - val Card = 16.dp - - /** Buttons, inputs, icon surfaces, segmented control. */ - val Control = 12.dp - - /** Small status badges and address chips only. */ - val Pill = 999.dp -} - -/** Fixed sizes from the spec. */ -object OwSize { - val Button = 48.dp - val ButtonCompact = 44.dp - val IconButton = 36.dp - val TabBar = 64.dp - val TabBarBorder = 1.dp - val ProgressTrack = 6.dp -} - -/** The only monospace style in the app. */ -val MonoStyle: TextStyle = TextStyle( - fontFamily = FontFamily.Monospace, - fontSize = 13.sp, - lineHeight = 18.sp, - color = OwColors.TextPrimary, -) - -private val OnionWireTypography = Typography( - // Chrome: system sans. No display face, no bundled grotesque. - displaySmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Bold, fontSize = 28.sp, lineHeight = 34.sp), - headlineSmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 22.sp, lineHeight = 28.sp), - titleLarge = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 20.sp, lineHeight = 26.sp), - titleMedium = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 16.sp, lineHeight = 22.sp), - titleSmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Medium, fontSize = 15.sp, lineHeight = 20.sp), - bodyLarge = TextStyle(fontFamily = FontFamily.SansSerif, fontSize = 16.sp, lineHeight = 24.sp), - bodyMedium = TextStyle(fontFamily = FontFamily.SansSerif, fontSize = 14.sp, lineHeight = 20.sp), - bodySmall = TextStyle(fontFamily = FontFamily.SansSerif, fontSize = 13.sp, lineHeight = 18.sp), - labelLarge = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 14.sp, lineHeight = 18.sp), - labelMedium = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Medium, fontSize = 12.sp, lineHeight = 16.sp), - labelSmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Medium, fontSize = 11.sp, lineHeight = 14.sp, letterSpacing = 0.6.sp), -) - -/** - * The scheme Material components (text fields, dialogs, dividers) still read - * from. New UI should take tokens from [OwColors] directly; `surfaceVariant` - * and `onSurfaceVariant` are mapped so untouched Material defaults do not fall - * back to purple. - */ -private val OnionWireColors = darkColorScheme( - primary = OwColors.Accent, - onPrimary = OwColors.Canvas, - primaryContainer = OwColors.SurfaceInteractive, - onPrimaryContainer = OwColors.TextPrimary, - secondary = OwColors.SurfaceInteractive, - onSecondary = OwColors.TextPrimary, - tertiary = OwColors.TextSecondary, - onTertiary = OwColors.Canvas, - background = OwColors.Canvas, - onBackground = OwColors.TextPrimary, - surface = OwColors.Canvas, - onSurface = OwColors.TextPrimary, - surfaceVariant = OwColors.Surface, - onSurfaceVariant = OwColors.TextSecondary, - surfaceContainer = OwColors.Surface, - surfaceContainerHigh = OwColors.SurfaceInteractive, - surfaceContainerLow = OwColors.Surface, - outline = OwColors.Border, - outlineVariant = OwColors.Border, - error = OwColors.Danger, - onError = OwColors.Canvas, - errorContainer = OwColors.DangerTint, - onErrorContainer = OwColors.Danger, - scrim = Color(0xCC000000), -) - -@Composable -fun OnionWireTheme(content: @Composable () -> Unit) { - MaterialTheme( - colorScheme = OnionWireColors, - typography = OnionWireTypography, - content = content, - ) -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/UnlockScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/UnlockScreen.kt deleted file mode 100644 index e4b87ab..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/UnlockScreen.kt +++ /dev/null @@ -1,258 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.safeDrawingPadding -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.text.KeyboardActions -import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.Button -import androidx.compose.material3.Checkbox -import androidx.compose.material3.CircularProgressIndicator -import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Text -import androidx.compose.material3.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalSoftwareKeyboardController -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.input.ImeAction -import androidx.compose.ui.text.input.KeyboardType -import androidx.compose.ui.text.input.PasswordVisualTransformation -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.Phase -import com.siriusdevops.onionwire.Unlock -import com.siriusdevops.onionwire.crypto.KeyBacking - -/** - * Lock screen. - * - * When [Unlock.OneTap] is set, the passphrase is already on disk wrapped by the - * Android Keystore key and the user taps once. Otherwise they type it — and - * they land here, with [Unlock.TypeIt.notice] explaining why, whenever the - * stored blob cannot be read (key invalidated, device reset, corrupt file). - * - * The typed passphrase lives in a plain `remember` (not `rememberSaveable`) and - * is cleared as soon as it is handed to the ViewModel: it never survives a - * config change and never gets written to the saved-instance-state bundle. - */ -@Composable -fun UnlockScreen( - phase: Phase, - unlock: Unlock, - onUnlock: (passphrase: String, remember: Boolean) -> Unit, - onUnlockStored: () -> Unit, - onForgetStored: () -> Unit, -) { - var pass by remember { mutableStateOf("") } - var storePassphrase by remember { mutableStateOf(true) } - // Only meaningful under OneTap: reveal the form without giving up the - // stored passphrase. - var typeInstead by remember { mutableStateOf(false) } - val keyboard = LocalSoftwareKeyboardController.current - - val oneTap = unlock as? Unlock.OneTap - val failed = phase is Phase.Failed - val showForm = oneTap == null || typeInstead || failed - // IME Done and Open share this. Done with no KeyboardActions used to - // dismiss the keyboard and never call unlock, so bootstrap never started. - fun submit() { - val handed = unlockSubmit(pass, storePassphrase) ?: return - pass = "" - keyboard?.hide() - onUnlock(handed.passphrase, handed.remember) - } - - Column( - modifier = Modifier - .fillMaxSize() - // This screen has no Scaffold, so its root owns every window inset: - // without this the keyboard covers the passphrase field's Open - // button and the status bar overlaps the title. - .safeDrawingPadding() - .verticalScroll(rememberScrollState()) - .padding(24.dp), - verticalArrangement = Arrangement.Center, - ) { - Text("ONIONWIRE", style = MaterialTheme.typography.headlineMedium) - Spacer(Modifier.height(4.dp)) - Text( - "Tor messenger. No server, no account. Your identity is a key.", - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - Spacer(Modifier.height(32.dp)) - - when (phase) { - is Phase.Opening -> { - Text("Publishing onion service…", style = MaterialTheme.typography.titleSmall) - Spacer(Modifier.height(8.dp)) - Text( - "First launch bootstraps Arti and uploads a v3 onion descriptor. " + - "On a cold network this takes minutes, not seconds. Keep the screen on.", - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - Spacer(Modifier.height(16.dp)) - CircularProgressIndicator() - } - - else -> { - if (oneTap != null && !failed) { - Text("Passphrase", style = MaterialTheme.typography.titleSmall) - Spacer(Modifier.height(8.dp)) - Text( - "Stored on this device, wrapped by an Android Keystore key " + - "(${backingLabel(oneTap.backing)}).", - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - Spacer(Modifier.height(20.dp)) - Button( - onClick = onUnlockStored, - modifier = Modifier.fillMaxWidth(), - ) { Text("Unlock") } - Spacer(Modifier.height(8.dp)) - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - TextButton(onClick = { typeInstead = true }) { - Text("Type it instead") - } - TextButton(onClick = onForgetStored) { - Text("Forget stored passphrase") - } - } - if (showForm) { - Spacer(Modifier.height(16.dp)) - HorizontalDivider() - Spacer(Modifier.height(16.dp)) - } - } - - if (showForm) { - if (unlock is Unlock.TypeIt && unlock.notice != null) { - Text( - unlock.notice, - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - Spacer(Modifier.height(16.dp)) - } - - OutlinedTextField( - value = pass, - onValueChange = { pass = it }, - singleLine = true, - visualTransformation = PasswordVisualTransformation(), - keyboardOptions = KeyboardOptions( - keyboardType = KeyboardType.Password, - imeAction = ImeAction.Go, - ), - keyboardActions = KeyboardActions( - onGo = { submit() }, - onDone = { submit() }, - ), - label = { Text("wraps the local message key") }, - modifier = Modifier.fillMaxWidth(), - ) - Spacer(Modifier.height(12.dp)) - Text( - "Empty is not a bypass — it fails closed. There is no recovery: " + - "lose this and the stored chat bodies stay unreadable.", - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - - Spacer(Modifier.height(4.dp)) - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.fillMaxWidth(), - ) { - Checkbox( - checked = storePassphrase, - onCheckedChange = { storePassphrase = it }, - ) - Text( - "Remember on this device (wrapped by the Android Keystore, " + - "no backup)", - style = MaterialTheme.typography.bodySmall, - ) - } - if (oneTap != null) { - Text( - "Typing and remembering replaces the stored passphrase.", - style = MaterialTheme.typography.labelSmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - } - - Spacer(Modifier.height(20.dp)) - Button( - onClick = { submit() }, - enabled = pass.isNotEmpty(), - modifier = Modifier.fillMaxWidth(), - ) { Text("Open") } - } - - if (failed) { - Spacer(Modifier.height(20.dp)) - Text( - "Failed to start", - style = MaterialTheme.typography.titleSmall, - color = MaterialTheme.colorScheme.error, - ) - Spacer(Modifier.height(4.dp)) - Text( - (phase as Phase.Failed).message, - style = MaterialTheme.typography.bodySmall, - fontFamily = FontFamily.Monospace, - color = MaterialTheme.colorScheme.error, - ) - Spacer(Modifier.height(8.dp)) - Text( - "OnionWire fails closed: if the onion service cannot publish, " + - "it does not fall back to a clearnet or C-tor path.", - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - } - } - } - - Spacer(Modifier.height(24.dp)) - Text( - "Permissions: internet, plus a foreground service and its notification so " + - "the onion stays reachable while the screen is off. No camera, contacts " + - "or storage.", - style = MaterialTheme.typography.labelSmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - } -} - -/** - * What the Keystore reported, verbatim. Never upgraded into a stronger claim: - * a software key says so. - */ -internal fun backingLabel(backing: KeyBacking): String = when (backing) { - KeyBacking.STRONGBOX -> "StrongBox" - KeyBacking.HARDWARE -> "TEE-backed" - KeyBacking.SOFTWARE -> "software key, NOT hardware-backed" - KeyBacking.UNKNOWN -> "backing not reported by this device" -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/UnlockSubmit.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/UnlockSubmit.kt deleted file mode 100644 index 7f1be30..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/UnlockSubmit.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.siriusdevops.onionwire.ui - -/** - * One submit for IME Done and the Open button. - * - * The IME action used to be `Done` with no [androidx.compose.foundation.text.KeyboardActions]: - * the keyboard closed and [com.siriusdevops.onionwire.WireViewModel.unlock] was never - * called, so bootstrap never started. Empty stays a no-op — the SDK fails closed - * on an empty passphrase, and we do not open the node for it. - */ -internal data class UnlockSubmit(val passphrase: String, val remember: Boolean) - -internal fun unlockSubmit(pass: String, remember: Boolean): UnlockSubmit? { - if (pass.isEmpty()) return null - return UnlockSubmit(passphrase = pass, remember = remember) -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt deleted file mode 100644 index 2f15281..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt +++ /dev/null @@ -1,850 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import com.siriusdevops.onionwire.wallet.NO_WALLET_RPC_MESSAGE -import com.siriusdevops.onionwire.wallet.WalletChildBinaryPaths -import java.io.File -import java.util.Locale - -/** - * One snapshot of the app-owned wallet process, as the wallet screen sees it. - * - * A plain mirror of the fields `WalletChildStatus` carries over UniFFI - * (`state`, `running`, `configured`, `chain_source`, `last_error`) — the same - * shape as `ChatRowInput` / `OutboxRowInput`, so this model and its tests stay - * on the JVM and never load the generated UniFFI types or JNA. - * - * `state` is the core's own word (`src/wallet_child.rs::WalletChildState`): - * `off` / `connecting` / `syncing` / `ready` / `exited`. Nothing here is - * inferred from a timeout, and nothing is invented: a state this build does not - * recognise is reported as unrecognised rather than folded into one that would - * read better. - */ -data class WalletChildInput( - val state: String, - /** A `monero-wallet-rpc` process is alive right now. */ - val running: Boolean, - /** A chain source is configured (anything but receive-only). */ - val configured: Boolean, - /** The core's label: `receive-only` / `local node` / `remote onion daemon` / `remote daemon`. */ - val chainSource: String, - /** - * The configured source runs the chain daemon **inside this app** (Cuprate) - * rather than spawning `monerod` or dialling a remote one — the core's - * `chain_in_process`. When true the line grows a node segment, because there - * is no separate daemon process for the state word to describe. - */ - val chainInProcess: Boolean = false, - /** - * This build carries `cuprate-daemon`, so the in-process node can actually - * start — the core's `node_available`. `false` means the option is stored but - * a start can only fail: say so before the user commits, never after. - */ - val nodeAvailable: Boolean = true, - /** - * The node's own word — the core's `node_state`: `off` / `starting` / - * `syncing` / `ready` / `exited`. **Empty** for every other chain source, and - * empty for an in-process source that has not been read yet. - */ - val nodeState: String = "", - /** - * Blocks the chain daemon had at the last probe — the core's `height`, from - * the wallet RPC or, when that RPC is refused, from the in-process daemon - * over loopback. `0` means unknown: never probed, the child is off/exited, or - * the probe failed. It is **not** caught up, and it is never a wallet-scan - * height. - * - * `ULong` because that is what UniFFI generates for the Rust `u64` (checked - * against `uniffi.onionwire_sdk.WalletChildStatus`, not assumed) — this model - * mirrors that record field for field. - */ - val height: ULong = 0uL, - /** Blocks the daemon was syncing towards — the core's `target_height`. `0` means none reported (also not caught up). */ - val targetHeight: ULong = 0uL, - val lastError: String? = null, -) - -/** - * What the wallet screen renders for one snapshot. - * - * The five states are the core's; there is no sixth "starting…". A child that - * was started and is gone is [Exited] — never [Off], and never [Ready]: the - * whole point of the control is that the user can see and drive the child. - * [Unread] is not a state of the child at all, it is the first - * `wallet_status()` read still in flight, and it is a word rather than a - * spinner so a stuck read is readable instead of merely animated. - * - * [testTag] and [contentDescription] are the assertable handles, matching - * `Delivery`: a screen reader gets a sentence, never a bare glyph or a bare - * word. - */ -sealed interface WalletChildPhase { - - /** Stable handle for Compose semantics and tests. */ - val testTag: String - - /** Word drawn on the status line. */ - val label: String - - /** What a screen reader announces. Always a sentence. */ - val contentDescription: String - - /** A child process is up. */ - val live: Boolean - - /** A started child is gone. Never `off`, never `ready`. */ - val dead: Boolean - - /** Nothing read yet. */ - data object Unread : WalletChildPhase { - override val testTag: String = "child-unread" - override val label: String = "reading…" - override val contentDescription: String = "Reading the wallet status" - override val live: Boolean = false - override val dead: Boolean = false - } - - /** No child has been started, or it was stopped. */ - data object Off : WalletChildPhase { - override val testTag: String = "child-off" - override val label: String = "off" - override val contentDescription: String = "The wallet is off" - override val live: Boolean = false - override val dead: Boolean = false - } - - /** The process exists; its wallet RPC has not answered yet. */ - data object Connecting : WalletChildPhase { - override val testTag: String = "child-connecting" - override val label: String = "connecting" - override val contentDescription: String = - "The wallet is starting; its RPC has not answered yet" - override val live: Boolean = true - override val dead: Boolean = false - } - - /** The wallet answered; the chain is behind the tip. */ - data object Syncing : WalletChildPhase { - override val testTag: String = "child-syncing" - override val label: String = "syncing" - override val contentDescription: String = - "The wallet is answering; the chain is not at the tip yet" - override val live: Boolean = true - override val dead: Boolean = false - } - - /** Wallet RPC answered and the chain is at the tip. */ - data object Ready : WalletChildPhase { - override val testTag: String = "child-ready" - override val label: String = "ready" - override val contentDescription: String = "The wallet is ready" - override val live: Boolean = true - override val dead: Boolean = false - } - - /** A started child has died. [reason] is the core's `last_error`, if any. */ - data class Exited(val reason: String?) : WalletChildPhase { - override val testTag: String = "child-exited" - override val label: String = "exited" - override val contentDescription: String = "The wallet process exited" - override val live: Boolean = false - override val dead: Boolean = true - } - - /** - * A state string this build does not know. Fail-closed: it is never - * reported as [Ready], so an unrecognised word cannot read as "wallet - * working". - */ - data class Unrecognised(val raw: String) : WalletChildPhase { - override val testTag: String = "child-unrecognised" - override val label: String = "unknown (${shortSendReason(raw, UNRECOGNISED_BUDGET)})" - override val contentDescription: String = - "The wallet reported a state this build does not know" - override val live: Boolean = false - override val dead: Boolean = false - } -} - -/** Cells of an unrecognised state word kept on the status line. */ -const val UNRECOGNISED_BUDGET: Int = 16 - -/** - * The in-process node's own word, for the chain sources that have one. - * - * Same fail-closed rule as [WalletChildPhase]: an unrecognised word is never - * [Ready]. [Absent] is not a node state at all — it is "this chain source has no - * node segment on the line", which is true of receive-only, a spawned `monerod` - * and a remote daemon, and also of an in-process source the core has not reported - * a node word for yet. Nothing is inferred to fill it in. - */ -sealed interface NodePhase { - - /** Stable handle for Compose semantics and tests. */ - val testTag: String - - /** Word drawn after `node`, or empty for [Absent]. */ - val label: String - - /** What a screen reader announces. Always a sentence. */ - val contentDescription: String - - /** No node segment: not an in-process chain source. */ - data object Absent : NodePhase { - override val testTag: String = "node-absent" - override val label: String = "" - override val contentDescription: String = "No on-device node" - } - - /** The app's own node is not running. */ - data object Off : NodePhase { - override val testTag: String = "node-off" - override val label: String = "off" - override val contentDescription: String = "The on-device node is off" - } - - /** The node is up; its loopback RPC has not answered yet. */ - data object Starting : NodePhase { - override val testTag: String = "node-starting" - override val label: String = "starting" - override val contentDescription: String = - "The on-device node is starting; its RPC has not answered yet" - } - - /** The node answers; its chain is not at the tip. */ - data object Syncing : NodePhase { - override val testTag: String = "node-syncing" - override val label: String = "syncing" - override val contentDescription: String = - "The on-device node is syncing; the chain is not at the tip yet" - } - - /** The node answers and its chain is at the tip. */ - data object Ready : NodePhase { - override val testTag: String = "node-ready" - override val label: String = "ready" - override val contentDescription: String = "The on-device node is ready" - } - - /** A started node is gone. */ - data object Exited : NodePhase { - override val testTag: String = "node-exited" - override val label: String = "exited" - override val contentDescription: String = "The on-device node exited" - } - - /** A node word this build does not know. Fail-closed: never [Ready]. */ - data class Unrecognised(val raw: String) : NodePhase { - override val testTag: String = "node-unrecognised" - override val label: String = "unknown (${shortSendReason(raw, UNRECOGNISED_BUDGET)})" - override val contentDescription: String = - "The on-device node reported a state this build does not know" - } -} - -/** - * Maps the core's `node_state` onto a [NodePhase]. - * - * [NodePhase.Absent] for a source that has no node (or no word yet); anything the - * five words do not cover is [NodePhase.Unrecognised] — never [NodePhase.Ready]. - */ -fun nodePhase(input: WalletChildInput?): NodePhase { - if (input == null || !input.chainInProcess) return NodePhase.Absent - return when (val state = input.nodeState.trim().lowercase()) { - "" -> NodePhase.Absent - "off" -> NodePhase.Off - "starting" -> NodePhase.Starting - "syncing" -> NodePhase.Syncing - "ready" -> NodePhase.Ready - "exited" -> NodePhase.Exited - else -> NodePhase.Unrecognised(state) - } -} - -/** - * Maps the core's `state` word onto a [WalletChildPhase]. Case- and - * whitespace-tolerant; anything else is [WalletChildPhase.Unrecognised]. - */ -fun walletChildPhase(input: WalletChildInput?): WalletChildPhase { - if (input == null) return WalletChildPhase.Unread - return when (val state = input.state.trim().lowercase()) { - "off" -> WalletChildPhase.Off - "connecting" -> WalletChildPhase.Connecting - "syncing" -> WalletChildPhase.Syncing - "ready" -> WalletChildPhase.Ready - "exited" -> WalletChildPhase.Exited(input.lastError?.takeIf { it.isNotBlank() }) - else -> WalletChildPhase.Unrecognised(state) - } -} - -/** - * `off · receive-only`, `exited · remote daemon — spawn monero-wallet-rpc: No - * such file or directory`. - * - * The chain-source label is the core's own (`WalletChildStatus.chain_source`), - * rendered verbatim: `receive-only`, `local node`, `remote onion daemon`, - * `remote daemon`. The trailing failure text is the core's `last_error`, cut - * and sanitized by the same rule chat rows use. - */ -fun walletChildLine(input: WalletChildInput?): String { - val phase = walletChildPhase(input) - val source = input?.chainSource?.takeIf { it.isNotBlank() } ?: "no chain source" - val node = nodePhase(input) - val height = input?.height ?: 0uL - val target = input?.targetHeight ?: 0uL - val why = input?.lastError?.takeIf { it.isNotBlank() } - return buildString { - append(phase.label) - append(" · ") - append(source) - // Only an in-process source has a node of its own to name. The node word - // is the core's, rendered as-is — there is no second state machine here. - if (node !is NodePhase.Absent) { - append(" · node ") - append(node.label) - } - // The daemon's own height, when it reported one: `sync h/t`, the segment - // the core's own line uses. No percent, no progress bar, no ETA — `0/0` - // is unknown (the probe failed, or the daemon is not up), not "0%", and - // when both are zero the segment is absent rather than printed as `0/0`. - if (height > 0uL || target > 0uL) { - append(" · sync ") - append(height.toString()) - append('/') - append(target.toString()) - } - when { - why != null -> append(" — ").append(shortSendReason(why)) - phase is WalletChildPhase.Exited -> append(" — the child process is gone") - } - } -} - -/** - * The whole status row as one screen-reader sentence: the phase's own sentence, - * then the same line the eye reads — including the daemon's `sync h/t` when the - * core reported one. A screen reader is never told less than the sighted user, - * and it is a sentence either way. - */ -fun walletChildStatusDescription(input: WalletChildInput?): String = - "${walletChildPhase(input).contentDescription}. ${walletChildLine(input)}" - -/** - * A `.onion` daemon is only reachable through the `arti` SOCKS child, and this - * build does not ship one — say that before the user presses Start rather than - * after the spawn fails. - */ -const val ONION_NEEDS_ARTI_NOTICE: String = - "A .onion daemon needs the arti SOCKS child, which this build does not bundle." - -/** Shown while the first `wallet_status()` read is still in flight. */ -const val READING_CHILD_NOTICE: String = "Reading the wallet status…" - -const val STARTING_CHILD_NOTICE: String = - "Start is running. Status stays off until the on-device node answers — that can take a minute, and is not a dead button." - -/** - * The alert banner the on-device node is offered with, **before** Start. - * - * Cuprate's own user book says *"do NOT use cuprated for any serious purposes"*, - * its `monerod` RPC parity is incomplete (Cuprate issue #278, and the four gaps - * measured in this repo are in `docs/cuprate-launch-spike.md`), and mainnet is - * unvalidated. The title is the banner's; the two sentences are the body — one - * copy of the caveat, never a second one elsewhere on the screen, so the two - * can never drift apart. - */ -const val CUPRATE_ON_DEVICE_TITLE: String = "Experimental On-Device Node (Cuprate)" -const val CUPRATE_ON_DEVICE_BODY: String = - "Pre-production software with incomplete RPC parity (#278). Do not use for significant " + - "funds. Mainnet is unvalidated, and Cuprate's own user book says do NOT use cuprated " + - "for any serious purposes." - -/** - * This build was compiled without the `cuprate-daemon` feature, so the stored - * on-device chain source can be read back but can never start. Mirrors the core's - * own refusal (`onionwire::cuprate::NO_FEATURE_MSG`) rather than inventing a - * second wording for the same fact. - */ -const val CUPRATE_NOT_IN_BUILD_NOTICE: String = - "This build has no in-process chain daemon, so the on-device node cannot start." - -/** - * Free space the chain store's filesystem must have before the on-device node is - * started. - * - * A **floor**, not a sync estimate, and deliberately so: nothing in this stack - * exposes one. `WalletChildStatus` carries no size field, and Cuprate's own - * restricted RPC reports a hardcoded 5 GiB `database_size` placeholder (see - * `src/cuprate.rs`), so a number taken from the node would be fiction. What can be - * measured honestly is the free space on the filesystem the fjall store grows - * into, and the device can be told when that is not enough. - */ -const val CHAIN_TESTNET_FLOOR_BYTES: Long = 3L * 1024 * 1024 * 1024 -const val CHAIN_MAINNET_PRUNED_FLOOR_BYTES: Long = 64L * 1024 * 1024 * 1024 -const val CHAIN_MAINNET_FULL_FLOOR_BYTES: Long = 280L * 1024 * 1024 * 1024 - -/** Testnet floor, kept so existing tests still name one constant. */ -const val CHAIN_FREE_SPACE_FLOOR_BYTES: Long = CHAIN_TESTNET_FLOOR_BYTES - -fun chainStorageFloorBytes(mainnet: Boolean, prune: Boolean): Long = when { - !mainnet -> CHAIN_TESTNET_FLOOR_BYTES - prune -> CHAIN_MAINNET_PRUNED_FLOOR_BYTES - else -> CHAIN_MAINNET_FULL_FLOOR_BYTES -} - -/** - * What the chain store costs, in the user's terms: the free space this device - * actually has, and what the node does *not* tell us. - */ -fun chainStorageLine(freeBytes: Long?, mainnet: Boolean = false, prune: Boolean = false): String { - val kind = when { - !mainnet -> "a synced testnet store" - prune -> "a pruned mainnet store (tens of GiB)" - else -> "a full mainnet store (hundreds of GiB)" - } - return when { - freeBytes == null -> - "chain store: free space on this device could not be read." - else -> - "chain store: ${formatBytes(freeBytes)} free on this device — $kind " + - "grows into it. The node reports no size estimate of its own." - } -} - -/** - * Why the on-device node must not be started on this device, or `null` when it - * may. Fail-closed on an unreadable filesystem: an unknown free space is not - * reported as enough. - */ -fun chainStorageBlockedReason( - freeBytes: Long?, - mainnet: Boolean = false, - prune: Boolean = false, -): String? { - val floor = chainStorageFloorBytes(mainnet, prune) - return when { - freeBytes == null -> - "Free space on the chain store's filesystem could not be read, so it is not known to fit." - freeBytes < floor -> - "Not enough space for the chain store: ${formatBytes(freeBytes)} free, and the " + - "on-device node needs at least ${formatBytes(floor)}." - else -> null - } -} - -enum class CuprateMode { - MainnetPruned, - MainnetFull, - Testnet, -} - -fun selectedCuprateMode(inProcess: Boolean, mainnet: Boolean, prune: Boolean): CuprateMode? = - when { - !inProcess -> null - !mainnet -> CuprateMode.Testnet - prune -> CuprateMode.MainnetPruned - else -> CuprateMode.MainnetFull - } - -/** - * Tapping a mode used to only persist `ChainConfig`, which looked like a no-op - * besides the storage line. Start when the storage floor would allow Start, - * **the Start gate itself would allow it**, and a launch is not already in - * flight. - * - * [startBlocked] is the same reason the Start button is disabled by - * (`startGateReason`). A mode tap stores the source either way, but persisting - * a choice must never launch a child the gate would refuse — the old - * storage-only predicate is exactly how an auto-start slipped past a stored - * binary that could not run. - */ -fun shouldStartAfterSelectingChain( - storageBlocked: String?, - starting: Boolean, - startBlocked: String? = null, -): Boolean = storageBlocked == null && startBlocked == null && !starting - -/** - * Bytes as a screen-sized string. Binary units (a "GB" that is really a GiB is how - * a store that needs 3 GiB ends up on a device with 2.8). - */ -fun formatBytes(bytes: Long): String = when { - bytes >= 1L shl 30 -> String.format(Locale.US, "%.1f GiB", bytes.toDouble() / (1L shl 30)) - bytes >= 1L shl 20 -> String.format(Locale.US, "%.0f MiB", bytes.toDouble() / (1L shl 20)) - else -> "$bytes B" -} - -/** - * A block height with thousands separators: `3794383` → `3,794,383`. - * - * Hand-grouped rather than `String.format("%,d")` on purpose: the grouped - * format is locale-dependent (some locales use a period or a non-breaking - * space), and a block height is a number in a monospace column, not prose. The - * screen and its test must print the same string everywhere. - */ -fun formatBlockCount(blocks: ULong): String { - val digits = blocks.toString() - val out = StringBuilder(digits.length + digits.length / 3) - digits.forEachIndexed { i, c -> - if (i > 0 && (digits.length - i) % 3 == 0) out.append(',') - out.append(c) - } - return out.toString() -} - -/** - * What the node card's progress header renders for one height / target pair. - * - * [percentText] and [blockText] are null when there is nothing honest to say — - * and `target == 0` is exactly that: the daemon reporting **no target** is not - * evidence of being caught up (`src/wallet.rs` returns `0` for a height it does - * not have, and Cuprate omits the target even at the tip). A percentage invented - * from a zero target would read as progress; an unknown target is said in words. - */ -data class SyncProgress( - /** 0f..1f of the track to fill. `0f` whenever the target is unknown. */ - val fraction: Float, - /** `12.8%`, or null when the daemon reported no target. */ - val percentText: String?, - /** `Block 485,253 of 3,794,383`, or null when neither number is known. */ - val blockText: String?, -) - -fun syncProgress(height: ULong, target: ULong): SyncProgress { - if (height == 0uL && target == 0uL) return SyncProgress(0f, null, null) - if (target == 0uL) { - return SyncProgress( - fraction = 0f, - percentText = null, - blockText = "Block ${formatBlockCount(height)} of an unknown target", - ) - } - val fraction = (height.toDouble() / target.toDouble()).coerceIn(0.0, 1.0) - return SyncProgress( - fraction = fraction.toFloat(), - percentText = String.format(Locale.US, "%.1f%%", fraction * 100.0), - blockText = "Block ${formatBlockCount(height)} of ${formatBlockCount(target)}", - ) -} - -/** - * The balance line, with the core's two sentinels translated into words. - * - * `walletBalance()` does not throw: it answers `off` (no chain source is - * configured at all) or `err` (configured, but the read failed — no wallet file - * open, or the process is down) and a formatted amount otherwise. Printing - * either sentinel raw is what put the string `wallet off` on the wallet screen; - * printing the same word for both is worse, because they are fixed in different - * places. The sentinels themselves are the core's contract and are not touched - * here — this is the display only. - */ -fun noWalletBalanceHeadline(balance: String?): String = when (balance) { - null -> "…" - "off" -> "No Wallet Loaded" - "err" -> "Balance unavailable" - else -> balance -} - -/** `Mainnet Pruned` / `Mainnet Full` / `Testnet` — the three stored modes, as words. */ -fun chainModeLabel(mainnet: Boolean, prune: Boolean): String = when { - !mainnet -> "Testnet" - prune -> "Mainnet Pruned" - else -> "Mainnet Full" -} - -/** - * How the node card's header reads. [tone] is the status dot's colour class, not - * a decoration: it is the caller's statement about the core's own word. - */ -enum class NodeStatusTone { - /** Nothing is running, and nothing is wrong. */ - Idle, - - /** Up, or on its way up. */ - Busy, - - /** Answered and at the tip. */ - Good, - - /** A state the app cannot read, or a process that is gone. */ - Bad, -} - -data class NodeStatusHead(val title: String, val tone: NodeStatusTone) - -/** - * The header sentence for the node card, from the core's `state` alone. - * - * Fail-closed exactly as [walletChildPhase] is: an unrecognised state gets - * [NodeStatusTone.Bad] and never reads as ready. A running child that has not - * answered is `Connecting…`, not `Ready` — the RPC has not spoken yet. - */ -fun nodeStatusHead( - input: WalletChildInput?, - inProcess: Boolean = false, - mainnet: Boolean = false, - prune: Boolean = false, -): NodeStatusHead { - val mode = if (inProcess) " (${chainModeLabel(mainnet, prune)})" else "" - return when (walletChildPhase(input)) { - WalletChildPhase.Unread -> NodeStatusHead("Reading wallet status", NodeStatusTone.Idle) - WalletChildPhase.Off -> - NodeStatusHead(if (inProcess) "Node Idle$mode" else "Wallet Offline", NodeStatusTone.Idle) - WalletChildPhase.Connecting -> NodeStatusHead("Connecting…", NodeStatusTone.Busy) - WalletChildPhase.Syncing -> - NodeStatusHead(if (inProcess) "Syncing Node$mode" else "Syncing Wallet", NodeStatusTone.Busy) - WalletChildPhase.Ready -> NodeStatusHead("Wallet Ready", NodeStatusTone.Good) - is WalletChildPhase.Exited -> NodeStatusHead("Wallet Stopped", NodeStatusTone.Bad) - is WalletChildPhase.Unrecognised -> NodeStatusHead("Unknown wallet state", NodeStatusTone.Bad) - } -} - -/** - * Why **Start** is not actionable, or `null` when it is. - * - * Ordered by what the user can act on: a binary this build does not carry is - * not fixable from this screen, a missing chain source is. Every branch names - * the actual condition — there is no generic "starting…" state to hide behind. - */ -fun startBlockedReason( - bins: WalletChildBinaryPaths, - input: WalletChildInput?, - onionDaemon: Boolean = false, - starting: Boolean = false, -): String? = when { - bins.walletRpc == null -> NO_WALLET_RPC_MESSAGE - starting -> STARTING_CHILD_NOTICE - input == null -> READING_CHILD_NOTICE - // Unreachable from the wallet screen: while the wallet runs the lifecycle - // control *is* Stop, so Start is never offered. Kept as a pure predicate so - // a stale status read cannot turn the one control into a no-op tap. - input.running -> "The wallet is already running." - !input.configured -> NO_CHAIN_SOURCE_NOTICE - // The stored source is the app's own node but this build has no daemon: the - // option is readable and unstoppable, so say it before the user presses Start. - input.chainInProcess && !input.nodeAvailable -> CUPRATE_NOT_IN_BUILD_NOTICE - onionDaemon && bins.arti == null -> ONION_NEEDS_ARTI_NOTICE - else -> null -} - -/** The stored config names no chain source, so there is no daemon to dial. */ -const val NO_CHAIN_SOURCE_NOTICE: String = - "No chain source yet: the wallet needs a daemon to dial." - -/** - * Whether [path] is a file this process may `exec`, measured the way the kernel - * will measure it at spawn time. A missing file and an existing file without - * the execute bit are both "cannot run here" — they differ only in errno. - * - * Never throws: a path the filesystem refuses to answer for is not executable. - */ -fun isExecutableWalletBin(path: String): Boolean = - runCatching { File(path).let { it.isFile && it.canExecute() } }.getOrDefault(false) - -/** - * The absolute path the stored config should keep instead of [storedBin], or - * `null` when the stored path is already runnable here (or there is nothing - * better to offer). - * - * This is the repair rule behind the self-heal. A record written by an older - * install can carry the bare name `monero-wallet-rpc` (or nothing at all), - * which nothing in an APK sandbox resolves on `PATH`; the spawn then dies with - * `ENOENT` and the screen had no way to say why. When this build *does* carry - * the binary at a resolved absolute path, that path replaces the unusable one. - * - * It never overwrites a path the user pointed at that actually runs: an - * existing, executable file is left alone even when it is not the bundled one. - */ -fun walletBinHealPath( - storedBin: String?, - resolvedBin: String?, - executable: (String) -> Boolean = ::isExecutableWalletBin, -): String? { - val resolved = resolvedBin?.takeIf { it.isNotBlank() } ?: return null - val stored = storedBin?.trim().orEmpty() - if (stored.isNotEmpty() && executable(stored)) return null - return resolved -} - -/** - * Why the **stored** `ChainConfig.walletRpcBin` will not produce a child, or - * `null` when it will. [startBlockedReason] only ever sees the *resolved* - * binaries, so a stale path saved by an older install passed that gate and - * then failed inside `spawn`. - * - * The reason always names the path it is about, so the next failure report - * carries its own cause instead of the opaque `spawn monero-wallet-rpc: No such - * file or directory`. A store that holds no path at all is named as such — - * "stored bin missing" is a distinct condition from "this build ships none". - */ -fun storedWalletBinBlockedReason( - storedBin: String?, - resolvedBin: String?, - executable: (String) -> Boolean = ::isExecutableWalletBin, -): String? { - if (resolvedBin.isNullOrBlank()) return NO_WALLET_RPC_MESSAGE - val stored = storedBin?.trim().orEmpty() - if (stored.isEmpty()) { - return "No wallet binary path is stored for this chain source, so there is nothing to " + - "spawn. This build ships $resolvedBin — pick a chain source to store it." - } - if (executable(stored)) return null - return "The stored wallet binary cannot be run on this device: $stored. " + - "This build ships $resolvedBin." -} - -/** - * The full **Start** gate: the eligibility rules above plus the stored binary. - * - * [startBlockedReason] runs first so its established copy and ordering (no - * binary in this build, start in flight, no chain source) is unchanged; the - * stored-path check is the new second half. Together they make a populated - * `bins` insufficient on its own — which was the hole that let a bare stored - * name through. - */ -fun startGateReason( - bins: WalletChildBinaryPaths, - input: WalletChildInput?, - storedWalletBin: String?, - onionDaemon: Boolean = false, - starting: Boolean = false, - executable: (String) -> Boolean = ::isExecutableWalletBin, -): String? = - startBlockedReason(bins, input, onionDaemon, starting) - ?: storedWalletBinBlockedReason(storedWalletBin, bins.walletRpc, executable) - -/** - * Why **Create wallet** / **Import wallet** cannot be offered yet, or `null` - * when they can. - * - * Both are RPC calls (`create_wallet` / `restore_deterministic_wallet`) against - * the running child. With no child the call cannot succeed, and the core's - * refusal is the desktop TUI's `wallet not configured — open F7 …` — a key that - * does not exist on a phone. Collecting a passphrase only to print that is the - * second dead end this screen must not offer. - */ -fun walletSetupBlockedReason(input: WalletChildInput?): String? = - when (walletChildPhase(input)) { - WalletChildPhase.Unread -> READING_CHILD_NOTICE - WalletChildPhase.Off -> WALLET_SETUP_NEEDS_CHILD - WalletChildPhase.Connecting -> WALLET_SETUP_STARTING - is WalletChildPhase.Exited, is WalletChildPhase.Unrecognised -> WALLET_SETUP_NEEDS_CHILD - WalletChildPhase.Syncing, WalletChildPhase.Ready -> null - } - -/** Shown on the disabled Create / Import controls when no wallet process is up. */ -const val WALLET_SETUP_NEEDS_CHILD: String = - "Create and Import need the wallet process running. Start it on the node card first." - -/** Shown while the child is up but its RPC has not answered yet. */ -const val WALLET_SETUP_STARTING: String = - "The wallet is still starting. Wait until it answers, then create or import." - -/** Tone of the one failure banner a card may paint. */ -enum class WalletFailureTone { - /** Information about a state the app is in, not a failed call. */ - Info, - - /** A call actually failed. */ - Error, -} - -/** - * The banner a card should paint for a display-ready failure string, or `null` - * when it should paint none. - * - * [WALLET_NOT_OPEN_TEXT] is documented as a *state*, not a failure — a running - * child with no wallet file open answers every read with the daemon's `-13`, - * and that is exactly what first-run looks like. It nevertheless reached the - * node card's red `Wallet error` banner, duplicating the `No wallet open` info - * banner directly above it. This decision is keyed on the *mapped* text only: - * the mapping in [walletFailureText] is untouched, so nothing raw becomes - * visible, and only the paint changes. - * - * - [walletOpen] true: the state has ended, so a stale no-wallet sentence is - * dropped entirely. - * - [openHintVisible] true: the info banner above already says it — one - * sentence, once. - * - otherwise the sentence is still information, so it is painted as - * [WalletFailureTone.Info] rather than red. - */ -fun walletFailureBanner( - text: String?, - openHintVisible: Boolean, - walletOpen: Boolean, -): WalletFailureBanner? { - val shown = text?.takeIf { it.isNotBlank() } ?: return null - return if (shown == WALLET_NOT_OPEN_TEXT) { - when { - walletOpen -> null - openHintVisible -> null - else -> WalletFailureBanner(shown, WalletFailureTone.Info, "No wallet open") - } - } else { - WalletFailureBanner(shown, WalletFailureTone.Error, "Wallet error") - } -} - -/** One banner: its sentence, its tone, and its title. */ -data class WalletFailureBanner( - val text: String, - val tone: WalletFailureTone, - val title: String, -) - - -/** - * Why **Stop** is not actionable, or `null` when it is. `stop_wallet_child` is - * idempotent in the core, so this is only about not offering a no-op button. - */ -fun stopBlockedReason(input: WalletChildInput?): String? = when { - input == null -> READING_CHILD_NOTICE - !input.running -> "No wallet is running." - else -> null -} - -/** - * Does this daemon host name a Tor onion service? Mirrors - * `wallet::is_onion_host` — the core's own rule, so the screen and the spawn - * path agree on which daemons need the SOCKS child. - */ -fun isOnionHost(host: String): Boolean = host.trim().lowercase().endsWith(".onion") - -/** - * Parse the one text field the chain-source editor offers (`host:port`) into a - * daemon address, or `null` when it is not one. - * - * Deliberately strict: the core rejects an empty host or port 0 anyway, and a - * silently-guessed port is how a wallet ends up dialing the wrong daemon. An - * IPv6 literal in brackets is accepted; a bare IPv6 address is not, because - * `::1:18089` has no unambiguous split. - */ -fun parseDaemonAddress(raw: String): DaemonAddress? { - val text = raw.trim() - if (text.isEmpty()) return null - val host: String - val portText: String - if (text.startsWith("[")) { - val end = text.indexOf(']') - if (end <= 1) return null - host = text.substring(1, end) - val rest = text.substring(end + 1) - if (!rest.startsWith(":")) return null - portText = rest.substring(1) - } else { - // A bare IPv6 literal has no unambiguous split: `::1:18089` is either - // the host `::1` on 18089 or the host `::1:18089`. Bracket it. - if (text.count { it == ':' } != 1) return null - val cut = text.lastIndexOf(':') - host = text.substring(0, cut) - portText = text.substring(cut + 1) - } - val port = portText.toIntOrNull() ?: return null - if (host.isBlank() || port !in 1..65535) return null - return DaemonAddress(host, port) -} - -/** A daemon address the user typed. */ -data class DaemonAddress(val host: String, val port: Int) { - /** The single-line form the field holds. */ - val text: String get() = "$host:$port" -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletManagerScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletManagerScreen.kt deleted file mode 100644 index 214394d..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletManagerScreen.kt +++ /dev/null @@ -1,983 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import android.app.Activity -import android.content.Context -import android.content.ContextWrapper -import android.view.WindowManager -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalView -import androidx.compose.ui.platform.testTag -import androidx.compose.ui.text.input.PasswordVisualTransformation -import androidx.compose.ui.unit.dp -import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.siriusdevops.onionwire.WireViewModel -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwAlertBanner -import com.siriusdevops.onionwire.ui.components.OwAlertVariant -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonRow -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwPill -import com.siriusdevops.onionwire.ui.components.OwSectionTitle -import com.siriusdevops.onionwire.ui.components.OwTopBar -import kotlinx.coroutines.launch -import uniffi.onionwire_sdk.WalletKeys -import uniffi.onionwire_sdk.WalletRow -import java.time.Instant -import java.time.ZoneId -import java.time.format.DateTimeFormatter - -// --------------------------------------------------------------------------- -// The rules this screen renders from, as pure Kotlin so `WalletManagerTest` -// covers them on the JVM without a device. Same shape as `SeedBackupGate` and -// `WalletChildStatusText`: the composables below only lay these decisions out. -// --------------------------------------------------------------------------- - -/** - * A catalogue row's label: the user's name for the wallet, or the file name - * when there is none. - * - * `WalletRow.name` is documented as `None` when the wallet was never named and - * "never an empty string", but a blank string is treated as absent here too — - * a row labelled with spaces is a row the user cannot identify. - */ -internal fun walletRowLabel(name: String?, filename: String): String = - name?.takeIf { it.isNotBlank() } ?: filename - -/** - * A row's creation date, from the store's unix seconds. - * - * `created_at <= 0` is not a date: the store assigns it on insert, so anything - * else is a row that predates that — say so rather than render 1970. - */ -internal fun walletRowDate(createdAt: Long): String { - if (createdAt <= 0L) return "date unknown" - return Instant.ofEpochSecond(createdAt) - .atZone(ZoneId.systemDefault()) - .format(DateTimeFormatter.ISO_LOCAL_DATE) -} - -/** - * Whether the wallet process has a wallet open that the RPC answers for. - * - * The core's `state` is the only honest signal available here: `connecting` - * means its wallet RPC has not answered, `off`/`exited` mean there is no child - * at all, and `syncing`/`ready` mean it answered — the chain being behind is - * irrelevant to whether the open wallet's keys can be read. A `null` state is - * "nothing read yet", which is not readable. - */ -internal fun walletChildReadable(state: String?): Boolean = - state == "ready" || state == "syncing" - -/** - * Whether the open wallet's secrets may be offered for the row named - * [rowFilename]. - * - * Both halves are load-bearing: - * - * - **active**: the seed and the private keys come from `query_key` against - * the file the child currently has open, so they belong to exactly one - * wallet. A non-active row's buttons stay dead instead of quietly opening - * that wallet under the user — switching is a deliberate tap, not a side - * effect of asking for a backup. - * - **readable**: with no child running there is no file open, and - * `wallet_seed()` / `wallet_keys()` can only fail. Offering a button that - * always errors is worse than saying why it is off. - */ -internal fun walletSecretsEnabled( - activeFilename: String?, - rowFilename: String, - walletReadable: Boolean, -): Boolean = walletReadable && activeFilename != null && activeFilename == rowFilename - -/** - * Why the secret actions are off, in words — or `null` when they are on. - * - * The two reasons are different states of the world and are not collapsed: - * "this is not the open wallet" is fixed by tapping the row, "the child is not - * running" is fixed on the wallet screen. The first wording is the card's own. - */ -internal fun walletSecretsBlockedReason( - isActive: Boolean, - walletReadable: Boolean, -): String? = when { - !isActive -> "Open this wallet to view its backup." - !walletReadable -> "The wallet is not running — start it on the wallet screen to read the backup." - else -> null -} - -// --------------------------------------------------------------------------- -// A wallet that needs its passphrase, and never the daemon's own words -// --------------------------------------------------------------------------- - -/** - * The daemon's own phrase for "this RPC has no wallet file open" - * (`monero-wallet-rpc` answers `-13 No wallet file`). - * - * Matched case-insensitively anywhere in a failure string: the wallet client - * strips the JSON envelope and keeps only `error.message`, so the bare sentence - * is what actually reaches Kotlin — sometimes wrapped in the core's own - * `wallet file X is not open — …` prefix. - */ -private val NO_WALLET_FILE = Regex("no wallet file", RegexOption.IGNORE_CASE) - -/** - * A bare wallet-RPC error code. `-13` is - * `WALLET_RPC_ERROR_CODE_NO_WALLET_FILE`; the lookarounds keep it from firing - * on a longer number or on a negative offset like `-135`. - */ -private val RAW_RPC_CODE = Regex("""(? null - // Before the JSON / -13 filters: the TUI's refusal is a plain sentence - // the raw pass-through would otherwise let reach the phone verbatim. - TUI_WALLET_NOT_CONFIGURED.containsMatchIn(text) -> WALLET_RPC_NOT_RUNNING_TEXT - NO_WALLET_FILE.containsMatchIn(text) || RAW_RPC_CODE.containsMatchIn(text) -> - WALLET_NOT_OPEN_TEXT - RAW_JSON.containsMatchIn(text) -> WALLET_DAEMON_REFUSED_TEXT - else -> text - } -} - -/** - * `lastError` as the wallet screen should paint it, given the child's `state`. - * - * Defense in depth behind the core's own fix: the 2s probe dials a wallet RPC - * that may not have bound its port yet, and that transient refusal - * (`wallet connect:` / `wallet write:`) is not a fact about the wallet — the - * child is still `connecting` and the next tick usually clears it. Painting it - * red in that window tells the user a start that is going to succeed has - * failed. - * - * Only `connecting` is suppressed, and only for those two prefixes. The same - * string once the child is `exited` / `syncing` / `off` means it accepted a - * connection and then stopped answering, which is exactly what the user needs - * to see. This mirrors the core's `error_is_unreachable` predicate verbatim — - * a bare `Connection refused` from anything else is not matched. - * - * Everything else goes through [walletFailureText], unchanged. - */ -internal fun displayLastError(state: String, raw: String?): String? { - val text = raw?.trim().orEmpty() - if (text.isEmpty()) return null - val connecting = state.trim().equals("connecting", ignoreCase = true) - if (connecting && (text.startsWith("wallet connect:") || text.startsWith("wallet write:"))) { - return null - } - return walletFailureText(text) -} - -/** - * Whether the manager screen must ask for a wallet-file passphrase. - * - * `needs_passphrase` is the core's own word for "a saved wallet is configured, - * and this install holds no passphrase that opens it" — a wallet created before - * the passphrase was sealed, or created on another install. It is not a start - * failure, and the child keeps running. - * - * `walletOpen` is the second half of the same statement and wins: a child that - * has a wallet file open has nothing to ask for, whatever the flag said a - * moment ago. Both come from one `WalletChildStatus`, so there is no second - * source of truth about which wallet is open. - */ -internal fun walletPassphrasePromptVisible(needsPassphrase: Boolean, walletOpen: Boolean): Boolean = - needsPassphrase && !walletOpen - -/** - * Whether the prompt's submit is actionable. - * - * A file name is required because the open is per-file (`open_wallet` on the - * file the child is pointed at); a blank passphrase is refused by the core - * anyway, so the button stays dead rather than round-tripping a guaranteed - * failure. An in-flight open is not re-submitted: it restarts the wallet process. - */ -internal fun walletPassphraseSubmitEnabled( - activeFilename: String?, - typed: String, - inFlight: Boolean, -): Boolean = !inFlight && activeFilename != null && typed.isNotEmpty() - -/** - * Why the prompt cannot be submitted yet, in words — or `null` when it can. - * - * The two reasons are different states of the world and are not collapsed: - * nothing typed is the user's own gap, no pointed-at file is the child's. - */ -internal fun walletPassphraseBlockedReason( - activeFilename: String?, - typed: String, -): String? = when { - activeFilename == null -> - "No wallet file is open yet — open one from the list below." - typed.isEmpty() -> "Type the passphrase for this wallet file." - else -> null -} - -/** - * Why the wallet process has nothing open, in this app's words — or `null` when - * it has a wallet open, or nothing is running to hold one. - * - * A live `monero-wallet-rpc` is not a usable wallet: it starts with no wallet - * file open, and every read then answers `-13 No wallet file`. The status line - * reports the child's state, not that, so the screen says it here and names the - * one screen that fixes it. `needsPassphrase` is the case where the child is - * pointed at a file this install holds no passphrase for — the fix is a typed - * passphrase, not a different wallet, and the prompt lives on the manager - * screen. - */ -internal fun walletChildOpenHint( - childRunning: Boolean, - walletOpen: Boolean, - needsPassphrase: Boolean, -): String? = when { - !childRunning || walletOpen -> null - needsPassphrase -> - "The wallet needs its passphrase: open it on the Saved wallets screen, where the " + - "prompt is." - else -> - "Select a saved wallet or create a new one to view your balance and transact." -} - -/** - * The saved-wallet catalogue: every wallet this install remembers, which one is - * open now, and — for that one — its recovery phrase and private keys. - * - * Three properties are deliberate and are the whole point of the screen: - * - * - The catalogue is re-read on entry and on Refresh, never cached from app - * start, so a wallet created on the wallet screen after this screen was - * first opened shows up without restarting the app. - * - A tap opens a row's file through `open_wallet(filename)` and reloads, so - * the in-use marker moves. The core refuses a name outside the catalogue, - * and its refusal is shown verbatim. - * - The secrets belong to the **open** wallet only. They are read on an - * explicit tap, are never shown for a row that is not the open one, and are - * never logged, persisted, put in a `testTag`/`contentDescription`, or held - * in saved state (`remember`, not `rememberSaveable`, and cleared on - * dispose). - */ -@Composable -fun WalletManagerScreen( - vm: WireViewModel, - onBack: () -> Unit, -) { - val child by vm.walletChild.collectAsStateWithLifecycle() - val scope = rememberCoroutineScope() - - /** `null` is "not read yet"; an empty list is a catalogue with no rows. */ - var rows by remember { mutableStateOf?>(null) } - /** The file name the core reports as open, or null when it reports none. */ - var active by remember { mutableStateOf(null) } - /** A catalogue/active-wallet read failure, distinct from an empty list. */ - var listError by remember { mutableStateOf(null) } - /** A failed open, verbatim from the core. */ - var actionError by remember { mutableStateOf(null) } - /** The file name currently being opened, so the row can say so. */ - var opening by remember { mutableStateOf(null) } - - // The wallet-file passphrase, for a wallet this install holds none for. - // Masked on screen, never copied (there is no copy action, exactly as the - // seed card has none), never logged, never persisted, and wiped when the - // screen goes — see the `DisposableEffect` below. - var passphrase by remember { mutableStateOf("") } - var passphraseError by remember { mutableStateOf(null) } - var openingWithPassphrase by remember { mutableStateOf(false) } - - // The seed on the blocking card, and the typed confirm word. Neither is - // persisted: a spend key lives in this composition and nowhere else. - var seed by remember { mutableStateOf(null) } - var seedConfirm by remember { mutableStateOf("") } - // The open wallet's private keys, only ever set by an explicit tap on - // "Private keys". Null means no card. - var keys by remember { mutableStateOf(null) } - var keysError by remember { mutableStateOf(null) } - - suspend fun reload() { - vm.wallets().fold( - onSuccess = { - rows = it - listError = null - }, - onFailure = { - rows = null - listError = walletFailureText(it.message ?: it.toString()) - }, - ) - vm.activeWalletFilename().fold( - onSuccess = { active = it }, - onFailure = { - // Same store as the list: a failure here is a read failure, not - // "no wallet is open", and it must not be rendered as one. - active = null - if (listError == null) { - listError = walletFailureText(it.message ?: it.toString()) - } - }, - ) - } - - /** Open a row's file, then re-read so the in-use marker moves. */ - fun open(filename: String) { - if (opening != null) return - scope.launch { - actionError = null - opening = filename - vm.openWallet(filename).fold( - onSuccess = { reload() }, - onFailure = { actionError = walletFailureText(it.message ?: it.toString()) }, - ) - opening = null - } - } - - /** - * "Open this wallet": the one-time passphrase for a wallet this install - * holds none for. - * - * `openWalletWithPassphrase` is the parent card's binding. It is a per-file - * call, so it is handed the file the child is already pointed at — the same - * `active_wallet_filename()` the list marks in use, not a second idea of - * which wallet is open. The core seals the passphrase only once a live - * daemon has accepted it, so a wrong one leaves the prompt up rather than - * looking fixed. - */ - fun openWithPassphrase() { - val file = active ?: return - if (openingWithPassphrase || passphrase.isEmpty()) return - scope.launch { - passphraseError = null - openingWithPassphrase = true - vm.openWalletWithPassphrase(file, passphrase).fold( - onSuccess = { - // The secret has done its job. Drop it before anything else - // can see it, then re-read: the live probe in the ViewModel - // is what flips `needs_passphrase` and takes this card off - // the screen. - passphrase = "" - reload() - }, - onFailure = { passphraseError = walletFailureText(it.message ?: it.toString()) }, - ) - openingWithPassphrase = false - } - } - - /** - * "Recovery phrase": re-read the open wallet's 25 words and put them on the - * existing blocking card. Same treatment as the wallet screen's "Back up - * seed" — one gate, one card, no second ungated display. - */ - fun showPhrase() { - scope.launch { - actionError = null - vm.walletSeed().fold( - onSuccess = { - seed = it - seedConfirm = "" - }, - onFailure = { actionError = walletFailureText(it.message ?: it.toString()) }, - ) - } - } - - /** - * "Private keys": read the open wallet's keys once, on this tap. Failure is - * shown where the card would be, so a wallet that cannot answer says so - * instead of looking like an empty one. - */ - fun showKeys() { - scope.launch { - actionError = null - keysError = null - vm.walletKeys().fold( - onSuccess = { keys = it }, - onFailure = { keysError = walletFailureText(it.message ?: it.toString()) }, - ) - } - } - - LaunchedEffect(Unit) { - // The cached child read never dials, so the screen paints; the live - // probe after it is what tells the truth about whether a wallet is - // open, which is what the secret actions hang on. - vm.paintWalletChildCached() - reload() - vm.refreshWalletChild() - } - - // Nothing here is `rememberSaveable`, so leaving the screen drops the - // composition's state — including the seed, the keys and the wallet-file - // passphrase. Dropping the reference is the strongest wipe a Kotlin String - // allows (see `SeedBackupCard`); this makes it explicit rather than - // incidental. - DisposableEffect(Unit) { - onDispose { - seed = null - seedConfirm = "" - keys = null - keysError = null - passphrase = "" - passphraseError = null - } - } - - // Screenshots and the recents thumbnail. This screen renders a spend key and - // asks for the passphrase that opens a wallet file, so it takes the same - // `FLAG_SECURE` treatment the seed path wants — set while this composition is - // up, cleared when it goes, so no other screen inherits it. (No screen in - // this app set the flag before this change; see the PR body.) - val view = LocalView.current - DisposableEffect(view) { - val window = view.context.findActivity()?.window - window?.addFlags(WindowManager.LayoutParams.FLAG_SECURE) - onDispose { window?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) } - } - - val walletReadable = walletChildReadable(child?.state) - - Scaffold( - // Root owns systemBars ∪ ime, exactly as the wallet screen does (see - // `screenContentInsets`). - contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, - topBar = { - OwTopBar( - title = "Saved wallets", - // A pushed sub-screen, so the chevron — never the word "Back". - onBack = onBack, - actions = { - OwButton( - text = "Refresh", - variant = OwButtonVariant.Outline, - onClick = { - scope.launch { - vm.refreshWalletChild() - reload() - } - }, - ) - }, - ) - }, - ) { pad -> - Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets() - .verticalScroll(rememberScrollState()), - ) { - // The blocking seed card, when a phrase is on screen: the whole - // body, exactly as on the wallet screen. Done is dead until the - // confirm word is typed, and the app-bar Back still leaves. - val shownSeed = seed - if (shownSeed != null) { - SeedBackupCard( - seed = shownSeed, - typed = seedConfirm, - onTyped = { seedConfirm = it }, - onDone = { - vm.confirmWalletSeed(seedConfirm) - seed = null - seedConfirm = "" - }, - ) - actionError?.let { ErrorText(it) } - return@Column - } - - keys?.let { k -> - PrivateKeysCard( - keys = k, - warning = vm.spendAuthorityWarning(), - onDone = { keys = null }, - ) - } - keysError?.let { message -> - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "Could not read the open wallet's private keys", - description = message, - modifier = Modifier - .padding(horizontal = 16.dp, vertical = 8.dp) - .testTag("wallet-keys-error"), - action = { - OwButton( - text = "Dismiss", - variant = OwButtonVariant.Outline, - onClick = { keysError = null }, - ) - }, - ) - } - - actionError?.let { ErrorText(it) } - - // The one-time passphrase for a wallet this install holds none for. - // A wallet created before the passphrase was sealed reports - // `needs_passphrase` and answers every read with `-13 No wallet - // file`, so without this the row tap looks like it did nothing. - if (walletPassphrasePromptVisible( - needsPassphrase = child?.needsPassphrase == true, - walletOpen = child?.walletOpen == true, - ) - ) { - WalletPassphraseCard( - filename = active, - typed = passphrase, - onTyped = { - passphrase = it - passphraseError = null - }, - inFlight = openingWithPassphrase, - childRunning = child?.running == true, - blockedReason = walletPassphraseBlockedReason(active, passphrase), - error = passphraseError, - onSubmit = { openWithPassphrase() }, - ) - } - - val listed = rows - when { - // A read failure is not an empty catalogue, and the two must - // not read alike: one is "the store did not answer", the other - // is "you have no wallets yet". - listError != null -> OwAlertBanner( - variant = OwAlertVariant.Error, - title = "Could not read the wallet catalogue", - description = listError ?: "", - modifier = Modifier - .padding(horizontal = 16.dp, vertical = 8.dp) - .testTag("wallet-list-error"), - action = { - OwButton( - text = "Retry", - variant = OwButtonVariant.Outline, - onClick = { scope.launch { reload() } }, - ) - }, - ) - - listed == null -> Text( - "Loading…", - style = MaterialTheme.typography.bodyMedium, - color = OwColors.TextSecondary, - modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), - ) - - listed.isEmpty() -> OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), - ) { - OwSectionTitle("No saved wallets yet") - Spacer(Modifier.height(6.dp)) - Text( - "Wallets this install remembers show up here. Create or import one " + - "on the wallet screen and it appears on the next look.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(12.dp)) - OwButton( - text = "Create or import a wallet", - variant = OwButtonVariant.Primary, - onClick = onBack, - modifier = Modifier.fillMaxWidth(), - ) - } - - else -> { - Label( - "${listed.size} SAVED ${if (listed.size == 1) "WALLET" else "WALLETS"}", - modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), - ) - listed.forEach { row -> - val isActive = active != null && active == row.walletFilename - WalletRowCard( - row = row, - isActive = isActive, - secretsEnabled = walletSecretsEnabled( - activeFilename = active, - rowFilename = row.walletFilename, - walletReadable = walletReadable, - ), - blockedReason = walletSecretsBlockedReason( - isActive = isActive, - walletReadable = walletReadable, - ), - opening = opening == row.walletFilename, - onOpen = { open(row.walletFilename) }, - onShowPhrase = { showPhrase() }, - onShowKeys = { showKeys() }, - ) - } - } - } - } - } -} - -/** - * One catalogue row: what it is called, which file it is, when it was created, - * and whether it is the open one. - * - * The open row is not tappable. Re-opening it would stop and restart a running - * wallet process onto the file it already has open — a slow no-op whose only - * effect is to make the screen look like it did something. - */ -@Composable -private fun WalletRowCard( - row: WalletRow, - isActive: Boolean, - secretsEnabled: Boolean, - blockedReason: String?, - opening: Boolean, - onOpen: () -> Unit, - onShowPhrase: () -> Unit, - onShowKeys: () -> Unit, -) { - OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 6.dp) - .then(if (isActive) Modifier else Modifier.clickable(enabled = !opening, onClick = onOpen)), - ) { - Row( - Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - Text( - walletRowLabel(row.name, row.walletFilename), - style = MaterialTheme.typography.titleMedium, - color = OwColors.TextPrimary, - modifier = Modifier.weight(1f), - ) - Spacer(Modifier.width(8.dp)) - when { - isActive -> OwPill( - text = "In use", - textColor = OwColors.Accent, - container = OwColors.InfoTint, - borderColor = OwColors.InfoBorder, - dotColor = OwColors.Accent, - ) - opening -> OwPill(text = "Opening…", textColor = OwColors.TextSecondary) - else -> OwPill(text = "Tap to open", textColor = OwColors.TextSecondary) - } - } - Spacer(Modifier.height(8.dp)) - Label("FILE") - Mono(row.walletFilename) - Spacer(Modifier.height(4.dp)) - Text( - "Created ${walletRowDate(row.createdAt)}", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - - Spacer(Modifier.height(10.dp)) - OwButtonRow { - OwButton( - text = "Recovery phrase", - variant = OwButtonVariant.Outline, - enabled = secretsEnabled, - onClick = onShowPhrase, - modifier = Modifier.weight(1f), - ) - OwButton( - text = "Private keys", - variant = OwButtonVariant.Outline, - enabled = secretsEnabled, - onClick = onShowKeys, - modifier = Modifier.weight(1f), - ) - } - blockedReason?.let { - Spacer(Modifier.height(6.dp)) - Text( - it, - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextMuted, - ) - } - } -} - -/** - * The one-time passphrase for a wallet file this install holds no passphrase - * for. - * - * Masked, and with no copy action at all — the same rule as [SeedBackupCard], - * for the same reason: the Android clipboard is readable by every other app and - * by the clipboard history on Android 13+, and this string opens a spend-capable - * wallet file. It is never logged, never persisted, and the caller drops it when - * the screen goes. - * - * Submit is dead while the wallet is not running: the core verifies a - * passphrase against a live daemon and refuses to seal an unverified one, so a - * tap there could only fail. When it *is* up — including `connecting`, whose RPC - * has not answered yet — the core restarts it onto the file with this - * passphrase, which is exactly the fix. - */ -@Composable -private fun WalletPassphraseCard( - filename: String?, - typed: String, - onTyped: (String) -> Unit, - inFlight: Boolean, - childRunning: Boolean, - blockedReason: String?, - error: String?, - onSubmit: () -> Unit, -) { - OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp) - .testTag("wallet-passphrase-card"), - ) { - OwSectionTitle("This wallet needs its passphrase") - Spacer(Modifier.height(6.dp)) - Text( - "The wallet is pointed at ${filename ?: "a wallet file"} but this install " + - "holds no passphrase that opens it — the wallet was created before the " + - "passphrase was stored, or on another device. Type it once: the wallet " + - "opens, and later starts reopen it on their own.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(12.dp)) - OutlinedTextField( - value = typed, - onValueChange = onTyped, - singleLine = true, - // Masked on screen: this string opens a spend-capable wallet. - visualTransformation = PasswordVisualTransformation(), - label = { Text("wallet passphrase") }, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-passphrase-input"), - ) - Spacer(Modifier.height(6.dp)) - Text( - "Never copied to the clipboard, never logged, and dropped when you leave this screen.", - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextSecondary, - ) - if (!childRunning) { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "The wallet is not running", - description = "Start it on the wallet screen, then come back.", - ) - } - error?.let { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "Could not open this wallet", - description = it, - ) - } - blockedReason?.let { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Not ready to open", - description = it, - ) - } - Spacer(Modifier.height(12.dp)) - OwButton( - text = if (inFlight) "Opening…" else "Open this wallet", - variant = OwButtonVariant.Primary, - enabled = childRunning && walletPassphraseSubmitEnabled(filename, typed, inFlight), - onClick = onSubmit, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-passphrase-submit"), - ) - } -} - -/** - * The open wallet's private keys, shown only after an explicit tap. - * - * The view key is always there; the spend key only when the wallet has one. - * A view-only wallet says so in words — it has no spend key, and rendering - * that as a failure would teach the user to read a normal wallet as a broken - * one. The values are spend secrets: no `testTag`, no `contentDescription`, - * no logging, no persistence, and the card is dropped when the screen goes. - */ -@Composable -private fun PrivateKeysCard( - keys: WalletKeys, - warning: String, - onDone: () -> Unit, -) { - OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp) - .testTag("wallet-private-keys-card"), - ) { - OwSectionTitle("Private keys of the open wallet") - Spacer(Modifier.height(6.dp)) - Text(warning, style = MaterialTheme.typography.bodySmall, color = OwColors.Danger) - Spacer(Modifier.height(12.dp)) - Label("VIEW KEY") - // Mono, and deliberately no testTag: a handle on a spend secret is a - // handle an automation can read back. - Mono(keys.viewKey, modifier = Modifier.fillMaxWidth()) - Spacer(Modifier.height(10.dp)) - val spend = keys.spendKey - if (spend != null) { - Label("SPEND KEY") - Mono(spend, modifier = Modifier.fillMaxWidth()) - } else { - Text( - "View-only wallet — no spend key.", - style = MaterialTheme.typography.bodyMedium, - color = OwColors.TextSecondary, - ) - } - Spacer(Modifier.height(12.dp)) - OwButton( - text = "Done", - variant = OwButtonVariant.Outline, - onClick = onDone, - modifier = Modifier.fillMaxWidth(), - ) - } -} - -/** - * A display-ready failure line, as a banner. Never carries a secret; callers - * pass errors. - * - * "No wallet is open" is not a failure — it is a state the app is in, and it - * gets the info banner and its own title. Only a real refusal is red. - */ -@Composable -private fun ErrorText(text: String) { - val notOpen = text == WALLET_NOT_OPEN_TEXT - OwAlertBanner( - variant = if (notOpen) OwAlertVariant.Info else OwAlertVariant.Error, - title = if (notOpen) "No wallet open" else "Something went wrong", - description = text, - modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), - ) -} - -/** - * The Activity behind a view's context, for the window flags. - * - * `view.context` is the Activity for a `setContent` root, but a wrapped context - * (a themed wrapper, a `ContextThemeWrapper` from a host) is a real case and - * silently skipping `FLAG_SECURE` because of it would be a silent leak. - */ -private tailrec fun Context.findActivity(): Activity? = when (this) { - is Activity -> this - is ContextWrapper -> baseContext.findActivity() - else -> null -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt deleted file mode 100644 index 4299cc2..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt +++ /dev/null @@ -1,1450 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import android.graphics.Bitmap -import android.graphics.Color -import androidx.compose.foundation.Image -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.aspectRatio -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.material3.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.testTag -import androidx.compose.ui.semantics.contentDescription -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.google.zxing.BarcodeFormat -import com.google.zxing.EncodeHintType -import com.google.zxing.qrcode.QRCodeWriter -import com.siriusdevops.onionwire.WireViewModel -import com.siriusdevops.onionwire.wallet.NO_WALLET_RPC_MESSAGE -import com.siriusdevops.onionwire.wallet.WalletChildBinaryPaths -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwAlertBanner -import com.siriusdevops.onionwire.ui.components.OwAlertVariant -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonRow -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwDivider -import com.siriusdevops.onionwire.ui.components.OwPill -import com.siriusdevops.onionwire.ui.components.OwSectionTitle -import com.siriusdevops.onionwire.ui.components.OwSegmentedControl -import com.siriusdevops.onionwire.ui.components.OwStatusDot -import com.siriusdevops.onionwire.ui.components.OwTopBar -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch -import uniffi.onionwire_sdk.ChainChoice -import uniffi.onionwire_sdk.ChainConfig -import uniffi.onionwire_sdk.FriendInfo -import uniffi.onionwire_sdk.TransferRow -import uniffi.onionwire_sdk.WalletChildStatus - -private enum class PayKind { Invoice, Tip } -private enum class SetupKind { Create, Import } - -/** - * The wallet tab. - * - * Three things changed from the alpha build, and each one is the plan's: - * - * - The page is a hero card and a node card, not a stack of nine equal boxes. - * The balance, the receive address and the two payment actions are the top - * card; the daemon, the network mode and the lifecycle are the second one. - * - Create / Import are the *first* thing on the page while no wallet is open, - * instead of two more outlined twins at the bottom of a long scroll. - * - The raw telemetry is gone from the surface: no daemon-process jargon, no - * `connecting · in-process mainnet pruned · node starting · sync 485253/…` - * string. What is left is a status sentence, a percentage, a progress track - * and two formatted block counts. The full line is still spoken — it is the - * header's `contentDescription` — so nothing an operator needs was deleted, - * it moved behind progressive disclosure. - * - * Behaviour is unchanged. Every callback below is the ViewModel call the old - * screen made; the gate on the seed card, the `shouldReloadWalletReads` key on - * the reload effect and the `openWalletChild` lifetime are untouched, because - * they are state, not layout. - */ -@Composable -fun WalletScreen( - vm: WireViewModel, - onOpenWallets: () -> Unit, -) { - val friends by vm.friends.collectAsStateWithLifecycle() - val child by vm.walletChild.collectAsStateWithLifecycle() - val childError by vm.walletChildError.collectAsStateWithLifecycle() - val starting by vm.walletChildStarting.collectAsStateWithLifecycle() - val chain by vm.chainSource.collectAsStateWithLifecycle() - val seedConfirmed by vm.walletSeedConfirmed.collectAsStateWithLifecycle() - val scope = rememberCoroutineScope() - // Resolved once per composition: the native library directory is fixed for - // the life of the process. - val bins = remember { vm.bundledBinaries() } - val childInput = child?.toInput() - // Free space on the filesystem the in-process chain store grows into. Read - // once per composition of the screen: it is the same filesystem for the life - // of the process, and the number is only a commit-time gate. - val nodeFreeBytes = remember { vm.chainFreeBytes() } - var showQr by remember { mutableStateOf(false) } - var balance by remember { mutableStateOf(null) } - var address by remember { mutableStateOf(null) } - var transfers by remember { mutableStateOf>(emptyList()) } - var error by remember { mutableStateOf(null) } - var composer by remember { mutableStateOf(null) } - var setup by remember { mutableStateOf(null) } - // The seed currently on the blocking card: set by a successful create, or by - // "Back up seed" re-reading it from the wallet process. Null means no card. - // Never persisted and never logged — it is a spend key. - var pendingSeed by remember { mutableStateOf(null) } - var seedConfirm by remember { mutableStateOf("") } - var daemonText by remember { mutableStateOf("") } - var daemonError by remember { mutableStateOf(null) } - // Which pane of the node card's connection selector is open. `null` means - // "follow the stored chain source", which is the honest default: the pane is - // a view of what is configured, not a configuration of its own. It is reset - // whenever the stored source changes, so a started on-device node snaps the - // selector back to its own pane. - var remotePane by remember { mutableStateOf(null) } - - suspend fun reload() { - runCatching { balance = vm.walletBalance() } - .onFailure { error = walletFailureText(it.message ?: it.toString()) } - runCatching { address = vm.walletReceiveAddress() } - runCatching { transfers = vm.walletRecentTransfers(25) } - } - - /** - * "Back up seed": re-read the open wallet's seed from the wallet process and - * put it on the blocking card. This is the only path to a seed that was - * created before this screen existed, so the failure is shown rather than - * swallowed — it is the difference between "the wallet is not running" and - * "there is nothing to recover". - */ - fun openSeedBackup() { - scope.launch { - error = null - vm.walletSeed().fold( - onSuccess = { seed -> - pendingSeed = seed - seedConfirm = "" - }, - onFailure = { error = walletFailureText(it.message ?: it.toString()) }, - ) - } - } - - LaunchedEffect(Unit) { - reload() - vm.refreshChainSource() - // Self-heal before the gate is asked: a stored `wallet_rpc_bin` left by - // an older install can point at a path this device cannot execute, and - // the bundled binary is the right answer for it. The gate below then - // names the path only when no repair was possible. - vm.healStoredWalletBin(bins) - } - - // The same reads again, once the wallet has actually answered. They are - // keyed on `state` alone, never on the whole status record: the 2s poller - // rewrites `height` every tick, and keying on the record would fire this on - // every tick instead of on the one transition that matters. `LaunchedEffect` - // re-runs only when the key changes, so `syncing` → `syncing` does not - // reload. Not while `connecting`: `walletBalance()` answers the string - // `"err"` (it does not throw), and that call is what pins the headline to - // `Balance unavailable`. - LaunchedEffect(childInput?.state) { - if (shouldReloadWalletReads(childInput?.state)) { - reload() - } - } - - // The wallet's 2s refresh loop lives in the ViewModel (like the chat - // poller); this screen only owns its lifetime, so leaving the wallet and - // coming back cannot stack a second loop on the first. - DisposableEffect(Unit) { - vm.openWalletChild() - onDispose { vm.closeWalletChild() } - } - - // Prefill the daemon field from the stored config, never over typing — and - // drop the connection-pane override, so the selector follows the source that - // was just stored. - LaunchedEffect(chain) { - remotePane = null - val stored = chain - if (stored != null && stored.kind == ChainChoice.REMOTE && daemonText.isBlank()) { - daemonText = "${stored.host}:${stored.port}" - } - } - - Scaffold( - // The content root below consumes systemBars ∪ ime itself (see - // `screenContentInsets`); zeroing the Scaffold's own insets keeps the - // navigation bar from being applied twice, and keeps the IME inset out - // of the Scaffold's inner padding. - contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, - topBar = { - // No actions: the catalogue's entry point is in the hero card's - // header, where the plan puts it. A second "Saved wallets" button - // here would be two doors to one screen on the same page. - OwTopBar(title = "Wallet") - }, - ) { pad -> - Column( - Modifier - .padding(pad) - .fillMaxSize() - // systemBars ∪ ime, applied outside the scrolling viewport so - // the inset does not scroll away with the content. - .screenContentInsets() - .verticalScroll(rememberScrollState()), - ) { - // The blocking seed step. While a seed is on screen this card is the - // whole body: no Cancel, and Done stays dead until the confirm word - // is typed, so the one-shot seed cannot be dismissed unread. Leaving - // the tab costs nothing now, because leaving no longer loses the - // seed: the wallet stays unbacked (warning up, receive address - // hidden) until "Back up seed" puts this card back on screen. - val seed = pendingSeed - if (seed != null) { - SeedBackupCard( - seed = seed, - typed = seedConfirm, - onTyped = { seedConfirm = it }, - onDone = { - // The gate owns the transition: a wrong word (which the - // disabled Done button already blocks) cannot confirm. - vm.confirmWalletSeed(seedConfirm) - pendingSeed = null - seedConfirm = "" - }, - ) - error?.let { ErrorLine(it) } - return@Column - } - - // The persistent unbacked strip, above everything else on the page. - // `walletReadable` is the core's own evidence that the wallet has a - // wallet open: `wallet_balance` returns exactly "off" for a chain - // source that was never configured, "err" for a configured one whose - // read failed (no wallet file open yet, or the process is down), and - // a real amount otherwise. The gate uses it only for an install that - // has never created a wallet here, so a first-run user who has - // configured a daemon but not yet created anything is not nagged - // about a seed they do not have. - val walletReadable = balance != null && balance != "off" && balance != "err" - val walletOpen = child?.walletOpen == true - // A sticky failure captured while no wallet was open is not a - // failure once one is: drop it, so the red line does not outlive - // the state that produced it. - LaunchedEffect(walletOpen) { - if (walletOpen) vm.clearWalletChildError() - } - val unbacked = SeedBackupGate.warningVisible(seedConfirmed, walletReadable) - if (unbacked) { - UnbackedSeedCard(error = error, onBackUpSeed = { openSeedBackup() }) - } - - val phase = walletChildPhase(childInput) - // Create and Import are RPC calls against the running child. With no - // child up they can only fail, and the failure is the TUI's `open F7` - // copy — so the controls stay dead and say why instead. - val setupBlocked = walletSetupBlockedReason(childInput) - WalletHeroCard( - balance = balance, - address = address, - walletOpen = walletOpen, - phase = phase, - showQr = showQr, - setupBlocked = setupBlocked, - onToggleQr = { showQr = !showQr }, - onOpenWallets = onOpenWallets, - onCreate = { if (setupBlocked == null) setup = SetupKind.Create }, - onImport = { if (setupBlocked == null) setup = SetupKind.Import }, - onInvoice = { composer = PayKind.Invoice }, - onTip = { composer = PayKind.Tip }, - onBackUpSeed = if ( - walletReadable && !SeedBackupGate.warningVisible(seedConfirmed, walletReadable) - ) { - { openSeedBackup() } - } else { - null - }, - onLock = { scope.launch { vm.stopWalletChild() } }, - ) - - NodeCard( - bins = bins, - input = childInput, - chain = chain, - nodeFreeBytes = nodeFreeBytes, - actionError = childError, - daemonText = daemonText, - daemonError = daemonError, - walletOpen = walletOpen, - needsPassphrase = child?.needsPassphrase == true, - starting = starting, - remotePane = remotePane ?: !isInProcessSource(childInput, chain), - onSelectPane = { wantsRemote -> - remotePane = wantsRemote - daemonError = null - }, - onDaemonText = { - daemonText = it - daemonError = null - }, - onSaveDaemon = { - val parsed = parseDaemonAddress(daemonText) - if (parsed == null) { - daemonError = "Type the daemon as host:port, e.g. 127.0.0.1:18089." - } else { - daemonError = null - scope.launch { - vm.saveRemoteDaemon(parsed.host, parsed.port, bins) - .onFailure { daemonError = walletFailureText(it.message ?: it.toString()) } - } - } - }, - onReceiveOnly = { - daemonError = null - scope.launch { - vm.setReceiveOnly(bins) - .onFailure { daemonError = walletFailureText(it.message ?: it.toString()) } - } - }, - onInProcessNode = { mainnet, prune -> - daemonError = null - scope.launch { - vm.setInProcessCuprate(bins, mainnet, prune) - .onFailure { daemonError = walletFailureText(it.message ?: it.toString()) } - .onSuccess { - // Selecting a mode stores it and, when the - // storage floor *and* the Start gate would allow - // a launch, starts the node. The stored binary is - // what the just-saved config holds; the gate - // asks it the same question Start does, so a - // mode tap can never launch a child Start would - // have refused. - if (shouldStartAfterSelectingChain( - chainStorageBlockedReason( - vm.chainFreeBytes(), - mainnet = mainnet, - prune = prune, - ), - starting = starting, - startBlocked = storedWalletBinBlockedReason( - bins.walletRpc, - bins.walletRpc, - ), - ) - ) { - vm.startWalletChild() - } - } - } - }, - onStart = { vm.startWalletChild() }, - onStop = { scope.launch { vm.stopWalletChild() } }, - ) - - if (transfers.isNotEmpty()) { - Column(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp)) { - Label("RECENT TRANSFERS") - Spacer(Modifier.height(8.dp)) - Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { - transfers.forEach { t -> TransferCard(t) } - } - } - } - - val kind = composer - val setupKind = setup - when { - kind != null -> PayComposer( - kind = kind, - friends = friends, - onCancel = { composer = null }, - onSend = { pk, amount, memo -> - scope.launch { - error = null - val result = when (kind) { - PayKind.Invoice -> vm.sendInvoice(pk, amount, memo) - PayKind.Tip -> vm.sendTip(pk, amount, memo) - } - result.fold( - onSuccess = { - composer = null - reload() - }, - onFailure = { error = walletFailureText(it.message ?: it.toString()) }, - ) - } - }, - ) - - setupKind != null -> WalletSetupCard( - kind = setupKind, - warning = vm.spendAuthorityWarning(), - onCancel = { setup = null }, - onCreated = { seed -> - setup = null - // The card is the whole body from here until SEEN. - pendingSeed = seed - seedConfirm = "" - scope.launch { reload() } - }, - onImported = { - setup = null - scope.launch { reload() } - }, - onError = { error = walletFailureText(it) }, - create = { pw -> vm.createWallet(pw) }, - importWallet = { pw, seed -> vm.importWallet(pw, seed) }, - scope = scope, - ) - } - - // While the strip is up the error belongs next to the button that - // caused it: this page is one long scroll and the node card sits - // between the strip and the bottom, so a failed `wallet_seed` read - // would otherwise land off-screen. - if (!unbacked) { - error?.let { ErrorLine(it) } - } - - Spacer(Modifier.height(16.dp)) - } - } -} - -/** - * The wallet at a glance: a balance, a receive address, and the four things a - * person actually does here. - * - * Two states, and the switch is the core's own `wallet_open` — not "is a chain - * source configured", which is a different question and answers yes for a - * receive-only install that has no wallet file at all. - */ -@Composable -private fun WalletHeroCard( - balance: String?, - address: String?, - walletOpen: Boolean, - phase: WalletChildPhase, - showQr: Boolean, - /** - * Why Create / Import cannot be offered yet, or `null` when they can. From - * [walletSetupBlockedReason]: both flows are RPC calls against a running - * wallet child, so a stopped child is a dead end the screen may not offer. - */ - setupBlocked: String?, - onToggleQr: () -> Unit, - onOpenWallets: () -> Unit, - onCreate: () -> Unit, - onImport: () -> Unit, - onInvoice: () -> Unit, - onTip: () -> Unit, - onBackUpSeed: (() -> Unit)?, - onLock: () -> Unit, -) { - OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), - ) { - Row( - Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - Row(verticalAlignment = Alignment.CenterVertically) { - OwStatusDot( - when { - !walletOpen -> OwColors.TextMuted - phase is WalletChildPhase.Ready -> OwColors.Accent - else -> OwColors.Warning - }, - ) - Spacer(Modifier.width(8.dp)) - OwSectionTitle(if (walletOpen) "Wallet" else "No Wallet Active") - } - OwButton( - text = "Saved wallets", - variant = OwButtonVariant.Outline, - onClick = onOpenWallets, - ) - } - Spacer(Modifier.height(12.dp)) - - if (!walletOpen) { - // The §4.1 replacement for the old `wallet off` string, kept as a - // value line rather than a second heading: the card already says - // "No Wallet Active", and "off" vs "err" is the difference between - // "nothing is configured" and "configured, but the read failed". - Text( - noWalletBalanceHeadline(balance), - style = MaterialTheme.typography.titleMedium, - color = OwColors.TextSecondary, - modifier = Modifier.testTag("wallet-balance"), - ) - Spacer(Modifier.height(6.dp)) - Text( - "Create a new Monero wallet or restore an existing seed.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(16.dp)) - OwButtonRow { - OwButton( - text = "Create Wallet", - variant = OwButtonVariant.Primary, - enabled = setupBlocked == null, - onClick = onCreate, - modifier = Modifier.weight(1f).testTag("wallet-create"), - ) - OwButton( - text = "Import Wallet", - variant = OwButtonVariant.Secondary, - enabled = setupBlocked == null, - onClick = onImport, - modifier = Modifier.weight(1f).testTag("wallet-import"), - ) - } - // Why the two flows are dead, in a sentence rather than a grey pair - // of buttons. The only fix is on the node card below, so the copy - // points there. - setupBlocked?.let { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Wallet not running", - description = it, - modifier = Modifier.testTag("wallet-setup-blocked"), - ) - } - // Invoicing does not need a wallet file: the core resolves the payee - // address from the profile (`no receive address — set profile xmr or - // ONIONWIRE_WALLET_RPC` is the both-missing case). Hiding the action - // in this state would remove a path that works, so it stays — as a - // text action, not a third button competing with Create. A tip - // genuinely needs the wallet (it calls `Wallet::transfer`), so it - // only appears once one is open. - TextButton(onClick = onInvoice) { Text("Send an invoice") } - return@OwCard - } - - // A wallet is open: the balance is the headline, 28sp bold, sans — it is - // money, not cryptographic material, so it is not monospaced. - Text( - noWalletBalanceHeadline(balance), - style = MaterialTheme.typography.displaySmall, - color = OwColors.TextPrimary, - modifier = Modifier.testTag("wallet-balance"), - ) - Spacer(Modifier.height(6.dp)) - OwPill( - text = phase.label, - textColor = when (phase) { - WalletChildPhase.Ready -> OwColors.Accent - is WalletChildPhase.Exited, is WalletChildPhase.Unrecognised -> OwColors.Danger - else -> OwColors.Warning - }, - container = when (phase) { - WalletChildPhase.Ready -> OwColors.InfoTint - is WalletChildPhase.Exited, is WalletChildPhase.Unrecognised -> OwColors.DangerTint - else -> OwColors.WarningTint - }, - borderColor = when (phase) { - WalletChildPhase.Ready -> OwColors.InfoBorder - is WalletChildPhase.Exited, is WalletChildPhase.Unrecognised -> OwColors.DangerBorder - else -> OwColors.WarningBorder - }, - dotColor = when (phase) { - WalletChildPhase.Ready -> OwColors.Accent - is WalletChildPhase.Exited, is WalletChildPhase.Unrecognised -> OwColors.Danger - else -> OwColors.Warning - }, - ) - - // Hidden until the seed is confirmed written down: XMR into a wallet - // whose 25 words were never recorded is unrecoverable, so the address - // and its QR are gated, not just warned about. - val addr = address - if (addr != null) { - Spacer(Modifier.height(16.dp)) - OwDivider() - Spacer(Modifier.height(12.dp)) - Label("RECEIVE ADDRESS") - Spacer(Modifier.height(4.dp)) - Mono(addr, modifier = Modifier.fillMaxWidth(), color = OwColors.TextPrimary) - TextButton(onClick = onToggleQr) { Text(if (showQr) "Hide QR" else "Show QR") } - if (showQr) { - val qr = remember(addr) { generateQrBitmap(addr) } - qr?.let { bm -> - Box( - modifier = Modifier - .fillMaxWidth() - .aspectRatio(1f) - .border(1.dp, OwColors.Border, RoundedCornerShape(OwRadius.Control)) - .padding(8.dp), - contentAlignment = Alignment.Center, - ) { - Image( - bitmap = bm.asImageBitmap(), - contentDescription = "QR code for receive address", - modifier = Modifier.fillMaxSize(), - contentScale = ContentScale.Fit, - ) - } - } - } - } - - Spacer(Modifier.height(16.dp)) - OwButtonRow { - OwButton( - text = "Receive / Invoice", - variant = OwButtonVariant.Primary, - onClick = onInvoice, - modifier = Modifier.weight(1f), - ) - OwButton( - text = "Send / Tip", - variant = OwButtonVariant.Secondary, - onClick = onTip, - modifier = Modifier.weight(1f), - ) - } - Spacer(Modifier.height(8.dp)) - OwButtonRow { - // Creating a second wallet and importing a third are real flows - // (each wallet gets its own file, and the catalogue lists them), so - // both stay reachable once the first one is open — they just stop - // being the loudest thing on the page. - OwButton( - text = "New wallet", - variant = OwButtonVariant.Outline, - enabled = setupBlocked == null, - onClick = onCreate, - modifier = Modifier.weight(1f).testTag("wallet-create"), - ) - OwButton( - text = "Import wallet", - variant = OwButtonVariant.Outline, - enabled = setupBlocked == null, - onClick = onImport, - modifier = Modifier.weight(1f).testTag("wallet-import"), - ) - } - setupBlocked?.let { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Wallet not running", - description = it, - modifier = Modifier.testTag("wallet-setup-blocked"), - ) - } - // The recovery path for a wallet whose seed was missed: a quiet action, - // because a healthy wallet needs it rarely and a seed is a spend key. - // While the seed is unconfirmed the strip above carries the button - // instead, so exactly one is ever on screen. - if (onBackUpSeed != null) { - TextButton( - onClick = onBackUpSeed, - modifier = Modifier.testTag("wallet-seed-backup-action"), - ) { Text("Back up seed") } - } - Spacer(Modifier.height(8.dp)) - OwButton( - text = "Lock Wallet", - variant = OwButtonVariant.Destructive, - onClick = onLock, - modifier = Modifier.fillMaxWidth().testTag("wallet-lock"), - ) - } -} - -/** - * The node and the daemon: one status header, one progress track, one choice of - * where the chain comes from, and one lifecycle control. - * - * The single most important property of this card is that it never asserts a - * state the core did not report. `target_height == 0` prints no percentage, an - * unrecognised state is never green, and a running process whose RPC has not - * answered is `Connecting…`, not `Wallet Ready`. - */ -@Composable -private fun NodeCard( - bins: WalletChildBinaryPaths, - input: WalletChildInput?, - chain: ChainConfig?, - nodeFreeBytes: Long?, - actionError: String?, - daemonText: String, - daemonError: String?, - /** - * The core's `wallet_open` / `needs_passphrase`, straight off the same - * `WalletChildStatus` the status header is drawn from — not a second idea of - * which wallet is open. - */ - walletOpen: Boolean, - needsPassphrase: Boolean, - starting: Boolean, - /** Which pane the connection selector shows; the caller owns the override. */ - remotePane: Boolean, - onSelectPane: (Boolean) -> Unit, - onDaemonText: (String) -> Unit, - onSaveDaemon: () -> Unit, - onReceiveOnly: () -> Unit, - onInProcessNode: (mainnet: Boolean, prune: Boolean) -> Unit, - onStart: () -> Unit, - onStop: () -> Unit, -) { - val inProcess = isInProcessSource(input, chain) - val head = nodeStatusHead( - input, - inProcess = inProcess, - mainnet = chain?.mainnet == true, - prune = chain?.prune == true, - ) - val progress = syncProgress(input?.height ?: 0uL, input?.targetHeight ?: 0uL) - val node = nodePhase(input) - val onionDaemon = chain?.kind == ChainChoice.REMOTE && isOnionHost(chain.host) - // The full gate: eligibility *and* the stored binary this build will - // actually spawn. A populated `bins` alone used to pass, which is how a - // stored bare name got as far as `spawn` and failed with ENOENT. - val startWhy = startGateReason(bins, input, chain?.walletRpcBin, onionDaemon, starting) - ?: if (inProcess) { - chainStorageBlockedReason( - nodeFreeBytes, - mainnet = chain?.mainnet == true, - prune = chain?.prune == true, - ) - } else { - null - } - val stopWhy = stopBlockedReason(input) - // A live wallet with no wallet file open answers every read with the - // daemon's own `-13 No wallet file`. Say that in this app's words, here, - // rather than letting the raw string arrive later on whichever card asked. - val openHint = walletChildOpenHint( - childRunning = input?.running == true, - walletOpen = walletOpen, - needsPassphrase = needsPassphrase, - ) - val running = input?.running == true - - OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), - ) { - // --- the status header ------------------------------------------------ - Row( - Modifier - .fillMaxWidth() - .testTag(walletChildPhase(input).testTag) - .semantics(mergeDescendants = true) { - // The whole raw line — `syncing · in-process mainnet pruned - // · node syncing · sync 485253/3794383` — is still spoken. - // A screen reader is never told less than the sighted user. - contentDescription = walletChildStatusDescription(input) - }, - verticalAlignment = Alignment.CenterVertically, - ) { - OwStatusDot( - when (head.tone) { - NodeStatusTone.Idle -> OwColors.TextMuted - NodeStatusTone.Busy -> OwColors.Warning - NodeStatusTone.Good -> OwColors.Accent - NodeStatusTone.Bad -> OwColors.Danger - }, - ) - Spacer(Modifier.width(8.dp)) - Text( - head.title, - style = MaterialTheme.typography.titleMedium, - color = OwColors.TextPrimary, - modifier = Modifier.weight(1f), - ) - progress.percentText?.let { pct -> - Mono(pct, color = OwColors.TextSecondary) - } - } - - // --- the progress track ---------------------------------------------- - if (progress.blockText != null) { - Spacer(Modifier.height(10.dp)) - Box( - Modifier - .fillMaxWidth() - .height(OwSize.ProgressTrack) - .clip(RoundedCornerShape(OwRadius.Pill)) - .background(OwColors.SurfaceInteractive), - ) { - Box( - Modifier - .fillMaxWidth(progress.fraction) - .height(OwSize.ProgressTrack) - .clip(RoundedCornerShape(OwRadius.Pill)) - .background(OwColors.Accent), - ) - } - Spacer(Modifier.height(6.dp)) - Row( - Modifier.fillMaxWidth().testTag("wallet-chain-progress"), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Text( - progress.blockText, - style = MonoStyle.copy(fontSize = 12.sp, color = OwColors.TextSecondary), - ) - Text( - nodeFreeBytes?.let { "${formatBytes(it)} free" } ?: "free space unknown", - style = MonoStyle.copy(fontSize = 12.sp, color = OwColors.TextSecondary), - ) - } - } - - // The node's own word, when there is one, as its own assertable line: - // an unrecognised node state can never be read as ready. - if (node !is NodePhase.Absent) { - Spacer(Modifier.height(6.dp)) - Text( - "node: ${node.label}", - style = MonoStyle.copy(fontSize = 12.sp, color = OwColors.TextSecondary), - modifier = Modifier - .fillMaxWidth() - .testTag(node.testTag) - .semantics(mergeDescendants = true) { - contentDescription = node.contentDescription - }, - ) - } - - Spacer(Modifier.height(12.dp)) - OwDivider() - Spacer(Modifier.height(12.dp)) - - // --- where the chain comes from --------------------------------------- - Label("CONNECTION TYPE") - Spacer(Modifier.height(8.dp)) - OwSegmentedControl( - options = listOf("Remote Node", "On-Device Node"), - selectedIndex = if (remotePane) 0 else 1, - onSelect = { onSelectPane(it == 0) }, - testTags = listOf("wallet-connection-remote", "wallet-connection-on-device"), - ) - - if (remotePane) { - Spacer(Modifier.height(12.dp)) - OutlinedTextField( - value = daemonText, - onValueChange = onDaemonText, - singleLine = true, - label = { Text("daemon host:port") }, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-daemon-input"), - ) - Spacer(Modifier.height(4.dp)) - Text( - "LAN (e.g. 192.168.1.20:18089) or a public clearnet node.", - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(10.dp)) - OwButtonRow { - OwButton( - text = "Save Daemon", - variant = OwButtonVariant.Secondary, - onClick = onSaveDaemon, - enabled = bins.walletRpcBundled, - modifier = Modifier.weight(1f).testTag("wallet-daemon-save"), - ) - OwButton( - text = "Receive-Only", - variant = OwButtonVariant.Outline, - onClick = onReceiveOnly, - modifier = Modifier.weight(1f).testTag("wallet-daemon-receive-only"), - ) - } - } else { - Spacer(Modifier.height(12.dp)) - Label("NETWORK MODE") - Spacer(Modifier.height(8.dp)) - val mode = selectedCuprateMode( - inProcess = true, - mainnet = chain?.mainnet == true, - prune = chain?.prune == true, - ) - OwSegmentedControl( - options = listOf("Pruned", "Full", "Testnet"), - selectedIndex = when (mode) { - CuprateMode.MainnetFull -> 1 - CuprateMode.Testnet -> 2 - // MainnetPruned, and the not-in-process case before anything - // is stored: the pruned store is the conservative default. - else -> 0 - }, - onSelect = { index -> - when (index) { - 0 -> onInProcessNode(true, true) - 1 -> onInProcessNode(true, false) - else -> onInProcessNode(false, false) - } - }, - testTags = listOf( - "wallet-chain-mainnet-pruned", - "wallet-chain-mainnet-full", - "wallet-chain-in-process", - ), - ) - Spacer(Modifier.height(10.dp)) - OwAlertBanner( - variant = OwAlertVariant.Warning, - title = CUPRATE_ON_DEVICE_TITLE, - description = CUPRATE_ON_DEVICE_BODY, - modifier = Modifier.testTag("wallet-cuprate-warning"), - ) - Spacer(Modifier.height(8.dp)) - Text( - chainStorageLine( - nodeFreeBytes, - mainnet = chain?.mainnet == true, - prune = chain?.prune == true, - ), - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextSecondary, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-chain-storage"), - ) - } - - // --- the lifecycle ---------------------------------------------------- - Spacer(Modifier.height(16.dp)) - if (starting) { - OwButton( - text = "Starting…", - variant = OwButtonVariant.Primary, - enabled = false, - onClick = {}, - modifier = Modifier.fillMaxWidth().testTag("wallet-child-start"), - ) - } else if (running) { - OwButton( - text = "Stop Node", - variant = OwButtonVariant.Destructive, - enabled = stopWhy == null, - onClick = onStop, - modifier = Modifier.fillMaxWidth().testTag("wallet-child-stop"), - ) - } else { - OwButton( - text = "Start Node & Wallet", - variant = OwButtonVariant.Primary, - enabled = startWhy == null, - onClick = onStart, - modifier = Modifier.fillMaxWidth().testTag("wallet-child-start"), - ) - } - - // --- what is wrong, in banners rather than paragraphs ----------------- - if (starting) { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Starting", - description = STARTING_CHILD_NOTICE, - ) - } - - // Why Start is dead, in the core's terms rather than a grey button. - if (!starting && !running) { - startWhy?.let { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Not ready to start", - description = it, - modifier = Modifier.testTag("wallet-child-start-blocked"), - ) - } - } - - if (!bins.walletRpcBundled) { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "No wallet binary", - description = NO_WALLET_RPC_MESSAGE, - ) - } - - // "No wallet file open" is a state of a live wallet, not a failure of - // the last call, so it is said here rather than left to surface as the - // daemon's `-13` on whichever card asked for a read. - openHint?.let { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "No wallet open", - description = it, - modifier = Modifier.testTag("wallet-child-no-wallet"), - ) - } - - // The last thing the core or the RPC call said. Sticky until the user - // acts, like the chat screen's load error. Filtered through - // `walletFailureText`: the daemon's own `-13 No wallet file` / JSON - // answer is not a sentence about this app and never reaches the screen. - // - // "No wallet open" is a state, not a failure: the info banner above - // already owns it, so it is not painted red and not printed twice. - val failure = walletFailureText(input?.lastError) ?: actionError ?: daemonError - failure?.let { - walletFailureBanner( - text = it, - openHintVisible = openHint != null, - walletOpen = walletOpen, - )?.let { banner -> - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = if (banner.tone == WalletFailureTone.Info) { - OwAlertVariant.Info - } else { - OwAlertVariant.Error - }, - title = banner.title, - description = banner.text, - modifier = Modifier.testTag("wallet-child-error"), - ) - } - } - } -} - -/** - * True when the stored chain source (or the live status, before the store is - * re-read) is the app's own node. The connection selector and the network-mode - * control both key off this one predicate. - */ -private fun isInProcessSource(input: WalletChildInput?, chain: ChainConfig?): Boolean = - input?.chainInProcess == true || chain?.kind == ChainChoice.IN_PROCESS_CUPRATE - -/** The one error line every wallet action shares, as a banner. */ -@Composable -private fun ErrorLine(text: String) { - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "Something went wrong", - description = text, - modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), - ) -} - -/** - * The persistent unbacked strip: up at the top of the wallet screen from the - * moment a create succeeds until the seed is confirmed written down, and again - * on any install whose wallet predates the flag. - * - * It is not a toast and not a dialog — leaving the screen does not dismiss it, - * because the state it reports is the wallet's, not the screen's. Its button is - * the recovery path for a seed that was created before the user knew to look. - */ -@Composable -private fun UnbackedSeedCard( - error: String?, - onBackUpSeed: () -> Unit, -) { - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "This wallet is not backed up", - description = SeedBackupGate.WARNING, - modifier = Modifier - .padding(horizontal = 16.dp, vertical = 8.dp) - .testTag("wallet-seed-warning"), - action = { - OwButton( - text = "Back up seed", - variant = OwButtonVariant.Outline, - onClick = onBackUpSeed, - modifier = Modifier.testTag("wallet-seed-backup-action"), - ) - }, - ) - error?.let { ErrorLine(it) } -} - -/** - * The blocking seed step: the 25 words, and a Done that is dead until the - * confirm word is typed. - * - * There is no Cancel and no copy button. No Cancel, because a seed this card is - * showing for the first time has never been written down anywhere else, so - * dismissing it unread is how a wallet becomes unrecoverable. No copy button, - * because the Android clipboard is readable by every other app on the device - * (and by the clipboard history on Android 13+), which would hand the spend key - * to whoever asks for it next. - * - * The seed is a Kotlin `String`, so it cannot be wiped in place the way the - * TUI's `Zeroizing` is; dropping the reference is the strongest thing - * available here. That is another reason it is never written to disk. - * - * `internal` rather than `private`: the saved-wallets screen shows the same - * card for the open wallet's recovery phrase, and a second copy of this gate - * (or of its constants) is the thing that would eventually disagree with this - * one. - */ -@Composable -internal fun SeedBackupCard( - seed: String, - typed: String, - onTyped: (String) -> Unit, - onDone: () -> Unit, -) { - OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(16.dp) - .testTag("wallet-seed-card"), - ) { - OwSectionTitle("Back up this seed") - Spacer(Modifier.height(8.dp)) - Text( - "These 25 words are the only way to recover this wallet, and anyone who " + - "reads them can spend it. Write them down now — this is the only copy.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(12.dp)) - Mono( - seed, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-seed-words"), - ) - Spacer(Modifier.height(16.dp)) - Text( - "Type ${SeedBackupGate.CONFIRM_WORD} to confirm you have written it down.", - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(4.dp)) - OutlinedTextField( - value = typed, - onValueChange = onTyped, - singleLine = true, - label = { Text("type ${SeedBackupGate.CONFIRM_WORD}") }, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-seed-confirm-input"), - ) - Spacer(Modifier.height(10.dp)) - OwButton( - text = "Done", - variant = OwButtonVariant.Primary, - enabled = SeedBackupGate.confirmEnabled(typed), - onClick = onDone, - modifier = Modifier.testTag("wallet-seed-confirm-done"), - ) - } -} - -@Composable -private fun TransferCard(t: TransferRow) { - OwCard(modifier = Modifier.fillMaxWidth(), padding = 12.dp) { - Row( - Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - Column(Modifier.weight(1f)) { - Mono(t.txid.take(16) + "…", color = OwColors.TextSecondary) - Spacer(Modifier.height(2.dp)) - Mono( - t.address.take(12) + "…" + t.address.takeLast(4), - color = OwColors.TextMuted, - ) - } - Spacer(Modifier.width(12.dp)) - Text( - t.amount, - style = MaterialTheme.typography.titleSmall, - color = OwColors.TextPrimary, - textAlign = TextAlign.End, - ) - } - } -} - -@Composable -private fun PayComposer( - kind: PayKind, - friends: List, - onCancel: () -> Unit, - onSend: (pubkeyHex: String, amount: String, memo: String) -> Unit, -) { - var selected by remember { - mutableStateOf(friends.singleOrNull()?.pubkeyHex) - } - var amount by remember { mutableStateOf("") } - var memo by remember { mutableStateOf("") } - val ready = selected != null && amount.trim().isNotEmpty() - - OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), - ) { - OwSectionTitle(if (kind == PayKind.Invoice) "Send invoice" else "Send tip") - Spacer(Modifier.height(8.dp)) - if (friends.isEmpty()) { - Text( - "Add a contact first. Invoice and tip are one-shot to a peer onion.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - } else { - Label("TO") - friends.forEach { f -> - val label = f.petname?.takeIf { it.isNotBlank() } ?: f.fingerprint - TextButton(onClick = { selected = f.pubkeyHex }) { - Text(if (selected == f.pubkeyHex) "• $label" else label) - } - } - } - Spacer(Modifier.height(4.dp)) - OutlinedTextField( - value = amount, - onValueChange = { amount = it }, - singleLine = true, - label = { Text("amount XMR") }, - modifier = Modifier.fillMaxWidth(), - ) - Spacer(Modifier.height(8.dp)) - OutlinedTextField( - value = memo, - onValueChange = { memo = it }, - singleLine = true, - label = { Text("memo (optional)") }, - modifier = Modifier.fillMaxWidth(), - ) - Spacer(Modifier.height(12.dp)) - OwButtonRow { - OwButton( - text = "Cancel", - variant = OwButtonVariant.Outline, - onClick = onCancel, - modifier = Modifier.weight(1f), - ) - OwButton( - text = "Send", - variant = OwButtonVariant.Primary, - enabled = ready, - onClick = { - // Dead button without a recipient, and `ready` says so; the - // null check is only here because `selected` is nullable. - val pk = selected - if (pk != null) onSend(pk, amount.trim(), memo.trim()) - }, - modifier = Modifier.weight(1f), - ) - } - } -} - -@Composable -private fun WalletSetupCard( - kind: SetupKind, - warning: String, - onCancel: () -> Unit, - onCreated: (String) -> Unit, - onImported: () -> Unit, - onError: (String) -> Unit, - create: suspend (String) -> Result, - importWallet: suspend (String, String) -> Result, - scope: CoroutineScope, -) { - var accepted by remember { mutableStateOf(kind != SetupKind.Create) } - var password by remember { mutableStateOf("") } - var seed by remember { mutableStateOf("") } - val ready = password.isNotEmpty() && (kind == SetupKind.Create || seed.isNotBlank()) - - OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), - ) { - OwSectionTitle(if (kind == SetupKind.Create) "Create wallet" else "Import wallet") - Spacer(Modifier.height(8.dp)) - if (kind == SetupKind.Create && !accepted) { - Text(warning, style = MaterialTheme.typography.bodySmall, color = OwColors.TextSecondary) - Spacer(Modifier.height(12.dp)) - OwButtonRow { - OwButton( - text = "Cancel", - variant = OwButtonVariant.Outline, - onClick = onCancel, - modifier = Modifier.weight(1f), - ) - OwButton( - text = "I accept spend authority", - variant = OwButtonVariant.Primary, - onClick = { accepted = true }, - modifier = Modifier.weight(1f), - ) - } - return@OwCard - } - if (kind == SetupKind.Import) { - Text( - "Paste the 25-word seed. Create does not need a key.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(8.dp)) - OutlinedTextField( - value = seed, - onValueChange = { seed = it }, - label = { Text("seed") }, - modifier = Modifier.fillMaxWidth(), - ) - Spacer(Modifier.height(8.dp)) - } - OutlinedTextField( - value = password, - onValueChange = { password = it }, - singleLine = true, - label = { Text("wallet passphrase") }, - modifier = Modifier.fillMaxWidth(), - ) - Spacer(Modifier.height(12.dp)) - OwButtonRow { - OwButton( - text = "Cancel", - variant = OwButtonVariant.Outline, - onClick = onCancel, - modifier = Modifier.weight(1f), - ) - OwButton( - text = if (kind == SetupKind.Create) "Create" else "Import", - variant = OwButtonVariant.Primary, - enabled = ready, - onClick = { - scope.launch { - when (kind) { - SetupKind.Create -> create(password).fold( - onSuccess = onCreated, - onFailure = { onError(it.message ?: it.toString()) }, - ) - SetupKind.Import -> importWallet(password, seed.trim()).fold( - onSuccess = { onImported() }, - onFailure = { onError(it.message ?: it.toString()) }, - ) - } - } - }, - modifier = Modifier.weight(1f), - ) - } - } -} - -/** - * Whether the wallet screen's reads (balance, address, recent transfers) should - * be reloaded for a given child state. - * - * Only the two states in which the wallet RPC has actually answered count. - * `walletBalance()` returns the string `"err"` rather than throwing when it - * cannot read, so a reload during `connecting` / `off` / `exited` is not a - * no-op — it is what writes that `err` into the headline and leaves it stuck on - * `Balance unavailable` after the wallet comes up. - */ -internal fun shouldReloadWalletReads(state: String?): Boolean { - val s = state?.trim()?.lowercase() - return s == "syncing" || s == "ready" -} - -/** - * The SDK record as the pure model `WalletChildStatusText.kt` renders. Field for - * field, nothing inferred. - * - * `lastError` is the one field that is not verbatim. It is the core's - * `wallet_status().last_error`, which is the *daemon's* own words on the path - * this screen exists for: a live wallet with no wallet file open answers `-13 - * No wallet file`, and `parse_json_rpc` strips the envelope and keeps that bare - * sentence. A probe that dialled a port the wallet had not bound yet can also - * land here (`wallet connect: Connection refused`) — [displayLastError] drops - * that one while the wallet is still `connecting`. The status header renders - * this field through `walletChildStatusDescription` for the screen reader — so - * the filter belongs here, at the seam where the SDK record becomes the Kotlin - * model, rather than at one of the render sites. `walletFailureText` is - * idempotent on its own replacement texts, so the second pass on the sticky - * error card is stable. - */ -internal fun WalletChildStatus.toInput(): WalletChildInput = WalletChildInput( - state = state, - running = running, - configured = configured, - chainSource = chainSource, - chainInProcess = chainInProcess, - nodeAvailable = nodeAvailable, - nodeState = nodeState, - height = height, - targetHeight = targetHeight, - lastError = displayLastError(state, lastError), -) - -/** Generate a QR bitmap for the given URI string. Returns null on encode failure. */ -internal fun generateQrBitmap(uri: String): Bitmap? { - return try { - val hints = mapOf(EncodeHintType.MARGIN to 1) - val writer = QRCodeWriter() - val matrix = writer.encode(uri, BarcodeFormat.QR_CODE, 512, 512, hints) - val buf = Bitmap.createBitmap(matrix.width, matrix.height, Bitmap.Config.ARGB_8888) - for (y in 0 until matrix.height) { - for (x in 0 until matrix.width) { - buf.setPixel(x, y, if (matrix.get(x, y)) Color.BLACK else Color.WHITE) - } - } - buf - } catch (_: Exception) { - null - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AlertBanner.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AlertBanner.kt deleted file mode 100644 index a7cbb3f..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AlertBanner.kt +++ /dev/null @@ -1,103 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** Banner severity. Three states, matching the status colours exactly. */ -enum class OwAlertVariant { Warning, Error, Info } - -/** - * A contextual banner: status icon, one-line title, one- or two-line body. - * - * Replaces the raw red and grey paragraphs that used to trail the wallet and - * invite screens. A state the app is *in* (no wallet open, node experimental) is - * an info or warning banner; only a real failure gets [OwAlertVariant.Error]. - */ -@Composable -fun OwAlertBanner( - variant: OwAlertVariant, - title: String, - description: String? = null, - modifier: Modifier = Modifier, - action: (@Composable () -> Unit)? = null, -) { - val text: Color = when (variant) { - OwAlertVariant.Warning -> OwColors.Warning - OwAlertVariant.Error -> OwColors.Danger - OwAlertVariant.Info -> OwColors.TextPrimary - } - val tint: Color = when (variant) { - OwAlertVariant.Warning -> OwColors.WarningTint - OwAlertVariant.Error -> OwColors.DangerTint - OwAlertVariant.Info -> OwColors.InfoTint - } - val border: Color = when (variant) { - OwAlertVariant.Warning -> OwColors.WarningBorder - OwAlertVariant.Error -> OwColors.DangerBorder - OwAlertVariant.Info -> OwColors.InfoBorder - } - val iconRes = when (variant) { - OwAlertVariant.Warning -> R.drawable.ic_ow_warning - OwAlertVariant.Error -> R.drawable.ic_ow_warning - OwAlertVariant.Info -> R.drawable.ic_ow_info - } - val iconTint = when (variant) { - OwAlertVariant.Info -> OwColors.Accent - else -> text - } - - Row( - modifier = modifier - .fillMaxWidth() - .clip(RoundedCornerShape(OwRadius.Control)) - .background(tint) - .border(1.dp, border, RoundedCornerShape(OwRadius.Control)) - .padding(horizontal = 14.dp, vertical = 12.dp), - horizontalArrangement = Arrangement.Start, - ) { - Icon( - painter = painterResource(iconRes), - contentDescription = null, - tint = iconTint, - modifier = Modifier.padding(top = 1.dp).size(18.dp), - ) - Spacer(Modifier.width(10.dp)) - Column(Modifier.weight(1f)) { - Text(title, style = MaterialTheme.typography.titleSmall, color = text) - if (!description.isNullOrBlank()) { - Spacer(Modifier.height(3.dp)) - Text( - description, - style = MaterialTheme.typography.bodySmall, - color = if (variant == OwAlertVariant.Info) OwColors.TextSecondary else text, - ) - } - if (action != null) { - Spacer(Modifier.height(10.dp)) - action() - } - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AppTopBar.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AppTopBar.kt deleted file mode 100644 index 3c3e1c7..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AppTopBar.kt +++ /dev/null @@ -1,79 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.RowScope -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.statusBarsPadding -import androidx.compose.foundation.layout.width -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors - -/** - * The app's one top bar. - * - * Deliberately not `TopAppBar`: that component is a fixed height single line, and - * this header carries a second row (the `● Tor active` pill). A custom column - * also keeps the status-bar inset inside the bar's own background instead of - * padding the screen underneath it. - * - * On a sub-screen the navigation slot is a chevron icon button, never the word - * "Back". - */ -@Composable -fun OwTopBar( - title: String, - modifier: Modifier = Modifier, - onBack: (() -> Unit)? = null, - status: (@Composable () -> Unit)? = null, - actions: @Composable RowScope.() -> Unit = {}, -) { - Column( - modifier = modifier - .fillMaxWidth() - .background(OwColors.Canvas) - .statusBarsPadding() - .padding(start = 16.dp, end = 16.dp, top = 10.dp, bottom = 10.dp), - ) { - Row(verticalAlignment = Alignment.CenterVertically) { - if (onBack != null) { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - tint = OwColors.TextPrimary, - background = OwColors.SurfaceInteractive, - ) - Spacer(Modifier.width(12.dp)) - } - Text( - title, - style = MaterialTheme.typography.titleLarge, - fontWeight = FontWeight.Bold, - color = OwColors.TextPrimary, - modifier = Modifier.weight(1f), - ) - Row( - horizontalArrangement = Arrangement.spacedBy(8.dp), - verticalAlignment = Alignment.CenterVertically, - content = actions, - ) - } - if (status != null) { - Spacer(Modifier.height(8.dp)) - status() - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/BottomTabBar.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/BottomTabBar.kt deleted file mode 100644 index f0127a0..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/BottomTabBar.kt +++ /dev/null @@ -1,127 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.annotation.DrawableRes -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.navigationBarsPadding -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.semantics.Role -import androidx.compose.ui.semantics.role -import androidx.compose.ui.semantics.selected -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwSize - -/** - * The three top-level destinations. - * - * Chats is home. The node lives inside Wallet (that is where its card already - * is), so the third tab is the security/settings surface: identity, saved - * wallets, rotation, wipe, and — behind progressive disclosure — the SDK line - * that used to sit under the roster. - */ -enum class OwTab(val label: String, @param:DrawableRes val icon: Int) { - Chats("Chats", R.drawable.ic_ow_chat), - Wallet("Wallet", R.drawable.ic_ow_wallet), - // Tab labels stay short: the destination is Node & Settings (that is the - // screen title), but a 10sp label in a third of the bar has no room for it. - Settings("Settings", R.drawable.ic_ow_sliders), -} - -/** - * Persistent bottom navigation. - * - * 64dp of canvas with a single 1dp top border — no elevation shadow, no - * translucent scrim. The navigation-bar inset is applied here, so screens inside - * the shell must not also pad for it (see `LocalBottomBarPresent`). - */ -@Composable -fun OwBottomTabBar( - selected: OwTab, - onSelect: (OwTab) -> Unit, - modifier: Modifier = Modifier, -) { - Column( - modifier = modifier - .fillMaxWidth() - .background(OwColors.Canvas), - ) { - OwDivider() - Row( - modifier = Modifier - .fillMaxWidth() - .navigationBarsPadding() - .height(OwSize.TabBar), - horizontalArrangement = Arrangement.SpaceEvenly, - verticalAlignment = Alignment.CenterVertically, - ) { - OwTab.entries.forEach { tab -> - TabItem( - tab = tab, - selected = tab == selected, - onClick = { onSelect(tab) }, - modifier = Modifier.weight(1f), - ) - } - } - } -} - -@Composable -private fun TabItem( - tab: OwTab, - selected: Boolean, - onClick: () -> Unit, - modifier: Modifier = Modifier, -) { - val tint: Color = if (selected) OwColors.Accent else OwColors.TextMuted - Column( - modifier = modifier - .fillMaxWidth() - .clickable(onClick = onClick) - .semantics { - role = Role.Tab - this.selected = selected - } - .padding(vertical = 8.dp), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center, - ) { - Box(contentAlignment = Alignment.Center) { - Icon( - painter = painterResource(tab.icon), - contentDescription = null, - tint = tint, - modifier = Modifier.size(22.dp), - ) - } - Spacer(Modifier.height(4.dp)) - Text( - tab.label, - style = MaterialTheme.typography.labelSmall, - fontSize = 10.sp, - fontWeight = if (selected) FontWeight.SemiBold else FontWeight.Medium, - color = tint, - ) - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Buttons.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Buttons.kt deleted file mode 100644 index 7ff42b6..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Buttons.kt +++ /dev/null @@ -1,145 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Button -import androidx.compose.material3.ButtonDefaults -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius -import com.siriusdevops.onionwire.ui.OwSize - -/** - * The four button tiers. There is no fifth: a screen that needs something - * quieter than [Outline] uses a text action, not a new shape. - */ -enum class OwButtonVariant { - /** Solid accent, canvas-coloured semibold text. One per screen region. */ - Primary, - - /** Solid interactive surface, no border. */ - Secondary, - - /** Transparent with the one border. */ - Outline, - - /** Tinted crimson with a crimson border. Destructive actions only. */ - Destructive, -} - -/** - * The app's button. - * - * Heights and radii come from the spec, not from Material's 40dp default: a - * 48dp target is comfortable and consistent, and a 12dp squircle replaces the - * 999dp pill that made every alpha action look identical. - */ -@Composable -fun OwButton( - text: String, - onClick: () -> Unit, - modifier: Modifier = Modifier, - variant: OwButtonVariant = OwButtonVariant.Primary, - enabled: Boolean = true, - leadingIconRes: Int? = null, - content: (@Composable androidx.compose.foundation.layout.RowScope.() -> Unit)? = null, -) { - val height = when (variant) { - OwButtonVariant.Outline -> OwSize.ButtonCompact - else -> OwSize.Button - } - val container = when (variant) { - OwButtonVariant.Primary -> OwColors.Accent - OwButtonVariant.Secondary -> OwColors.SurfaceInteractive - OwButtonVariant.Outline -> Color.Transparent - OwButtonVariant.Destructive -> OwColors.DangerTint - } - val contentColor = when (variant) { - OwButtonVariant.Primary -> OwColors.Canvas - OwButtonVariant.Secondary -> OwColors.TextPrimary - OwButtonVariant.Outline -> OwColors.TextPrimary - OwButtonVariant.Destructive -> OwColors.Danger - } - val weight = if (variant == OwButtonVariant.Primary) FontWeight.SemiBold else FontWeight.Medium - // A local val, not the parameter: a parameter captured by the Button's - // content lambda cannot be smart-cast, and the nullable-call error reads as - // a Compose problem when it is only a Kotlin capture rule. - val customContent = content - - Button( - onClick = onClick, - enabled = enabled, - modifier = modifier.height(height), - shape = RoundedCornerShape(OwRadius.Control), - border = when (variant) { - OwButtonVariant.Outline -> BorderStroke(1.dp, OwColors.Border) - OwButtonVariant.Destructive -> BorderStroke(1.dp, OwColors.DangerBorder) - else -> null - }, - colors = ButtonDefaults.buttonColors( - containerColor = container, - contentColor = contentColor, - disabledContainerColor = when (variant) { - OwButtonVariant.Outline -> Color.Transparent - OwButtonVariant.Primary -> OwColors.SurfaceInteractive - OwButtonVariant.Secondary -> OwColors.Surface - OwButtonVariant.Destructive -> OwColors.Surface - }, - disabledContentColor = OwColors.TextMuted, - ), - elevation = ButtonDefaults.buttonElevation(defaultElevation = 0.dp, pressedElevation = 0.dp), - contentPadding = ButtonDefaults.ContentPadding, - ) { - if (customContent != null) { - customContent() - } else { - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Center, - ) { - if (leadingIconRes != null) { - Icon( - painter = painterResource(leadingIconRes), - contentDescription = null, - modifier = Modifier.size(18.dp), - ) - Spacer(Modifier.width(8.dp)) - } - Text(text, style = MaterialTheme.typography.labelLarge, fontWeight = weight) - } - } - } -} - -/** - * Two buttons sharing a row: the primary action takes the space, the secondary - * one takes what it needs. Used by the identity bar and the empty state. - */ -@Composable -fun OwButtonRow( - modifier: Modifier = Modifier, - content: @Composable androidx.compose.foundation.layout.RowScope.() -> Unit, -) { - Row( - modifier = modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.spacedBy(12.dp), - verticalAlignment = Alignment.CenterVertically, - content = content, - ) -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Dialogs.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Dialogs.kt deleted file mode 100644 index cb8d1ea..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Dialogs.kt +++ /dev/null @@ -1,93 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.AlertDialog -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Text -import androidx.compose.material3.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * A typed-confirmation dialog for an irreversible action. - * - * The typed word is not theatre: "Rotate identity" cuts every friend who is - * offline off the current locator, and "Wipe all chats" deletes every message - * body. Both are one stray tap away from a menu, so the dialog asks for the - * word the user is about to lose. - * - * [confirmationWord] is echoed in the field label; the confirm button stays - * disabled until it is typed (case-insensitively) — same contract the old inline - * confirm strip had, now with a real scrim behind it. - */ -@Composable -fun OwConfirmDialog( - title: String, - body: String, - confirmationWord: String, - confirmLabel: String, - destructive: Boolean, - onConfirm: () -> Unit, - onDismiss: () -> Unit, -) { - var typed by remember { mutableStateOf("") } - val armed = typed.trim().equals(confirmationWord, ignoreCase = true) - - AlertDialog( - onDismissRequest = onDismiss, - shape = RoundedCornerShape(OwRadius.Card), - containerColor = OwColors.Surface, - titleContentColor = OwColors.TextPrimary, - textContentColor = OwColors.TextSecondary, - title = { Text(title, style = MaterialTheme.typography.titleMedium) }, - text = { - Column { - Text(body, style = MaterialTheme.typography.bodyMedium) - Spacer(Modifier.height(14.dp)) - OutlinedTextField( - value = typed, - onValueChange = { typed = it }, - singleLine = true, - label = { Text("Type $confirmationWord") }, - modifier = Modifier.fillMaxWidth(), - ) - } - }, - confirmButton = { - Row(horizontalArrangement = Arrangement.End, modifier = Modifier.fillMaxWidth()) { - TextButton(onClick = onDismiss) { - Text("Cancel", color = OwColors.TextSecondary) - } - TextButton( - onClick = onConfirm, - enabled = armed, - ) { - Text( - confirmLabel, - color = when { - !armed -> OwColors.TextMuted - destructive -> OwColors.Danger - else -> OwColors.Accent - }, - ) - } - } - }, - modifier = Modifier.padding(horizontal = 8.dp), - ) -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/OverflowMenu.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/OverflowMenu.kt deleted file mode 100644 index f467049..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/OverflowMenu.kt +++ /dev/null @@ -1,69 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.layout.Box -import androidx.compose.material3.DropdownMenu -import androidx.compose.material3.DropdownMenuItem -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * The `⋮` overflow on the messenger and settings bars. - * - * Serious and rare actions live here instead of on the home screen: rotating the - * identity cuts every offline friend off the current locator, and deleting the - * message history is irreversible. Neither belongs next to "Invite". - * - * The menu is a component rather than inline code so the destructive verbs have - * exactly one home — a new screen that wants the overflow gets the same list, - * not a second copy with different wording. - */ -@Composable -fun OwOverflowMenu( - onOpenProfile: () -> Unit, - onOpenWallets: () -> Unit, - onRotate: () -> Unit, - onWipe: () -> Unit, - modifier: Modifier = Modifier, -) { - var open by remember { mutableStateOf(false) } - - Box(modifier) { - OwIconButton( - iconRes = R.drawable.ic_ow_more_vert, - contentDescription = "More actions", - onClick = { open = true }, - ) - DropdownMenu( - expanded = open, - onDismissRequest = { open = false }, - containerColor = OwColors.SurfaceInteractive, - shape = androidx.compose.foundation.shape.RoundedCornerShape(OwRadius.Control), - ) { - DropdownMenuItem( - text = { Text("Your profile", color = OwColors.TextPrimary) }, - onClick = { open = false; onOpenProfile() }, - ) - DropdownMenuItem( - text = { Text("Saved wallets", color = OwColors.TextPrimary) }, - onClick = { open = false; onOpenWallets() }, - ) - DropdownMenuItem( - text = { Text("Rotate identity", color = OwColors.TextPrimary) }, - onClick = { open = false; onRotate() }, - ) - DropdownMenuItem( - text = { Text("Delete message history", color = OwColors.Danger) }, - onClick = { open = false; onWipe() }, - ) - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/QrCode.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/QrCode.kt deleted file mode 100644 index 9e3fb3d..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/QrCode.kt +++ /dev/null @@ -1,78 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.Canvas -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.geometry.Size -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp -import com.google.zxing.BarcodeFormat -import com.google.zxing.EncodeHintType -import com.google.zxing.qrcode.QRCodeWriter -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * Renders [payload] as a QR code. - * - * The invite is a locator plus a prekey — long, and it has to survive a person - * pointing a phone at a screen, so the modules are drawn at full contrast on a - * light plate rather than tinted to match the dark theme. - * - * A payload zxing cannot encode (too long for version 40) renders as an empty - * plate; callers always show the copyable text as well, so a failed encode is - * degraded, not fatal. - */ -@Composable -fun OwQrCode( - payload: String, - modifier: Modifier = Modifier, - size: Dp = 200.dp, -) { - val matrix = remember(payload) { - runCatching { - QRCodeWriter().encode( - payload, - BarcodeFormat.QR_CODE, - 0, - 0, - mapOf(EncodeHintType.MARGIN to 0), - ) - }.getOrNull() - } - Box( - modifier = modifier - .size(size) - .clip(RoundedCornerShape(OwRadius.Control)) - .background(OwColors.TextPrimary), - contentAlignment = Alignment.Center, - ) { - if (matrix != null) { - Canvas(Modifier.size(size)) { - val cells = matrix.width.toFloat() - val cellW = this.size.width / cells - val cellH = this.size.height / matrix.height.toFloat() - for (y in 0 until matrix.height) { - for (x in 0 until matrix.width) { - if (matrix.get(x, y)) { - drawRect( - color = Color(0xFF0A0C0E), - topLeft = Offset(x * cellW, y * cellH), - size = Size(cellW + 0.5f, cellH + 0.5f), - ) - } - } - } - } - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/SegmentedControl.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/SegmentedControl.kt deleted file mode 100644 index c5f2f2b..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/SegmentedControl.kt +++ /dev/null @@ -1,104 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.animation.animateColorAsState -import androidx.compose.animation.core.tween -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.platform.testTag -import androidx.compose.ui.semantics.Role -import androidx.compose.ui.semantics.role -import androidx.compose.ui.semantics.selected -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * Horizontal segmented control: one track, [OwColors.SurfaceInteractive], 4dp of - * inside padding, 12dp radius. - * - * This replaces the stacks of full-width pill buttons that made "Pruned / Full / - * Testnet" read as three unrelated actions rather than one choice with three - * values. The selected segment is an accent fill with canvas text. - */ -@Composable -fun OwSegmentedControl( - options: List, - selectedIndex: Int, - onSelect: (Int) -> Unit, - modifier: Modifier = Modifier, - enabled: Boolean = true, - /** - * Optional per-segment `testTag`s, one per option. Additive: omitted (the - * default) leaves every existing call site byte-identical. It exists because - * a merged "Pruned / Full / Testnet" track has no per-value handle otherwise, - * and the wallet screen's tests address each segment by the tag it had when - * the three options were three stacked buttons. - */ - testTags: List = emptyList(), -) { - Row( - modifier = modifier - .fillMaxWidth() - .clip(RoundedCornerShape(OwRadius.Control)) - .background(OwColors.SurfaceInteractive) - .padding(4.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - options.forEachIndexed { index, label -> - val selected = index == selectedIndex - val container by animateColorAsState( - targetValue = if (selected) OwColors.Accent else OwColors.SurfaceInteractive, - animationSpec = tween(durationMillis = 160), - label = "segment-container", - ) - val textColor by animateColorAsState( - targetValue = when { - selected -> OwColors.Canvas - enabled -> OwColors.TextSecondary - else -> OwColors.TextMuted - }, - animationSpec = tween(durationMillis = 160), - label = "segment-text", - ) - val tag = testTags.getOrNull(index) - Box( - modifier = Modifier - .weight(1f) - .height(36.dp) - .clip(RoundedCornerShape(9.dp)) - .background(container) - .then(if (tag != null) Modifier.testTag(tag) else Modifier) - .clickable(enabled = enabled && !selected) { onSelect(index) } - .semantics { - role = Role.Tab - this.selected = selected - }, - contentAlignment = Alignment.Center, - ) { - Text( - label, - style = MaterialTheme.typography.labelLarge, - fontSize = 13.sp, - fontWeight = if (selected) FontWeight.SemiBold else FontWeight.Medium, - color = textColor, - ) - } - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Surfaces.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Surfaces.kt deleted file mode 100644 index 57bdfde..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Surfaces.kt +++ /dev/null @@ -1,260 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.Canvas -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.ColumnScope -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.geometry.Size -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.semantics.contentDescription -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.ui.MonoStyle -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius -import com.siriusdevops.onionwire.ui.OwSize - -/** - * A section card: [OwColors.Surface], 16dp radius, one 1dp border, 16dp of - * padding. Every non-list block on every screen is one of these. - */ -@Composable -fun OwCard( - modifier: Modifier = Modifier, - padding: Dp = 16.dp, - content: @Composable ColumnScope.() -> Unit, -) { - Column( - modifier = modifier - .clip(RoundedCornerShape(OwRadius.Card)) - .background(OwColors.Surface) - .border(1.dp, OwColors.Border, RoundedCornerShape(OwRadius.Card)) - .padding(padding), - content = content, - ) -} - -/** Small tracked label, secondary colour. Never monospace. */ -@Composable -fun Label(text: String, modifier: Modifier = Modifier) { - Text( - text, - modifier = modifier, - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextSecondary, - ) -} - -/** - * Cryptographic material and numbers only: pubkeys, truncated locators, seeds, - * `host:port`, block heights. Never a sentence. - */ -@Composable -fun Mono(text: String, modifier: Modifier = Modifier, color: Color = OwColors.TextPrimary) { - Text(text, modifier = modifier, style = MonoStyle.copy(color = color)) -} - -/** Section heading inside a card. */ -@Composable -fun OwSectionTitle(text: String, modifier: Modifier = Modifier) { - Text( - text, - modifier = modifier, - style = MaterialTheme.typography.titleMedium, - color = OwColors.TextPrimary, - ) -} - -/** A 7dp status dot. Colour is the caller's statement, not decoration. */ -@Composable -fun OwStatusDot(color: Color, modifier: Modifier = Modifier) { - Box(modifier.size(7.dp).clip(CircleShape).background(color)) -} - -/** Small status badge — the one place a 999dp radius is correct. */ -@Composable -fun OwPill( - text: String, - modifier: Modifier = Modifier, - textColor: Color = OwColors.TextSecondary, - container: Color = OwColors.SurfaceInteractive, - borderColor: Color? = null, - dotColor: Color? = null, -) { - Row( - modifier = modifier - .clip(RoundedCornerShape(OwRadius.Pill)) - .background(container) - .then( - if (borderColor != null) { - Modifier.border(1.dp, borderColor, RoundedCornerShape(OwRadius.Pill)) - } else { - Modifier - }, - ) - .padding(horizontal = 10.dp, vertical = 4.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(6.dp), - ) { - if (dotColor != null) OwStatusDot(dotColor) - Text(text, style = MaterialTheme.typography.labelSmall, color = textColor, fontSize = 11.sp) - } -} - -/** - * The header status pill: `● Tor active`. - * - * Shown while the app is in `Phase.Ready`, which is exactly when the node (and - * therefore Arti) is up. It says nothing about reachability after the app - * leaves the foreground — the keep-alive state is a separate row on the - * settings screen, because that is the honest place for it. - */ -@Composable -fun TorStatusPill(modifier: Modifier = Modifier) { - OwPill( - text = "Tor active", - modifier = modifier, - textColor = OwColors.Accent, - container = OwColors.InfoTint, - borderColor = OwColors.InfoBorder, - dotColor = OwColors.Accent, - ) -} - -/** - * A 36x36 icon button on an interactive surface. Used for Lock, back chevrons - * and the overflow trigger. - */ -@Composable -fun OwIconButton( - iconRes: Int, - contentDescription: String, - onClick: () -> Unit, - modifier: Modifier = Modifier, - tint: Color = OwColors.TextPrimary, - background: Color = OwColors.SurfaceInteractive, - size: Dp = OwSize.IconButton, -) { - Box( - modifier = modifier - .size(size) - .clip(RoundedCornerShape(OwRadius.Control)) - .background(background) - .clickable(onClick = onClick) - .semantics { this.contentDescription = contentDescription }, - contentAlignment = Alignment.Center, - ) { - Icon( - painter = painterResource(iconRes), - contentDescription = null, - tint = tint, - modifier = Modifier.size(18.dp), - ) - } -} - -/** - * A deterministic 5x5 identicon derived from the identity fingerprint. - * - * Not a security feature: it is a stable visual handle so "your identity" is - * recognisable at a glance without reading 64 hex characters. It renders the - * seed it was given — it never invents a value, and two devices showing the - * same fingerprint show the same picture. - */ -@Composable -fun Identicon(seed: String, modifier: Modifier = Modifier, size: Dp = 40.dp) { - val palette = listOf(OwColors.Accent, OwColors.TextSecondary, OwColors.TextMuted) - val cells = identiconCells(seed) - Box( - modifier = modifier - .size(size) - .clip(CircleShape) - .background(OwColors.SurfaceInteractive), - contentAlignment = Alignment.Center, - ) { - Canvas(Modifier.size(size * 0.62f)) { - val cell = this.size.minDimension / 5f - val pad = (this.size.minDimension - cell * 5f) / 2f - cells.forEach { (x, y, tone) -> - drawRect( - color = palette[tone % palette.size], - topLeft = Offset(pad + x * cell, pad + y * cell), - size = Size(cell, cell), - ) - } - } - } -} - -/** - * The left half of a 5-wide grid plus its mirror, as (column, row, tone) - * triples. Pure and cheap: the same seed always yields the same picture. - */ -internal fun identiconCells(seed: String): List> { - if (seed.isEmpty()) return emptyList() - val bytes = seed.map { it.code }.toIntArray() - var i = 0 - val out = mutableListOf>() - for (row in 0 until 5) { - for (col in 0 until 3) { - val v = bytes[i % bytes.size] - i++ - // A cell exists when the byte says so; tone varies the shade. - if (v % 3 != 0) { - val tone = (v / 3) % 3 - out += Triple(col, row, tone) - val mirrored = 4 - col - if (mirrored != col) out += Triple(mirrored, row, tone) - } - } - } - return out -} - -/** The one hairline rule. */ -@Composable -fun OwDivider(modifier: Modifier = Modifier, color: Color = OwColors.Border) { - Box(modifier.fillMaxWidth().height(1.dp).background(color)) -} - -/** Border stroke helper so screens never hardcode the token twice. */ -val OwCardBorder: BorderStroke = BorderStroke(1.dp, OwColors.Border) - -/** Convenience for the many `Icon(painterResource(...))` call sites. */ -@Composable -fun OwIcon( - iconRes: Int, - contentDescription: String?, - tint: Color = OwColors.TextPrimary, - size: Dp = 20.dp, -) { - Icon( - painter = painterResource(iconRes), - contentDescription = contentDescription, - tint = tint, - modifier = Modifier.size(size), - ) -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/wallet/ChainStorage.kt b/android/app/src/main/java/com/siriusdevops/onionwire/wallet/ChainStorage.kt deleted file mode 100644 index cd06bab..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/wallet/ChainStorage.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.siriusdevops.onionwire.wallet - -import android.os.StatFs -import java.io.File - -/** - * Free space on the filesystem the in-process chain store grows into. - * - * The chain source this is for is Cuprate's fjall store under - * `$ONIONWIRE_HOME/chain` (`WireViewModel.home` is `filesDir/onionwire`), which is - * the same filesystem as `filesDir` — so `StatFs` on the app's own data directory - * answers the question the user is actually being asked: *will this fit here?* - * - * It is a **measurement, not an estimate**: nothing in the SDK exposes a chain - * size (`WalletChildStatus` has no size field, and Cuprate's restricted RPC - * reports a hardcoded 5 GiB placeholder — `src/cuprate.rs`). The floor the screen - * applies to this number is [com.siriusdevops.onionwire.ui.CHAIN_FREE_SPACE_FLOOR_BYTES], - * and it is documented there as a floor rather than a sync estimate. - * - * `null` means "could not be read", and the screen treats that as fail-closed: an - * unknown free space is not reported as enough. Kept out of the JVM unit tests on - * purpose — `StatFs` is an Android class, so the pure formatting and the gate live - * in `ui/WalletChildStatusText.kt` where they are covered without a device. - */ -object ChainStorage { - - /** Free bytes on [path]'s filesystem, or `null` when it cannot be read. */ - fun freeBytes(path: File): Long? = runCatching { StatFs(path.absolutePath).availableBytes } - .getOrNull() -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/wallet/WalletChildBinaries.kt b/android/app/src/main/java/com/siriusdevops/onionwire/wallet/WalletChildBinaries.kt deleted file mode 100644 index b9292a6..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/wallet/WalletChildBinaries.kt +++ /dev/null @@ -1,101 +0,0 @@ -package com.siriusdevops.onionwire.wallet - -import java.io.File - -/** - * The app-owned wallet-child executables, as the APK actually carries them. - * - * **Why `jniLibs` and not an asset.** Since Android 10 (API 29) an app may not - * `exec()` a file it wrote into its own data directory: the SELinux policy has - * no `execute` on `app_data_file`, so `filesDir/libmonerowalletrpc.so` copied - * out of `assets/` with the exec bit set is still refused by the kernel — the - * classic "copy it to app-private storage" recipe died with `targetSdk 29`. - * The one directory Android does hand out executable is - * `ApplicationInfo.nativeLibraryDir`: the package manager unpacks the - * `lib//` entries from the APK there at install time with the exec bit - * intact. A plain - * executable therefore has to be named `lib*.so` and shipped through - * `jniLibs`, and that unpack only happens when the manifest says - * `android:extractNativeLibs="true"` (`packaging.jniLibs.useLegacyPackaging` - * in `app/build.gradle.kts`). With `extractNativeLibs="false"` — the AGP 8 - * default — the `.so` stays inside the APK and there is nothing on disk to run. - * - * The names here are the paths handed to the core as `ChainConfig.wallet_rpc_bin` - * and `ChainConfig.arti_bin`; the core spawns exactly the path it is given and - * never falls back to `PATH` (nothing in an APK sandbox resolves a bare - * `monero-wallet-rpc`). - */ -object WalletChildBinaries { - - /** `jniLibs//` entry name for `monero-wallet-rpc`. */ - const val WALLET_RPC_LIB: String = "libmonerowalletrpc.so" - - /** - * Wallet file name inside `$ONIONWIRE_HOME/wallet`. Mirrors the core's - * `wallet::DEFAULT_WALLET_FILENAME`, so a config saved from here and a - * config the core defaults to name the same file. - */ - const val WALLET_FILENAME: String = "onionwire" - - /** - * `jniLibs//` entry name for the `arti` SOCKS child. **Not bundled in - * this build** — a `.onion` daemon needs a separate Rust binary, which is a - * follow-up (see `android/MONERO_BINARIES.md`). The constant exists so the - * screen can name the path it would use, and so the absence is checkable - * rather than assumed. - */ - const val ARTI_LIB: String = "libarti.so" - - /** - * Resolve the bundled binaries under [nativeLibraryDir]. - * - * A null/blank directory (or a missing file) means this install does not - * carry the binary — the screen says so instead of offering a Start that - * can only fail. - */ - fun resolve(nativeLibraryDir: String?): WalletChildBinaryPaths = - WalletChildBinaryPaths( - walletRpc = existing(nativeLibraryDir, WALLET_RPC_LIB), - arti = existing(nativeLibraryDir, ARTI_LIB), - ) - - /** - * The absolute path the core is handed for an entry, whether or not the - * file is present. - * - * Used for `arti_bin` on a clearnet/loopback daemon: the core validates - * that `arti_bin` is non-empty for any non-receive-only source but only - * ever spawns it for a `.onion` host, so the value is inert there. Naming - * the path the binary *would* occupy is deliberate — passing a real binary - * that is not `arti` (say, `monero-wallet-rpc`) would be spawned as the - * SOCKS child the moment the user typed an `.onion` host, which is worse - * than an honest `ENOENT`. - */ - fun expectedPath(nativeLibraryDir: String?, entry: String): String { - val dir = nativeLibraryDir?.takeIf { it.isNotBlank() } ?: return "" - return File(dir, entry).absolutePath - } - - private fun existing(nativeLibraryDir: String?, entry: String): String? { - val dir = nativeLibraryDir?.takeIf { it.isNotBlank() } ?: return null - val file = File(dir, entry) - return if (file.isFile) file.absolutePath else null - } -} - -/** What this install can actually spawn. */ -data class WalletChildBinaryPaths( - val walletRpc: String?, - val arti: String?, -) { - val walletRpcBundled: Boolean get() = walletRpc != null - val artiBundled: Boolean get() = arti != null -} - -/** - * Shown when this install carries no `monero-wallet-rpc`. One string, used by - * both the status line and the Start gate, so the two can never disagree about - * why the button is dead. - */ -const val NO_WALLET_RPC_MESSAGE: String = - "monero-wallet-rpc is not bundled in this build, so there is nothing to start." diff --git a/android/app/src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so b/android/app/src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so deleted file mode 100755 index 1d1f151..0000000 Binary files a/android/app/src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so and /dev/null differ diff --git a/android/app/src/main/res/drawable-nodpi/onionwire_app_icon.png b/android/app/src/main/res/drawable-nodpi/onionwire_app_icon.png deleted file mode 100644 index 197a2eb..0000000 Binary files a/android/app/src/main/res/drawable-nodpi/onionwire_app_icon.png and /dev/null differ diff --git a/android/app/src/main/res/drawable/ic_ow_add.xml b/android/app/src/main/res/drawable/ic_ow_add.xml deleted file mode 100644 index 3f91af8..0000000 --- a/android/app/src/main/res/drawable/ic_ow_add.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_chat.xml b/android/app/src/main/res/drawable/ic_ow_chat.xml deleted file mode 100644 index e673602..0000000 --- a/android/app/src/main/res/drawable/ic_ow_chat.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_chevron_left.xml b/android/app/src/main/res/drawable/ic_ow_chevron_left.xml deleted file mode 100644 index b235eaa..0000000 --- a/android/app/src/main/res/drawable/ic_ow_chevron_left.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_copy.xml b/android/app/src/main/res/drawable/ic_ow_copy.xml deleted file mode 100644 index d52c3fb..0000000 --- a/android/app/src/main/res/drawable/ic_ow_copy.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_info.xml b/android/app/src/main/res/drawable/ic_ow_info.xml deleted file mode 100644 index 2a5d106..0000000 --- a/android/app/src/main/res/drawable/ic_ow_info.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_lock.xml b/android/app/src/main/res/drawable/ic_ow_lock.xml deleted file mode 100644 index fce7ee1..0000000 --- a/android/app/src/main/res/drawable/ic_ow_lock.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_more_vert.xml b/android/app/src/main/res/drawable/ic_ow_more_vert.xml deleted file mode 100644 index bcd27db..0000000 --- a/android/app/src/main/res/drawable/ic_ow_more_vert.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_person.xml b/android/app/src/main/res/drawable/ic_ow_person.xml deleted file mode 100644 index 7bc0b35..0000000 --- a/android/app/src/main/res/drawable/ic_ow_person.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_qr.xml b/android/app/src/main/res/drawable/ic_ow_qr.xml deleted file mode 100644 index 7e43c96..0000000 --- a/android/app/src/main/res/drawable/ic_ow_qr.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_share.xml b/android/app/src/main/res/drawable/ic_ow_share.xml deleted file mode 100644 index dc49c02..0000000 --- a/android/app/src/main/res/drawable/ic_ow_share.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_shield.xml b/android/app/src/main/res/drawable/ic_ow_shield.xml deleted file mode 100644 index 2aab4a8..0000000 --- a/android/app/src/main/res/drawable/ic_ow_shield.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_sliders.xml b/android/app/src/main/res/drawable/ic_ow_sliders.xml deleted file mode 100644 index d16a838..0000000 --- a/android/app/src/main/res/drawable/ic_ow_sliders.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_wallet.xml b/android/app/src/main/res/drawable/ic_ow_wallet.xml deleted file mode 100644 index ed74045..0000000 --- a/android/app/src/main/res/drawable/ic_ow_wallet.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_warning.xml b/android/app/src/main/res/drawable/ic_ow_warning.xml deleted file mode 100644 index 234711a..0000000 --- a/android/app/src/main/res/drawable/ic_ow_warning.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_stat_onion.xml b/android/app/src/main/res/drawable/ic_stat_onion.xml deleted file mode 100644 index 90aa302..0000000 --- a/android/app/src/main/res/drawable/ic_stat_onion.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index 8c08082..0000000 --- a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index abdbe32..0000000 --- a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml deleted file mode 100644 index b857106..0000000 --- a/android/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - OnionWire - - - Node keep-alive - Shown while OnionWire keeps your onion address reachable in the background. - OnionWire is reachable - OnionWire is starting - Tor and the outbox are running so peers can deliver messages. - Bootstrapping Tor. This can take minutes — keep the device awake. - Tor and the outbox are running so peers can reach %1$s… - Stop keep-alive - Reachable only while this app is open. - Kept alive — Tor and the outbox run until you tap Lock. - Kept alive, but notifications are blocked, so the status notice is hidden. Android still lists the service in the Task Manager. - Not kept alive (%1$s). The node stops when the app does. - diff --git a/android/app/src/main/res/values/themes.xml b/android/app/src/main/res/values/themes.xml deleted file mode 100644 index 21680da..0000000 --- a/android/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/xml/data_extraction_rules.xml b/android/app/src/main/res/xml/data_extraction_rules.xml deleted file mode 100644 index 3e7a089..0000000 --- a/android/app/src/main/res/xml/data_extraction_rules.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/WalletChildRefreshLoopTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/WalletChildRefreshLoopTest.kt deleted file mode 100644 index a1b59c2..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/WalletChildRefreshLoopTest.kt +++ /dev/null @@ -1,108 +0,0 @@ -package com.siriusdevops.onionwire - -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch -import kotlinx.coroutines.test.advanceTimeBy -import kotlinx.coroutines.test.currentTime -import kotlinx.coroutines.test.runTest -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * The wallet screen's refresh loop. - * - * `Wire` has no seam a JVM test can fake: `requireWire()` reads - * `NodeHost.requireOpen()`, a process-global that only `openWire()` — i.e. a - * real Arti bootstrap — sets, and `Wire` itself is the generated UniFFI - * interface. So the loop takes its two reads as parameters, and these tests - * drive it with recording lambdas to pin the two things that make the - * `sync h/t` segment live: - * - * - the cheap cached read paints once, and every tick after it is the live - * probe (`Wire::wallet_child_refresh`), not the cached status read - * (`Wire::wallet_status`) that only re-reads what the last probe left behind; - * - the ticks are serialized by construction — a probe slower than the tick - * delays the next one instead of overlapping it, so no two - * `wallet_child_refresh` calls are ever in flight against one wallet child. - * - * The binding of `live` to `WireViewModel.refreshWalletChild()` (and `cached` - * to `paintWalletChildCached()`) is the two lines in - * `WireViewModel.openWalletChild()`, and the source there is the evidence for - * it — nothing in this test can observe a `NodeHost` that is not open. - * - * Time is virtual, so the 2s cadence is free to assert. Note the scheduler's - * rule: `advanceTimeBy(n)` runs what is scheduled strictly before `n`, not the - * task at `n` itself. - */ -class WalletChildRefreshLoopTest { - - @Test - fun the_first_paint_is_the_cached_read_and_every_tick_after_it_is_live() = runTest { - var cached = 0 - var live = 0 - val job = launch { - walletChildRefreshLoop(tickMs = TICK_MS, cached = { cached++ }, live = { live++ }) - } - - // Four ticks of virtual time: probes at 2s, 4s and 6s; the 8s one has - // not fired yet. - advanceTimeBy(4 * TICK_MS) - - assertEquals("the cheap read paints once, and only once", 1, cached) - assertEquals("every tick after the paint is a live probe", 3, live) - assertEquals("and they land on the tick, not back to back", 4 * TICK_MS, currentTime) - - job.cancel() - advanceTimeBy(10 * TICK_MS) - assertEquals("cancelling the loop is what stops the dialing", 3, live) - } - - @Test - fun a_probe_slower_than_the_tick_is_never_overlapped() = runTest { - var inFlight = 0 - var maxInFlight = 0 - var probes = 0 - val job = launch { - walletChildRefreshLoop( - tickMs = TICK_MS, - cached = {}, - live = { - inFlight++ - if (inFlight > maxInFlight) maxInFlight = inFlight - delay(5 * TICK_MS) // a probe five ticks long - inFlight-- - probes++ - }, - ) - } - - // Probe 1 at 2s runs to 12s, probe 2 at 14s to 24s, probe 3 at 26s to - // 36s: each of them pushes the next tick out by its own length. - advanceTimeBy(19 * TICK_MS) - - assertEquals("two concurrent wallet_child_refresh probes is a race", 1, maxInFlight) - assertEquals("three probes done, none of them skipped or doubled", 3, probes) - assertEquals(19 * TICK_MS, currentTime) - - job.cancel() - } - - @Test - fun cancelling_the_loop_stops_the_probes() = runTest { - var live = 0 - val job = launch { - walletChildRefreshLoop(tickMs = TICK_MS, cached = {}, live = { live++ }) - } - - advanceTimeBy(3 * TICK_MS) - assertEquals("two ticks have gone by", 2, live) - - job.cancel() - advanceTimeBy(10 * TICK_MS) - assertEquals("leaving the wallet screen stops the dialing", 2, live) - } - - private companion object { - const val TICK_MS = 2_000L - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/crypto/StoreSecretTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/crypto/StoreSecretTest.kt deleted file mode 100644 index 3fa7db3..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/crypto/StoreSecretTest.kt +++ /dev/null @@ -1,157 +0,0 @@ -package com.siriusdevops.onionwire.crypto - -import org.junit.Assert.assertArrayEquals -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNotEquals -import org.junit.Assert.assertTrue -import org.junit.Assert.fail -import org.junit.Test -import javax.crypto.KeyGenerator -import javax.crypto.SecretKey - -/** - * Exercises the real envelope code — [StoreSecret] has no `android.*` imports, - * so a JVM AES key stands in for the AndroidKeystore key. - * - * What this does NOT cover (see the PR description): the AndroidKeyStore provider - * itself (`KeyGenerator` + `KeyGenParameterSpec`, StrongBox fallback, and - * `KeyInfo.isInsideSecureHardware`). Those are device-only APIs; the unit-test - * JVM has no such provider. - */ -class StoreSecretTest { - - private fun aesKey(): SecretKey = - KeyGenerator.getInstance("AES").apply { init(StoreSecret.KEY_BITS) }.generateKey() - - private val passphrase = "correct horse battery staple".toCharArray() - - @Test - fun seal_open_round_trips() { - val key = aesKey() - val blob = StoreSecret.seal(key, passphrase) - val out = StoreSecret.open(key, blob) - try { - assertArrayEquals(passphrase, out) - } finally { - StoreSecret.wipe(out) - } - } - - @Test - fun round_trips_non_ascii_and_whitespace() { - val key = aesKey() - val weird = " ünïcödé 🔑 \n\ttab ".toCharArray() - val out = StoreSecret.open(key, StoreSecret.seal(key, weird)) - try { - assertArrayEquals(weird, out) - } finally { - StoreSecret.wipe(out) - } - } - - @Test - fun blob_does_not_contain_the_plaintext() { - val key = aesKey() - val blob = StoreSecret.seal(key, passphrase) - val needle = String(passphrase).toByteArray(Charsets.UTF_8) - assertFalse( - "ciphertext must not contain the passphrase", - blob.containsSubsequence(needle), - ) - assertTrue(blob.size > needle.size) - } - - @Test - fun blob_carries_the_envelope_magic() { - val blob = StoreSecret.seal(aesKey(), passphrase) - assertEquals("OWSEAL1\n", String(blob.copyOfRange(0, 8), Charsets.US_ASCII)) - // Magic(8) + IV length(1) + IV(12) + tag(16) - assertEquals(8 + 1 + StoreSecret.IV_BYTES + 16, blob.size - String(passphrase).toByteArray(Charsets.UTF_8).size) - } - - @Test - fun each_seal_uses_a_fresh_iv() { - val key = aesKey() - val a = StoreSecret.seal(key, passphrase) - val b = StoreSecret.seal(key, passphrase) - assertNotEquals( - "identical ciphertext means the IV was reused", - a.toList(), - b.toList(), - ) - } - - @Test - fun wrong_key_fails_closed() { - val blob = StoreSecret.seal(aesKey(), passphrase) - try { - StoreSecret.open(aesKey(), blob) - fail("expected SecretUnavailable") - } catch (e: SecretUnavailable) { - assertTrue(e.message!!.contains("authenticate")) - } - } - - @Test - fun tampered_ciphertext_fails_the_gcm_tag() { - val key = aesKey() - val blob = StoreSecret.seal(key, passphrase) - blob[blob.size - 1] = (blob[blob.size - 1].toInt() xor 0x01).toByte() - try { - StoreSecret.open(key, blob) - fail("expected SecretUnavailable") - } catch (_: SecretUnavailable) { - } - } - - @Test - fun truncated_blob_fails_closed() { - val key = aesKey() - val blob = StoreSecret.seal(key, passphrase) - try { - StoreSecret.open(key, blob.copyOfRange(0, 10)) - fail("expected SecretUnavailable") - } catch (_: SecretUnavailable) { - } - } - - @Test - fun garbage_blob_fails_closed() { - try { - StoreSecret.open(aesKey(), "not an envelope".toByteArray()) - fail("expected SecretUnavailable") - } catch (e: SecretUnavailable) { - assertTrue(e.message!!.contains("truncated") || e.message!!.contains("envelope")) - } - } - - @Test - fun seal_refuses_an_empty_passphrase() { - try { - StoreSecret.seal(aesKey(), CharArray(0)) - fail("expected IllegalArgumentException") - } catch (_: IllegalArgumentException) { - } - } - - @Test - fun wipe_zeroes() { - val bytes = byteArrayOf(1, 2, 3) - StoreSecret.wipe(bytes) - assertArrayEquals(ByteArray(3), bytes) - - val chars = charArrayOf('a', 'b') - StoreSecret.wipe(chars) - assertArrayEquals(CharArray(2), chars) - } - - private fun ByteArray.containsSubsequence(needle: ByteArray): Boolean { - if (needle.isEmpty() || needle.size > size) return false - outer@ for (i in 0..size - needle.size) { - for (j in needle.indices) if (this[i + j] != needle[j]) continue@outer - return true - } - return false - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/crypto/StoredPassphraseStoreTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/crypto/StoredPassphraseStoreTest.kt deleted file mode 100644 index a56141d..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/crypto/StoredPassphraseStoreTest.kt +++ /dev/null @@ -1,167 +0,0 @@ -package com.siriusdevops.onionwire.crypto - -import org.junit.Assert.assertArrayEquals -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Rule -import org.junit.Test -import org.junit.rules.TemporaryFolder -import javax.crypto.KeyGenerator -import javax.crypto.SecretKey - -/** - * File-level behaviour of [StoredPassphraseStore] with the real envelope from - * [StoreSecret] and a JVM AES key standing in for the Keystore key. - * - * The Keystore itself is device-only; what is proven here is that nothing - * plaintext reaches the file, that a lost key degrades instead of crashing, - * and that a lost key does not delete the user's blob. - */ -class StoredPassphraseStoreTest { - - @get:Rule - val tmp = TemporaryFolder() - - private val passphrase = "correct horse battery staple".toCharArray() - - /** Stands in for the AndroidKeystore key: real AES-GCM, JVM-held key. */ - private class JvmKeyCipher(private val key: SecretKey) : PassphraseCipher { - var deleted = false - var backingQueried = 0 - - override fun seal(plaintext: CharArray): ByteArray = StoreSecret.seal(key, plaintext) - - override fun open(blob: ByteArray): CharArray { - if (deleted) throw SecretUnavailable("the device's Keystore key for OnionWire is gone") - return StoreSecret.open(key, blob) - } - - override fun keyPresent(): Boolean = !deleted - - override fun backing(): KeyBacking { - backingQueried++ - return KeyBacking.SOFTWARE - } - - override fun deleteKey() { - deleted = true - } - } - - private fun jvmKey(): SecretKey = - KeyGenerator.getInstance("AES").apply { init(StoreSecret.KEY_BITS) }.generateKey() - - private fun store(cipher: PassphraseCipher) = - StoredPassphraseStore(tmp.newFile("store-passphrase.bin").also { it.delete() }, cipher) - - @Test - fun save_then_load_round_trips() { - val store = store(JvmKeyCipher(jvmKey())) - store.save(passphrase) - - val loaded = store.load() - assertTrue(loaded is StoredPassphraseStore.Load.Loaded) - val out = (loaded as StoredPassphraseStore.Load.Loaded).passphrase - try { - assertArrayEquals(passphrase, out) - } finally { - StoreSecret.wipe(out) - } - } - - @Test - fun on_disk_blob_is_not_the_plaintext() { - val store = store(JvmKeyCipher(jvmKey())) - store.save(passphrase) - - val raw = java.io.File(store.path).readBytes() - val needle = String(passphrase).toByteArray(Charsets.UTF_8) - assertFalse( - "the passphrase must not appear in the file", - raw.toString(Charsets.ISO_8859_1).contains(String(needle, Charsets.ISO_8859_1)), - ) - assertTrue("expected the OWSEAL envelope", raw.size > needle.size + 20) - assertEquals("OWSEAL1\n", String(raw.copyOfRange(0, 8), Charsets.US_ASCII)) - } - - @Test - fun no_temp_file_is_left_behind() { - val store = store(JvmKeyCipher(jvmKey())) - store.save(passphrase) - val dir = requireNotNull(java.io.File(store.path).parentFile) - val leftovers = dir.listFiles()!!.filter { it.name.endsWith(".tmp") } - assertTrue("temp files left: $leftovers", leftovers.isEmpty()) - } - - @Test - fun save_overwrites_the_previous_blob() { - val store = store(JvmKeyCipher(jvmKey())) - store.save("first".toCharArray()) - store.save("second".toCharArray()) - - val loaded = store.load() as StoredPassphraseStore.Load.Loaded - try { - assertArrayEquals("second".toCharArray(), loaded.passphrase) - } finally { - StoreSecret.wipe(loaded.passphrase) - } - } - - @Test - fun absent_when_nothing_was_ever_stored() { - val store = store(JvmKeyCipher(jvmKey())) - assertFalse(store.exists()) - assertEquals(StoredPassphraseStore.Load.Absent, store.load()) - } - - @Test - fun lost_key_reports_unavailable_and_keeps_the_blob() { - val cipher = JvmKeyCipher(jvmKey()) - val store = store(cipher) - store.save(passphrase) - - cipher.deleteKey() // device reset / key invalidated - - val loaded = store.load() - assertTrue(loaded is StoredPassphraseStore.Load.Unavailable) - assertTrue( - (loaded as StoredPassphraseStore.Load.Unavailable).reason.contains("gone"), - ) - assertTrue("a failed read must not delete the blob", store.exists()) - } - - @Test - fun corrupt_blob_reports_unavailable_instead_of_throwing() { - val store = store(JvmKeyCipher(jvmKey())) - store.save(passphrase) - java.io.File(store.path).writeBytes("OWSEAL1\n not really a ciphertext".toByteArray()) - - val loaded = store.load() - assertTrue(loaded is StoredPassphraseStore.Load.Unavailable) - } - - @Test - fun forget_deletes_the_blob_and_the_key() { - val cipher = JvmKeyCipher(jvmKey()) - val store = store(cipher) - store.save(passphrase) - assertTrue(store.exists()) - - store.forget() - - assertFalse(store.exists()) - assertFalse(cipher.keyPresent()) - assertEquals(StoredPassphraseStore.Load.Absent, store.load()) - } - - @Test - fun backing_is_reported_from_the_cipher() { - val cipher = JvmKeyCipher(jvmKey()) - val store = store(cipher) - store.save(passphrase) - - assertEquals(KeyBacking.SOFTWARE, store.backing()) - assertEquals(1, cipher.backingQueried) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/keepalive/KeepAlivePolicyTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/keepalive/KeepAlivePolicyTest.kt deleted file mode 100644 index f12fd6c..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/keepalive/KeepAlivePolicyTest.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.siriusdevops.onionwire.keepalive - -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * The keep-alive used to refuse to start until [NodeHost.current] was set — - * which is only after Tor has published. Bootstrap itself ran on the UI - * ViewModel scope, so closing the activity cancelled `openWire` and the - * spinner vanished with no onion. - */ -class KeepAlivePolicyTest { - - @Test - fun bootstrap_in_flight_is_work_the_service_must_hold() { - assertTrue(keepAliveHasWork(nodeOpen = false, bootstrapInFlight = true)) - } - - @Test - fun a_live_node_is_work_the_service_must_hold() { - assertTrue(keepAliveHasWork(nodeOpen = true, bootstrapInFlight = false)) - } - - @Test - fun locked_and_idle_is_not_work() { - assertFalse(keepAliveHasWork(nodeOpen = false, bootstrapInFlight = false)) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/keepalive/NodeLifetimeTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/keepalive/NodeLifetimeTest.kt deleted file mode 100644 index 24f1cab..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/keepalive/NodeLifetimeTest.kt +++ /dev/null @@ -1,130 +0,0 @@ -package com.siriusdevops.onionwire.keepalive - -import com.siriusdevops.onionwire.keepalive.NodeAction.Flush -import com.siriusdevops.onionwire.keepalive.NodeAction.Keep -import com.siriusdevops.onionwire.keepalive.NodeAction.Stop -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * The service-lifetime state machine, no device required: [NodeLifetime] is - * pure. Every case here is a transition the app actually produces — unlock, - * background, task swipe, notification Stop, explicit Lock, re-unlock. - */ -class NodeLifetimeTest { - - @Test - fun ui_detach_with_no_keep_alive_stops_the_node() { - val l = NodeLifetime() - l.onOpened() - - assertEquals(Stop, l.onUnanchored(NodeAnchor.UI)) - assertTrue(l.isOpen) // the caller still has to run flush+shutdown - } - - @Test - fun keep_alive_anchor_survives_ui_detach_and_only_flushes() { - val l = NodeLifetime() - l.onOpened() - l.onAnchored(NodeAnchor.KEEP_ALIVE) - - // Task swiped: the activity is gone, the service is not. - assertEquals(Flush, l.onUnanchored(NodeAnchor.UI)) - assertFalse(l.anchoredBy(NodeAnchor.UI)) - assertTrue(l.anchoredBy(NodeAnchor.KEEP_ALIVE)) - } - - @Test - fun losing_the_last_anchor_stops_the_node() { - val l = NodeLifetime() - l.onOpened() - l.onAnchored(NodeAnchor.KEEP_ALIVE) - l.onUnanchored(NodeAnchor.UI) - - // Notification Stop, or the system killing the service. - assertEquals(Stop, l.onUnanchored(NodeAnchor.KEEP_ALIVE)) - } - - @Test - fun service_stopping_while_the_ui_is_up_keeps_the_node() { - val l = NodeLifetime() - l.onOpened() - l.onAnchored(NodeAnchor.KEEP_ALIVE) - - assertEquals(Flush, l.onUnanchored(NodeAnchor.KEEP_ALIVE)) - assertTrue(l.anchoredBy(NodeAnchor.UI)) - assertTrue(l.isOpen) - } - - @Test - fun repeated_anchor_loss_is_idempotent() { - val l = NodeLifetime() - l.onOpened() - l.onAnchored(NodeAnchor.KEEP_ALIVE) - l.onUnanchored(NodeAnchor.UI) - - // The Stop action and onDestroy both report the same loss. - assertEquals(Stop, l.onUnanchored(NodeAnchor.KEEP_ALIVE)) - l.onClosed() - assertEquals(Keep, l.onUnanchored(NodeAnchor.KEEP_ALIVE)) - } - - @Test - fun lock_drops_every_anchor() { - val l = NodeLifetime() - l.onOpened() - l.onAnchored(NodeAnchor.KEEP_ALIVE) - - assertEquals(Stop, l.onLocked()) - assertFalse(l.isOpen) - assertFalse(l.anchoredBy(NodeAnchor.KEEP_ALIVE)) - assertFalse(l.anchoredBy(NodeAnchor.UI)) - l.onClosed() - } - - @Test - fun re_unlock_after_lock_starts_from_a_clean_slate() { - val l = NodeLifetime() - l.onOpened() - l.onAnchored(NodeAnchor.KEEP_ALIVE) - l.onLocked() - l.onClosed() - - // Second unlock: only the UI anchors, so backgrounding really stops. - assertEquals(Keep, l.onOpened()) - assertFalse(l.anchoredBy(NodeAnchor.KEEP_ALIVE)) - assertEquals(Stop, l.onUnanchored(NodeAnchor.UI)) - } - - @Test - fun re_unlock_while_the_keep_alive_still_holds_the_node_adopts_it() { - // Process relaunch with the service still up: the ViewModel adopts the - // live node and never calls onOpened(), so the KEEP_ALIVE anchor (and - // the node) is untouched by the new UI attaching. - val l = NodeLifetime() - l.onOpened() - l.onAnchored(NodeAnchor.KEEP_ALIVE) - l.onUnanchored(NodeAnchor.UI) - - assertTrue(l.isOpen) - assertTrue(l.anchoredBy(NodeAnchor.KEEP_ALIVE)) - assertFalse(l.anchoredBy(NodeAnchor.UI)) - - // The adopted UI leaves again: still flush, still alive. - assertEquals(Flush, l.onUnanchored(NodeAnchor.UI)) - assertTrue(l.isOpen) - assertEquals(Stop, l.onUnanchored(NodeAnchor.KEEP_ALIVE)) - } - - @Test - fun transitions_on_a_closed_node_do_nothing() { - val l = NodeLifetime() - - assertEquals(Keep, l.onUnanchored(NodeAnchor.UI)) - assertEquals(Keep, l.onUnanchored(NodeAnchor.KEEP_ALIVE)) - assertEquals(Keep, l.onLocked()) - assertEquals(Keep, l.onAnchored(NodeAnchor.KEEP_ALIVE)) // service up, still locked - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/InviteAddFlowTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/InviteAddFlowTest.kt deleted file mode 100644 index d47be8e..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/InviteAddFlowTest.kt +++ /dev/null @@ -1,131 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.async -import kotlinx.coroutines.launch -import kotlinx.coroutines.test.runTest -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertNull -import org.junit.Test - -class InviteAddFlowTest { - - private data class Preview(val id: String) - private data class Added(val id: String) - - @Test - fun add_while_verify_in_flight_completes_add_exactly_once() = runTest { - val decodeEntered = CompletableDeferred() - val decodeGate = CompletableDeferred() - var decodeCount = 0 - var addCount = 0 - val flow = InviteAddFlow( - onDecode = { - decodeCount++ - if (decodeCount == 1) { - decodeEntered.complete(Unit) - decodeGate.await() - } - Preview("p") - }, - onAdd = { - addCount++ - Added("a") - }, - ) - - val verifyJob = launch { flow.verify("invite") } - decodeEntered.await() - flow.add("invite") - decodeGate.complete(Unit) - verifyJob.join() - - assertEquals(1, addCount) - assertEquals(Added("a"), flow.added) - } - - @Test - fun onAdd_is_invoked_exactly_once_per_approve() = runTest { - var addCount = 0 - val flow = InviteAddFlow( - onDecode = { Preview("p") }, - onAdd = { - addCount++ - Added("a") - }, - ) - - flow.verify("invite") - flow.add("invite") - - assertEquals(1, addCount) - assertEquals(Added("a"), flow.added) - } - - @Test - fun failed_decode_sets_error_and_never_calls_onAdd() = runTest { - var addCount = 0 - val flow = InviteAddFlow( - onDecode = { error("bad invite") }, - onAdd = { - addCount++ - Added("a") - }, - ) - - flow.verify("invite") - - assertEquals("bad invite", flow.error) - assertNull(flow.preview) - assertNull(flow.added) - assertEquals(0, addCount) - } - - @Test - fun double_tap_approve_while_in_flight_does_not_add_twice() = runTest { - val addEntered = CompletableDeferred() - val addGate = CompletableDeferred() - var addCount = 0 - val flow = InviteAddFlow( - onDecode = { Preview("p") }, - onAdd = { - addCount++ - addEntered.complete(Unit) - addGate.await() - Added("a") - }, - ) - - flow.verify("invite") - val first = async { flow.add("invite") } - addEntered.await() - val second = async { flow.add("invite") } - addGate.complete(Unit) - first.await() - second.await() - - assertEquals(1, addCount) - assertEquals(Added("a"), flow.added) - } - - @Test - fun after_successful_add_further_taps_are_inert() = runTest { - var addCount = 0 - val flow = InviteAddFlow( - onDecode = { Preview("p") }, - onAdd = { - addCount++ - Added("a") - }, - ) - - flow.verify("invite") - flow.add("invite") - flow.add("invite") - flow.add("invite") - - assertNotNull(flow.added) - assertEquals(1, addCount) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/MessageDeliveryTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/MessageDeliveryTest.kt deleted file mode 100644 index ac35c09..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/MessageDeliveryTest.kt +++ /dev/null @@ -1,180 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNull -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * Renders each of the four core outbox states and asserts the semantic the - * Composable applies for it — the same `testTag` / `contentDescription` values - * `ChatScreen`'s delivery row uses, so a marker change without an announcement - * change fails here. - * - * `compose.ui.test` is not on the JVM unit-test classpath (and adding it is - * outside this card's scope), so the assertion target is the state model that - * the Composable renders from, not a laid-out node. Same shape as - * `InviteAddFlowTest`. - */ -class MessageDeliveryTest { - - private val glyphs = listOf("✓", "◷", "»", "✗") - - private fun out(delivery: String?) = parseDelivery("out", delivery) - - @Test - fun every_core_state_is_rendered_with_its_own_handle_and_sentence() { - val sent = requireNotNull(out("sent")) - val queued = requireNotNull(out("queued")) - val sending = requireNotNull(out("sending")) - val failed = requireNotNull(out("failed: connection timed out")) - - assertEquals(Delivery.Sent, sent) - assertEquals(Delivery.Queued, queued) - assertEquals(Delivery.Sending, sending) - assertEquals(Delivery.Failed("connection timed out"), failed) - - assertEquals("delivery-sent", sent.testTag) - assertEquals("delivery-queued", queued.testTag) - assertEquals("delivery-sending", sending.testTag) - assertEquals("delivery-failed", failed.testTag) - - assertEquals("Delivered", sent.contentDescription) - assertEquals("Queued, not delivered yet: retrying their onion", queued.contentDescription) - assertEquals("Sending", sending.contentDescription) - assertEquals("Failed: connection timed out", failed.contentDescription) - - // Four states, four distinct handles and four distinct sentences. - val all = listOf(sent, queued, sending, failed) - assertEquals(4, all.map { it.testTag }.toSet().size) - assertEquals(4, all.map { it.contentDescription }.toSet().size) - } - - @Test - fun markers_are_visually_distinct_per_state() { - assertEquals("✓✓", Delivery.Sent.marker) - assertEquals("◷ queued", Delivery.Queued.marker) - assertEquals("» sending", Delivery.Sending.marker) - assertEquals("✗ failed: no route", Delivery.Failed("no route").marker) - - val all = listOf( - Delivery.Sent.marker, - Delivery.Queued.marker, - Delivery.Sending.marker, - Delivery.Failed("no route").marker, - ) - assertEquals(4, all.toSet().size) - } - - @Test - fun every_state_announces_words_not_a_bare_glyph() { - val all = listOf( - Delivery.Sent, - Delivery.Queued, - Delivery.Sending, - Delivery.Failed("no route"), - ) - for (d in all) { - for (glyph in glyphs) { - assertFalse( - "${d.testTag} announces a glyph: ${d.contentDescription}", - d.contentDescription.contains(glyph), - ) - } - assertTrue( - "${d.testTag} must announce words, not an icon name: ${d.contentDescription}", - d.contentDescription.length >= 7 && d.contentDescription.any { it.isLetter() }, - ) - } - } - - @Test - fun failed_reason_is_sanitized_tailed_and_capped_like_the_tui() { - // C0 controls and bidi marks are stripped. - assertEquals("badsignature", shortSendReason("bad\u0007\u202esignature")) - // Tail of the `a: b: c` chain. - assertEquals( - "connection timed out", - shortSendReason("dial 7f4k.onion: onion: connection timed out"), - ) - // Capped at the row budget, with the ellipsis inside it. - val long = "x".repeat(80) - val cut = shortSendReason(long) - assertEquals(FAIL_REASON_BUDGET, cut.length) - assertTrue(cut.endsWith("…")) - assertEquals(long, shortSendReason(long, budget = 80)) - } - - @Test - fun an_unrecognised_status_is_queued_never_delivered() { - // A status this build does not know must not read as delivered. - assertEquals(Delivery.Queued, out("spooling")) - assertEquals(Delivery.Queued, out("SENDING")) - } - - @Test - fun a_missing_delivery_on_an_outgoing_row_is_not_called_delivered() { - // The SDK reports "sent" explicitly for an outgoing row with no outbox - // row, so a missing value means nothing was confirmed. - assertEquals(Delivery.Queued, out(null)) - assertEquals(Delivery.Queued, out(" ")) - } - - @Test - fun the_core_reporting_sent_is_the_only_way_to_render_delivered() { - assertEquals(Delivery.Sent, out("sent")) - assertEquals(Delivery.Sent, out(" sent ")) - } - - @Test - fun inbound_rows_carry_no_delivery_state() { - assertNull(parseDelivery("in", null)) - assertNull(parseDelivery("in", "sent")) - } - - @Test - fun blank_failure_reason_still_says_failed() { - val d = out("failed:") as Delivery.Failed - assertEquals("unknown", d.reason) - assertEquals("Failed: unknown", d.contentDescription) - } - - @Test - fun footer_reports_pending_sends_and_keeps_a_failure_statement() { - // Nothing outstanding: no note at all. - assertNull(outboxSummary(listOf(Delivery.Sent, null)).note) - - // Anything still coming is counted, queued and sending alike. - assertEquals( - "2 queued", - outboxSummary(listOf(Delivery.Queued, Delivery.Sending, Delivery.Sent)).note, - ) - - // A terminal failure is stated, not hidden behind the queue count. - val withFailure = outboxSummary(listOf(Delivery.Queued, Delivery.Failed("no route"))) - assertEquals(1, withFailure.queued) - assertEquals(1, withFailure.failed) - assertTrue(withFailure.hasFailures) - assertEquals("1 queued, send failed: no route", withFailure.note) - - // No queue, one failure. - assertEquals( - "send failed: no route", - outboxSummary(listOf(Delivery.Failed("no route"))).note, - ) - // No queue, several failures: first reason plus how many. - assertEquals( - "send failed: no route (3 failed)", - outboxSummary( - listOf( - Delivery.Failed("no route"), - Delivery.Failed("timeout"), - Delivery.Failed("bad identity"), - ), - ).note, - ) - // Nothing pending and nothing failed: silent. - assertFalse(outboxSummary(listOf(Delivery.Sent)).hasFailures) - } -} \ No newline at end of file diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/OutboxDetailTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/OutboxDetailTest.kt deleted file mode 100644 index b5df5ca..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/OutboxDetailTest.kt +++ /dev/null @@ -1,278 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * The SDK's outbox rows turned into chat-row wording: `queued (try 3/8, retry - * 45s)`. - * - * These assert the pure model `ChatScreen` renders from — the same shape as - * `MessageDeliveryTest` — so the retry wording, the fail-closed join and the - * "a failed row never shows a countdown" rule are all covered on the JVM - * without a device. - */ -class OutboxDetailTest { - - private fun out(delivery: String?) = ChatRowInput("out", delivery) - - private fun row( - messageId: Long, - status: String, - attempts: UInt = 0u, - nextAttemptAt: Long = 0L, - ) = OutboxRowInput(messageId, status, attempts, nextAttemptAt) - - // --- retry_in_text: the three buckets, mirroring src/tui.rs ------------- - - @Test - fun retry_in_text_is_now_at_or_before_the_next_attempt_time() { - assertEquals("retry now", retryInText(0L)) - assertEquals("retry now", retryInText(-45L)) - } - - @Test - fun retry_in_text_counts_seconds_below_a_minute() { - assertEquals("retry 1s", retryInText(1L)) - assertEquals("retry 45s", retryInText(45L)) - assertEquals("retry 59s", retryInText(59L)) - } - - @Test - fun retry_in_text_rounds_minutes_up_from_the_first_minute() { - // 60s is one minute, not "retry 1s" and not "retry 0m". - assertEquals("retry 1m", retryInText(60L)) - // Anything over the boundary rounds up, so the app never promises an - // attempt sooner than the store will make one. - assertEquals("retry 2m", retryInText(61L)) - assertEquals("retry 10m", retryInText(600L)) - assertEquals("retry 25m", retryInText(1500L)) - // The core's backoff caps at 30 minutes. - assertEquals("retry 30m", retryInText(1800L)) - } - - // --- the queued row's own numbers --------------------------------------- - - @Test - fun a_queued_row_renders_the_tui_wording() { - val details = outboxDetails( - rows = listOf(out("queued")), - outbox = listOf(row(7L, "queued", attempts = 3u, nextAttemptAt = 1_000L + 45L)), - maxAttempts = 8u, - now = 1_000L, - ) - val detail = requireNotNull(details.single()) - assertEquals("queued (try 3/8, retry 45s)", detail.text) - assertEquals("◷ queued (try 3/8, retry 45s)", deliveryMarkerText(Delivery.Queued, detail)) - } - - @Test - fun the_denominator_comes_from_the_core_not_a_constant_here() { - val detail = requireNotNull( - outboxDetails( - rows = listOf(out("queued")), - outbox = listOf(row(1L, "queued", attempts = 3u, nextAttemptAt = 0L)), - maxAttempts = 12u, - now = 0L, - ).single(), - ) - assertEquals("queued (try 3/12, retry now)", detail.text) - } - - @Test - fun an_overdue_attempt_reads_retry_now() { - val detail = requireNotNull( - outboxDetails( - rows = listOf(out("queued")), - outbox = listOf(row(1L, "queued", attempts = 1u, nextAttemptAt = 900L)), - maxAttempts = 8u, - now = 1_000L, - ).single(), - ) - assertEquals("queued (try 1/8, retry now)", detail.text) - } - - @Test - fun the_countdown_is_computed_from_the_absolute_time_the_store_holds() { - val first = requireNotNull( - outboxDetails( - rows = listOf(out("queued")), - outbox = listOf(row(1L, "queued", attempts = 2u, nextAttemptAt = 1_000L + 600L)), - maxAttempts = 8u, - now = 1_000L, - ).single(), - ) - assertEquals("queued (try 2/8, retry 10m)", first.text) - - // Same row, one minute later: the wording moves with `now`. - val later = requireNotNull( - outboxDetails( - rows = listOf(out("queued")), - outbox = listOf(row(1L, "queued", attempts = 2u, nextAttemptAt = 1_000L + 600L)), - maxAttempts = 8u, - now = 1_060L, - ).single(), - ) - assertEquals("queued (try 2/8, retry 9m)", later.text) - } - - // --- the states that must not show a countdown -------------------------- - - @Test - fun a_failed_row_shows_no_countdown() { - // A terminal row keeps the last time it was scheduled for. Rendering - // that as "retry 15m" would promise an attempt that will never happen. - val details = outboxDetails( - rows = listOf(out("failed: connection timed out")), - outbox = listOf(row(4L, "failed", attempts = 8u, nextAttemptAt = 1_900L)), - maxAttempts = 8u, - now = 1_000L, - ) - assertNull(details.single()) - - val d = requireNotNull(parseDelivery("out", "failed: connection timed out")) - assertEquals("✗ failed: connection timed out", deliveryMarkerText(d, details.single())) - assertEquals("Failed: connection timed out", deliveryAnnouncement(d, details.single())) - } - - @Test - fun a_sending_row_shows_no_countdown() { - val details = outboxDetails( - rows = listOf(out("sending")), - outbox = listOf(row(4L, "sending", attempts = 2u, nextAttemptAt = 1_900L)), - maxAttempts = 8u, - now = 1_000L, - ) - assertNull(details.single()) - - val d = requireNotNull(parseDelivery("out", "sending")) - assertEquals("» sending", deliveryMarkerText(d, details.single())) - } - - @Test - fun delivered_and_inbound_rows_never_take_an_outbox_row() { - // No outbox rows at all: an accepted send and an inbound row are quiet. - val details = outboxDetails( - rows = listOf(ChatRowInput("in", null), out("sent")), - outbox = emptyList(), - maxAttempts = 8u, - now = 1_000L, - ) - assertEquals(listOf(null, null), details) - } - - // --- the join is positional, so it has to prove itself ------------------ - - @Test - fun details_are_attached_to_the_pending_row_in_order() { - val rows = listOf(out("sent"), ChatRowInput("in", null), out("queued"), out("failed: no route")) - val details = outboxDetails( - rows = rows, - outbox = listOf( - row(12L, "queued", attempts = 1u, nextAttemptAt = 1_030L), - row(15L, "failed", attempts = 8u, nextAttemptAt = 1_500L), - ), - maxAttempts = 8u, - now = 1_000L, - ) - assertNull(details[0]) - assertNull(details[1]) - assertEquals("queued (try 1/8, retry 30s)", requireNotNull(details[2]).text) - assertNull(details[3]) - } - - @Test - fun the_join_ignores_the_row_order_the_core_returned() { - val details = outboxDetails( - rows = listOf(out("queued"), out("queued")), - outbox = listOf( - row(20L, "queued", attempts = 1u, nextAttemptAt = 1_010L), - row(10L, "queued", attempts = 2u, nextAttemptAt = 1_020L), - ), - maxAttempts = 8u, - now = 1_000L, - ) - // Sorted by messageId, so the older message owns the 20s row. - assertEquals("queued (try 2/8, retry 20s)", requireNotNull(details[0]).text) - assertEquals("queued (try 1/8, retry 10s)", requireNotNull(details[1]).text) - } - - @Test - fun a_row_count_that_does_not_match_the_pending_sends_drops_every_detail() { - // The app cannot prove which message owns which row, so it says nothing - // rather than showing the wrong attempt count. - val details = outboxDetails( - rows = listOf(out("queued"), out("queued")), - outbox = listOf(row(1L, "queued", attempts = 3u, nextAttemptAt = 1_010L)), - maxAttempts = 8u, - now = 1_000L, - ) - assertEquals(listOf(null, null), details) - } - - @Test - fun a_status_that_contradicts_the_message_drops_every_detail() { - // Positional join + the SDK's own per-message status is the check: the - // first message is queued, the row in its slot says failed. - val details = outboxDetails( - rows = listOf(out("queued"), out("queued")), - outbox = listOf( - row(1L, "failed", attempts = 8u, nextAttemptAt = 1_010L), - row(2L, "queued", attempts = 1u, nextAttemptAt = 1_010L), - ), - maxAttempts = 8u, - now = 1_000L, - ) - assertEquals(listOf(null, null), details) - } - - @Test - fun a_status_this_build_does_not_know_drops_every_detail() { - val details = outboxDetails( - rows = listOf(out("queued")), - outbox = listOf(row(1L, "spooling", attempts = 1u, nextAttemptAt = 1_010L)), - maxAttempts = 8u, - now = 1_000L, - ) - assertEquals(listOf(null), details) - } - - @Test - fun an_unknown_delivery_on_a_pending_row_is_treated_as_pending() { - // parseDelivery maps an unrecognised outgoing status to Queued (never - // delivered), so the row still wants its outbox row. - val detail = requireNotNull( - outboxDetails( - rows = listOf(out("spooling")), - outbox = listOf(row(1L, "queued", attempts = 1u, nextAttemptAt = 1_000L)), - maxAttempts = 8u, - now = 1_000L, - ).single(), - ) - assertEquals("queued (try 1/8, retry now)", detail.text) - } - - // --- a11y --------------------------------------------------------------- - - @Test - fun the_announcement_keeps_the_sentence_and_adds_the_numbers() { - val detail = requireNotNull( - outboxDetails( - rows = listOf(out("queued")), - outbox = listOf(row(1L, "queued", attempts = 3u, nextAttemptAt = 1_045L)), - maxAttempts = 8u, - now = 1_000L, - ).single(), - ) - val said = deliveryAnnouncement(Delivery.Queued, detail) - assertEquals( - "Queued, not delivered yet: retrying their onion (try 3/8, retry 45s)", - said, - ) - // Never a bare glyph, and never only numbers. - assertTrue(said.any { it.isLetter() }) - assertTrue(!said.contains("◷")) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/ProfileDraftTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/ProfileDraftTest.kt deleted file mode 100644 index aa7f9b2..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/ProfileDraftTest.kt +++ /dev/null @@ -1,254 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNull -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * The profile screen's rules, on the JVM. - * - * These are the decisions `ProfileScreen` renders from: whether Save is live, - * whether a typed address can be written at all, which bio a save actually - * persists, and what the status line says after pushing to the roster. Pure - * logic — no Robolectric, no Compose test dependency, no device — same shape as - * `SeedBackupGateTest` and `RosterIdTest`. - * - * The address check is injected (`profileAddressProblem` takes the predicate), - * so the contract under test is the screen's, not UniFFI's: `check_address`'s - * own behaviour is covered by the SDK's Rust tests. - */ -class ProfileDraftTest { - - /** A loaded profile, i.e. what the store held when the screen opened. */ - private val loaded = ProfileDraft( - nickname = "lance", - bio = "gardener, mostly drip irrigation", - address = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A", - ) - - // --- the save button's rule --------------------------------------------- - - @Test - fun save_is_dead_until_the_first_read_lands() { - // `loaded == null` is "the screen has not read the store yet", not "the - // form is unchanged" — writing before the read would fight the store. - assertFalse(profileSaveEnabled(null, loaded)) - assertFalse(profileSaveEnabled(null, ProfileDraft())) - } - - @Test - fun save_is_dead_while_the_form_is_unchanged() { - assertFalse(profileSaveEnabled(loaded, loaded.copy())) - } - - @Test - fun save_is_live_as_soon_as_any_field_differs() { - assertTrue(profileSaveEnabled(loaded, loaded.copy(nickname = "lance2"))) - assertTrue(profileSaveEnabled(loaded, loaded.copy(bio = "something else"))) - assertTrue(profileSaveEnabled(loaded, loaded.copy(address = ""))) - } - - @Test - fun an_empty_nickname_is_a_real_edit_and_is_allowed() { - // Picked deliberately: the core accepts an empty `display_name` (it only - // bounds the length and forbids newlines), the TUI's `/profile` accepts - // it, and the roster already falls back to the fingerprint. So clearing - // a nickname must be saveable rather than hidden behind a disabled - // button the user cannot explain. - val cleared = loaded.copy(nickname = "") - assertTrue(profileSaveEnabled(loaded, cleared)) - assertEquals("", cleared.normalized().nickname) - } - - @Test - fun whitespace_around_a_field_is_not_a_change() { - // A trailing space from a paste or an autocorrect habit must not offer a - // save that would write the same value back. - val padded = loaded.copy(nickname = " lance ", address = "${loaded.address}\n") - assertFalse(profileSaveEnabled(loaded, padded)) - } - - @Test - fun normalising_strips_only_the_edges() { - // Interior whitespace is the user's: a bio may well want it. - val n = ProfileDraft(" a b ", " x y ", " addr ").normalized() - assertEquals("a b", n.nickname) - assertEquals("x y", n.bio) - assertEquals("addr", n.address) - } - - // --- the address check --------------------------------------------------- - - /** Stands in for `uniffi.onionwire_sdk.checkAddress`: anything but "" ok. */ - private val accepts: (String) -> Result = { Result.success(Unit) } - - /** The core's own words, copied from `pay::check_address`. */ - private val rejects: (String) -> Result = - { Result.failure(IllegalStateException("invalid Monero address")) } - - @Test - fun an_empty_address_is_allowed_and_is_never_checked() { - var calls = 0 - val counted: (String) -> Result = { calls++; Result.success(Unit) } - // Empty clears the profile address, which the core permits — and - // `check_address("")` would fail, so the predicate must not even run. - assertNull(profileAddressProblem("", counted)) - assertNull(profileAddressProblem(" ", counted)) - assertEquals(0, calls) - } - - @Test - fun a_valid_address_passes() { - assertNull(profileAddressProblem(loaded.address, accepts)) - } - - @Test - fun an_invalid_address_is_refused_with_the_cores_own_words() { - assertEquals( - "invalid Monero address", - profileAddressProblem("not-an-address", rejects), - ) - } - - @Test - fun the_check_sees_the_value_that_would_be_written() { - // The screen saves `normalized()`, so the check must see the trimmed - // address, not the raw field — otherwise a paste with a trailing space - // passes the pre-check and then fails inside the core. - var seen: String? = null - val spy: (String) -> Result = { seen = it; Result.success(Unit) } - assertNull(profileAddressProblem(" ${loaded.address} ", spy)) - assertEquals(loaded.address, seen) - } - - @Test - fun a_failure_without_a_message_still_reports_something() { - val blank: (String) -> Result = - { Result.failure(RuntimeException()) } - val problem = profileAddressProblem("x", blank) - assertTrue(problem != null && problem.isNotEmpty()) - } - - // --- the bio is carried, not owned -------------------------------------- - - @Test - fun an_untouched_bio_writes_back_what_the_store_holds_now() { - // The TUI edited the bio since this screen loaded. The phone save did - // not touch the field, so the store's value must win — blanking it here - // is exactly the regression this rule exists to prevent. - assertEquals( - "set in the TUI after this screen opened", - bioToWrite( - draftBio = loaded.bio, - loadedBio = loaded.bio, - storedBio = "set in the TUI after this screen opened", - ), - ) - } - - @Test - fun an_edited_bio_writes_what_the_user_typed() { - assertEquals( - "typed on the phone", - bioToWrite( - draftBio = "typed on the phone", - loadedBio = loaded.bio, - storedBio = "set in the TUI after this screen opened", - ), - ) - } - - @Test - fun padding_a_bio_is_not_an_edit() { - // Same normalisation as the dirty check: a trailing space is not a - // reason to override a bio someone set elsewhere. - assertEquals( - loaded.bio, - bioToWrite("${loaded.bio} ", loaded.bio, loaded.bio), - ) - } - - // --- labels --------------------------------------------------------------- - - @Test - fun a_friend_is_labelled_by_petname_else_by_short_id() { - val fp = "654c4a382299b364d1345cf69961e1d529659122fc1550c7c75c537b2a30aa99" - assertEquals("Bob", friendLabel("Bob", fp)) - assertEquals(shortId(fp), friendLabel(null, fp)) - // A roster row with a blank petname renders the fingerprint too. - assertEquals(shortId(fp), friendLabel(" ", fp)) - } - - // --- the status line ------------------------------------------------------ - - @Test - fun an_empty_roster_reports_a_plain_save() { - // The TUI's word for "written locally, sent to nobody". - assertEquals("profile saved", profileStatusLine(emptyList())) - } - - @Test - fun a_clean_push_names_the_count() { - val one = profileStatusLine(listOf(ProfilePushOutcome("Bob"))) - assertEquals("profile saved · sent to 1 friend", one) - - val three = profileStatusLine( - listOf( - ProfilePushOutcome("Bob"), - ProfilePushOutcome("Ann"), - ProfilePushOutcome("654c4a…aa99"), - ), - ) - assertEquals("profile saved · sent to 3 friends", three) - } - - @Test - fun a_failed_push_still_starts_with_the_local_write() { - // The split that matters: the store was written, one peer was not - // reached. A status line that reads as a failed save sends the user - // back to re-do a write that already happened. - val line = profileStatusLine( - listOf( - ProfilePushOutcome("Bob"), - ProfilePushOutcome("Ann", "connect failed"), - ), - ) - assertTrue(line.startsWith("profile saved")) - assertTrue(line.contains("sent to 1 of 2 friends")) - assertTrue(line.contains("failed: Ann: connect failed")) - } - - @Test - fun every_failure_is_listed_by_name() { - val line = profileStatusLine( - listOf( - ProfilePushOutcome("Bob", "connect failed"), - ProfilePushOutcome("654c4a…aa99", "friend missing prekey"), - ), - ) - assertTrue(line.contains("sent to 0 of 2 friends")) - assertTrue(line.contains("Bob: connect failed")) - assertTrue(line.contains("654c4a…aa99: friend missing prekey")) - } - - // --- the empty-address consequence, on screen ----------------------------- - - @Test - fun an_empty_address_says_nobody_can_pay() { - val text = profileAddressNotice("") - assertTrue(text.contains("clears the profile address")) - // The consequence, not the process name: the copy no longer says - // "wallet child" anywhere a user can read it. - assertTrue(text.contains("running wallet")) - assertTrue(text.contains("nobody can send you an invoice")) - } - - @Test - fun a_filled_address_says_it_is_validated_before_the_write() { - val text = profileAddressNotice(loaded.address) - assertTrue(text.contains("Validated")) - assertTrue(text.contains("refused")) - } -} \ No newline at end of file diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterIdTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterIdTest.kt deleted file mode 100644 index d890fb3..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterIdTest.kt +++ /dev/null @@ -1,84 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * `shortId`, the roster's collapsed identity line, on the JVM. - * - * The collapsed card shows the fingerprint through this function, and the - * expanded one shows the raw value; the two must never disagree about what the - * fingerprint *is*, so the abbreviation has to be a pure slice of the input - * with nothing invented. Pure logic, no Robolectric — same shape as - * `SeedBackupGateTest` and `WalletChildStatusTextTest`. - */ -class RosterIdTest { - - /** An ed25519 pubkey as the core prints it: 64 lowercase hex characters. */ - private val fingerprint = - "9f2c41ab77de03b5c8e1f0a6d4b39c2e5a7f81c0d3e6b492af17c5d80e3b6a49" - - // --- the long case ------------------------------------------------------- - - @Test - fun a_long_fingerprint_becomes_head_ellipsis_tail() { - assertEquals("9f2c41…6a49", shortId(fingerprint)) - } - - @Test - fun the_abbreviation_is_a_slice_of_the_input_not_a_re_encoding() { - // The head and the tail must be literally the input's own characters: - // a summary that cannot be checked against the full value is worse than - // no summary. - val short = shortId(fingerprint) - assertEquals(fingerprint.take(6), short.substringBefore("…")) - assertEquals(fingerprint.takeLast(4), short.substringAfter("…")) - // Nothing invented to pad the middle: 6 + "…" + 4. - assertEquals(11, short.length) - } - - @Test - fun head_and_tail_are_call_sites_choice() { - assertEquals("9f2c…6a49", shortId(fingerprint, head = 4, tail = 4)) - assertEquals("9f2c41ab77…3b6a49", shortId(fingerprint, head = 10, tail = 6)) - } - - // --- the short case ------------------------------------------------------ - - @Test - fun a_string_shorter_than_head_tail_plus_one_is_returned_unchanged() { - // head + tail + 1 == 11 here, so anything of 10 characters or fewer has - // no middle worth hiding. - assertEquals("abcdefghij", shortId("abcdefghij")) - assertEquals("abc", shortId("abc")) - assertEquals("a", shortId("a")) - } - - @Test - fun the_first_length_that_abbreviates_is_head_tail_plus_one() { - // The boundary, both sides: 10 unchanged, 11 abbreviated to the same - // length with the middle character collapsed. - assertEquals("abcdefghij", shortId("abcdefghij")) - assertEquals("abcdef…hijk", shortId("abcdefghijk")) - } - - // --- the empty case ------------------------------------------------------ - - @Test - fun an_empty_string_stays_empty() { - // `ready.fingerprint` is always populated in practice, but the function - // must not turn "nothing" into "…" on a card that is already on screen. - assertEquals("", shortId("")) - } - - // --- the shape the card relies on --------------------------------------- - - @Test - fun the_ellipsis_is_the_single_character_one() { - // U+2026, not three dots: the collapsed line is monospace and a - // three-dot tail is four cells where the design budgeted one. - assertTrue(shortId(fingerprint).contains("\u2026")) - assertEquals(1, shortId(fingerprint).count { it == '\u2026' }) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterOnionTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterOnionTest.kt deleted file mode 100644 index 0fa45bf..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterOnionTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * `shortOnion`, the roster's locator abbreviation, on the JVM. - * - * A v3 onion locator must never be soft-wrapped or reduced to a middle slice - * that hides `.onion`: the suffix is what tells a reader this is an onion - * address at all, and the full value is available on the profile and invite - * screens. Pure logic, no Robolectric — same shape as `RosterIdTest`. - */ -class RosterOnionTest { - - private val v3 = - "abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwxyz234567.onion" - - @Test - fun a_v3_locator_keeps_its_suffix() { - val short = shortOnion(v3) - assertEquals(true, short.endsWith(".onion")) - assertEquals(v3.take(10), short.substringBefore("\u2026")) - assertEquals(v3.removeSuffix(".onion").takeLast(6), short.removeSuffix(".onion").substringAfter("\u2026")) - } - - @Test - fun the_suffix_is_never_the_part_that_is_cut() { - // Even with an aggressive abbreviation the reader still sees `….onion`. - val body = v3.removeSuffix(".onion") - val short = shortOnion(v3, head = 3, tail = 2) - assertEquals(body.take(3) + "\u2026" + body.takeLast(2) + ".onion", short) - } - - @Test - fun a_short_value_is_returned_unchanged() { - assertEquals("abc.onion", shortOnion("abc.onion")) - assertEquals("", shortOnion("")) - } - - @Test - fun a_value_with_no_suffix_is_not_mangled() { - assertEquals("not-an-onion", shortOnion("not-an-onion")) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/SeedBackupGateTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/SeedBackupGateTest.kt deleted file mode 100644 index 9318753..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/SeedBackupGateTest.kt +++ /dev/null @@ -1,176 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * The seed-backup gate's rules, on the JVM. - * - * These are the decisions the wallet screen renders from: whether the created - * seed card is still blocking, whether the persistent warning is up, and - * whether the receive address is on screen at all. Pure logic, so no - * Robolectric and no Compose test dependency — same shape as - * `WalletChildStatusTextTest` and `OutboxDetailTest`. - */ -class SeedBackupGateTest { - - /** A wallet the child can actually read: `wallet_balance` returned a value. */ - private val readable = true - - /** `wallet_balance` said "off" (no chain source) or "err" (nothing open). */ - private val notReadable = false - - // --- the confirm word is the TUI's word --------------------------------- - - @Test - fun the_confirm_word_is_the_tui_word() { - // `src/tui.rs` `WalletSetup::CreateSeed` compares against "SEEN". A - // second convention here would be a different gate than the TUI's. - assertEquals("SEEN", SeedBackupGate.CONFIRM_WORD) - } - - @Test - fun a_correct_word_releases_the_block_whatever_its_case_or_padding() { - assertTrue(SeedBackupGate.accepts("SEEN")) - // The TUI compares with `eq_ignore_ascii_case`. - assertTrue(SeedBackupGate.accepts("seen")) - assertTrue(SeedBackupGate.accepts("SeEn")) - // A soft keyboard auto-capitalises and a paste can carry whitespace. - assertTrue(SeedBackupGate.accepts(" seen ")) - } - - @Test - fun a_blank_or_wrong_word_stays_blocked() { - assertFalse(SeedBackupGate.accepts("")) - assertFalse(SeedBackupGate.accepts(" ")) - assertFalse(SeedBackupGate.accepts("SEE")) - // A prefix is not the word: the TUI only fires on the whole match. - assertFalse(SeedBackupGate.accepts("SEENN")) - assertFalse(SeedBackupGate.accepts("seen.")) - // The other word in this flow is the spend-authority one. - assertFalse(SeedBackupGate.accepts("SPEND")) - } - - @Test - fun done_is_dead_until_the_word_is_right() { - assertFalse(SeedBackupGate.confirmEnabled("")) - assertFalse(SeedBackupGate.confirmEnabled("SEENN")) - assertTrue(SeedBackupGate.confirmEnabled("SEEN")) - assertTrue(SeedBackupGate.confirmEnabled("seen")) - } - - // --- the state transitions ---------------------------------------------- - - @Test - fun a_create_starts_unbacked() { - assertFalse(SeedBackupGate.afterWallet(WalletKeyOrigin.Created)) - } - - @Test - fun an_import_is_backed_up_without_the_gate() { - // The user pasted the seed to get here, so there is nothing to confirm. - assertTrue(SeedBackupGate.afterWallet(WalletKeyOrigin.Imported)) - } - - @Test - fun a_successful_confirm_marks_the_wallet_backed_up() { - val created = SeedBackupGate.afterWallet(WalletKeyOrigin.Created) - assertTrue(SeedBackupGate.afterConfirm("SEEN", created)) - } - - @Test - fun a_wrong_word_leaves_an_unbacked_wallet_unbacked() { - assertFalse(SeedBackupGate.afterConfirm("", false)) - assertFalse(SeedBackupGate.afterConfirm("nope", false)) - } - - @Test - fun a_wrong_word_cannot_un_confirm_a_backed_up_wallet() { - // Done is disabled for a wrong word, but the flag must not be a way to - // walk a confirmed wallet back into the hidden-address state. - assertTrue(SeedBackupGate.afterConfirm("", true)) - assertTrue(SeedBackupGate.afterConfirm("SPEND", true)) - } - - @Test - fun a_new_create_resets_a_confirmed_wallet_to_unbacked() { - // Create -> confirm -> create again: the second wallet file has its own - // seed, and nobody has read it yet. - val first = - SeedBackupGate.afterConfirm("SEEN", SeedBackupGate.afterWallet(WalletKeyOrigin.Created)) - assertTrue(first) - assertFalse(SeedBackupGate.afterWallet(WalletKeyOrigin.Created)) - } - - // --- what the screen does with the flag --------------------------------- - - @Test - fun a_created_wallet_keeps_the_strip_up_until_the_word_is_typed() { - val created = SeedBackupGate.afterWallet(WalletKeyOrigin.Created) - assertTrue(SeedBackupGate.warningVisible(created, readable)) - - val confirmed = SeedBackupGate.afterConfirm("seen", created) - assertFalse(SeedBackupGate.warningVisible(confirmed, readable)) - } - - @Test - fun an_imported_wallet_never_shows_the_strip() { - val backedUp = SeedBackupGate.afterWallet(WalletKeyOrigin.Imported) - assertFalse(SeedBackupGate.warningVisible(backedUp, readable)) - assertFalse(SeedBackupGate.warningVisible(backedUp, notReadable)) - } - - @Test - fun a_created_wallet_keeps_the_strip_up_even_before_its_balance_reads() { - // A create is proof a wallet exists, so a child that has not answered - // yet must not be read as "no wallet to warn about". - assertTrue(SeedBackupGate.warningVisible(false, notReadable)) - } - - @Test - fun the_receive_address_is_hidden_while_the_seed_is_unconfirmed() { - assertFalse(SeedBackupGate.receiveAddressVisible(false, readable)) - assertTrue(SeedBackupGate.receiveAddressVisible(true, readable)) - } - - @Test - fun a_created_wallet_hides_its_receive_address_until_the_word_is_typed() { - val created = SeedBackupGate.afterWallet(WalletKeyOrigin.Created) - assertFalse(SeedBackupGate.receiveAddressVisible(created, readable)) - - val confirmed = SeedBackupGate.afterConfirm("seen", created) - assertTrue(SeedBackupGate.receiveAddressVisible(confirmed, readable)) - } - - @Test - fun an_install_that_never_created_a_wallet_here_waits_for_a_readable_wallet() { - // `null` is "nothing stored": an install that predates the flag, or one - // that has only configured a chain source. `wallet_balance` returns - // "err" for a configured chain whose child has no wallet open, and a - // first-run user is in exactly that state — nagging them about a seed - // they do not have is the false positive this rule exists to prevent. - assertFalse(SeedBackupGate.warningVisible(null, notReadable)) - assertTrue(SeedBackupGate.receiveAddressVisible(null, notReadable)) - } - - @Test - fun an_unconfirmed_wallet_that_predates_the_flag_is_warned_about_once_it_reads() { - // The user this gate is for: they created a wallet on an older build, - // so nothing is stored, but the child can read the wallet. That is a - // real wallet whose seed nobody has confirmed. - assertTrue(SeedBackupGate.warningVisible(null, readable)) - assertFalse(SeedBackupGate.receiveAddressVisible(null, readable)) - } - - @Test - fun the_strip_says_why_the_address_is_gone() { - // The hiding is only fair if the strip names it; assert the strip is - // not empty and actually mentions the seed and the receive address. - val text = SeedBackupGate.WARNING - assertTrue(text.contains("seed")) - assertTrue(text.contains("receive address")) - assertTrue(text.contains("recovered")) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/UnlockSubmitTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/UnlockSubmitTest.kt deleted file mode 100644 index d91c221..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/UnlockSubmitTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull -import org.junit.Test - -/** - * IME Done and the Open button must share one submit: the keyboard's action - * key used to dismiss the IME and never call unlock, so bootstrap never - * started. Empty stays a no-op (the SDK would fail closed; we never open). - */ -class UnlockSubmitTest { - - @Test - fun empty_passphrase_does_not_submit() { - assertNull(unlockSubmit("", remember = true)) - assertNull(unlockSubmit("", remember = false)) - } - - @Test - fun typed_passphrase_is_handed_over_with_the_remember_flag() { - assertEquals( - UnlockSubmit(passphrase = "correct horse", remember = true), - unlockSubmit("correct horse", remember = true), - ) - assertEquals( - UnlockSubmit(passphrase = "correct horse", remember = false), - unlockSubmit("correct horse", remember = false), - ) - } - - @Test - fun interior_spaces_are_part_of_the_passphrase_not_trimmed() { - assertEquals( - UnlockSubmit(passphrase = " lead", remember = false), - unlockSubmit(" lead", remember = false), - ) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt deleted file mode 100644 index 255c217..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt +++ /dev/null @@ -1,760 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import com.siriusdevops.onionwire.wallet.NO_WALLET_RPC_MESSAGE -import com.siriusdevops.onionwire.wallet.WalletChildBinaryPaths -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertNull -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * The wallet-child status line the screen renders from - * `Wire::wallet_status()`. - * - * These assert the pure model — the same shape as `MessageDeliveryTest` and - * `OutboxDetailTest` — so the rules that matter are covered on the JVM without - * a device: every core state has its own word, a died child never reads as - * `off` and never as `ready`, an unknown state is never `ready`, and Start is - * only offered when there is something to spawn. - */ -class WalletChildStatusTextTest { - - private fun input( - state: String, - running: Boolean = false, - configured: Boolean = true, - chainSource: String = "remote daemon", - chainInProcess: Boolean = false, - nodeAvailable: Boolean = true, - nodeState: String = "", - height: ULong = 0uL, - targetHeight: ULong = 0uL, - lastError: String? = null, - ) = WalletChildInput( - state = state, - running = running, - configured = configured, - chainSource = chainSource, - chainInProcess = chainInProcess, - nodeAvailable = nodeAvailable, - nodeState = nodeState, - height = height, - targetHeight = targetHeight, - lastError = lastError, - ) - - private val bundled = WalletChildBinaryPaths(walletRpc = "/lib/libmonerowalletrpc.so", arti = null) - private val noBinary = WalletChildBinaryPaths(walletRpc = null, arti = null) - - // --- every core state has its own word --------------------------------- - - @Test - fun each_core_state_maps_to_its_own_phase() { - assertTrue(walletChildPhase(input("off")) is WalletChildPhase.Off) - assertTrue(walletChildPhase(input("connecting")) is WalletChildPhase.Connecting) - assertTrue(walletChildPhase(input("syncing")) is WalletChildPhase.Syncing) - assertTrue(walletChildPhase(input("ready")) is WalletChildPhase.Ready) - assertTrue(walletChildPhase(input("exited")) is WalletChildPhase.Exited) - } - - @Test - fun nothing_read_yet_is_not_off() { - val phase = walletChildPhase(null) - assertTrue(phase is WalletChildPhase.Unread) - assertEquals("reading…", phase.label) - } - - @Test - fun state_matching_tolerates_case_and_padding() { - assertTrue(walletChildPhase(input(" READY ")) is WalletChildPhase.Ready) - assertTrue(walletChildPhase(input("Exited")) is WalletChildPhase.Exited) - } - - // --- a died child is never "off" and never "ready" --------------------- - - @Test - fun exited_is_its_own_state_and_never_off_or_ready() { - val phase = walletChildPhase(input("exited", lastError = "spawn monero-wallet-rpc: No such file")) - assertTrue(phase is WalletChildPhase.Exited) - assertTrue("a died child is dead", phase.dead) - assertFalse("a died child is not off", phase is WalletChildPhase.Off) - assertFalse("a died child is not ready", phase is WalletChildPhase.Ready) - assertFalse("a died child is not live", phase.live) - } - - @Test - fun exited_keeps_the_cores_reason() { - val phase = walletChildPhase(input("exited", lastError = "child exited with status 1")) - assertEquals("child exited with status 1", (phase as WalletChildPhase.Exited).reason) - } - - // --- an unknown state is never ready ----------------------------------- - - @Test - fun an_unknown_state_is_never_ready() { - val phase = walletChildPhase(input("wobbling")) - assertTrue(phase is WalletChildPhase.Unrecognised) - assertFalse("an unknown state must not read as ready", phase is WalletChildPhase.Ready) - assertTrue(phase.label.startsWith("unknown")) - } - - @Test - fun an_unknown_state_word_is_cut_and_sanitized() { - val raw = "wobbling\u0000\u0007" + "x".repeat(80) - val phase = walletChildPhase(input(raw)) as WalletChildPhase.Unrecognised - assertFalse("controls must not reach the screen", phase.label.contains('\u0000')) - assertTrue("the word is capped", phase.label.length < raw.length) - } - - // --- the status line names the chain source ---------------------------- - - @Test - fun the_line_names_the_chain_source_the_core_reported() { - assertEquals("off · receive-only", walletChildLine(input("off", chainSource = "receive-only"))) - assertEquals( - "ready · remote onion daemon", - walletChildLine(input("ready", running = true, chainSource = "remote onion daemon")), - ) - assertEquals( - "connecting · local node", - walletChildLine(input("connecting", running = true, chainSource = "local node")), - ) - } - - @Test - fun the_line_says_when_there_is_no_chain_source() { - assertEquals("off · no chain source", walletChildLine(input("off", chainSource = " "))) - } - - @Test - fun the_line_carries_the_cores_failure_text() { - val line = walletChildLine( - input("off", lastError = "spawn monero-wallet-rpc: Permission denied"), - ) - assertTrue(line, line.contains("Permission denied")) - assertTrue("the state word survives", line.startsWith("off · ")) - } - - @Test - fun an_exited_child_with_no_reason_still_says_it_is_gone() { - val line = walletChildLine(input("exited", lastError = null)) - assertTrue(line, line.contains("gone")) - } - - @Test - fun a_long_failure_text_is_cut_like_a_chat_row() { - val line = walletChildLine(input("off", lastError = "a: b: " + "y".repeat(400))) - assertTrue(line, line.length < 120) - } - - // --- Start is only offered when there is something to spawn ------------ - - @Test - fun start_is_blocked_when_the_build_carries_no_binary() { - val why = startBlockedReason(noBinary, input("off")) - assertEquals(NO_WALLET_RPC_MESSAGE, why) - } - - @Test - fun start_is_blocked_before_the_first_read() { - assertEquals(READING_CHILD_NOTICE, startBlockedReason(bundled, null)) - } - - @Test - fun start_is_blocked_with_no_chain_source() { - val why = startBlockedReason(bundled, input("off", configured = false, chainSource = "receive-only")) - assertNotNull(why) - assertTrue(why!!, why.contains("chain source")) - } - - @Test - fun start_is_blocked_while_the_child_is_already_running() { - val why = startBlockedReason(bundled, input("ready", running = true)) - assertNotNull(why) - assertTrue(why!!, why.contains("already running")) - } - - @Test - fun start_is_blocked_for_an_onion_daemon_without_the_socks_child() { - val why = startBlockedReason(bundled, input("off"), onionDaemon = true) - assertEquals(ONION_NEEDS_ARTI_NOTICE, why) - } - - @Test - fun start_is_allowed_for_a_clearnet_daemon_with_the_binary_present() { - assertNull(startBlockedReason(bundled, input("off"))) - } - - @Test - fun start_is_blocked_while_start_is_in_flight() { - assertEquals( - STARTING_CHILD_NOTICE, - startBlockedReason(bundled, input("off"), starting = true), - ) - } - - @Test - fun start_is_allowed_again_after_the_child_exited() { - assertNull( - "a died child must be restartable", - startBlockedReason(bundled, input("exited", lastError = "child exited with status 1")), - ) - } - - // --- Stop --------------------------------------------------------------- - - @Test - fun stop_is_blocked_when_nothing_is_running() { - assertTrue(stopBlockedReason(input("off"))!!.contains("No wallet is running")) - assertTrue(stopBlockedReason(input("exited"))!!.contains("No wallet is running")) - assertEquals(READING_CHILD_NOTICE, stopBlockedReason(null)) - } - - @Test - fun stop_is_allowed_while_a_child_is_up() { - assertNull(stopBlockedReason(input("connecting", running = true))) - assertNull(stopBlockedReason(input("syncing", running = true))) - assertNull(stopBlockedReason(input("ready", running = true))) - } - - // --- onion detection mirrors the core ---------------------------------- - - @Test - fun onion_detection_matches_the_cores_rule() { - assertTrue(isOnionHost("abcdefghijklmnop.onion")) - assertTrue(isOnionHost("ABCDEFGH.ONION")) - assertTrue(isOnionHost(" abcdefgh.onion ")) - assertFalse(isOnionHost("onion.example.com")) - assertFalse(isOnionHost("127.0.0.1")) - assertFalse(isOnionHost("node.onion.example.com")) - } - - // --- the daemon address field ------------------------------------------ - - @Test - fun daemon_address_parses_host_and_port() { - assertEquals(DaemonAddress("127.0.0.1", 18089), parseDaemonAddress("127.0.0.1:18089")) - assertEquals(DaemonAddress("abc.onion", 18081), parseDaemonAddress(" abc.onion:18081 ")) - assertEquals(DaemonAddress("node.example.com", 18089), parseDaemonAddress("node.example.com:18089")) - assertEquals(DaemonAddress("::1", 18089), parseDaemonAddress("[::1]:18089")) - } - - @Test - fun daemon_address_rejects_what_it_cannot_split_honestly() { - assertNull(parseDaemonAddress("")) - assertNull(parseDaemonAddress("node.example.com")) - assertNull(parseDaemonAddress(":18089")) - assertNull(parseDaemonAddress("node.example.com:")) - assertNull(parseDaemonAddress("node.example.com:0")) - assertNull(parseDaemonAddress("node.example.com:70000")) - assertNull(parseDaemonAddress("node.example.com:eight")) - assertNull("a bare IPv6 has no unambiguous split", parseDaemonAddress("::1:18089")) - } - - @Test - fun daemon_address_round_trips_through_its_text_form() { - val parsed = parseDaemonAddress("127.0.0.1:18089")!! - assertEquals("127.0.0.1:18089", parsed.text) - } - - // --- the on-device node (Cuprate) --------------------------------------- - - private fun node( - state: String = "syncing", - chainSource: String = "in-process node", - nodeState: String, - nodeAvailable: Boolean = true, - running: Boolean = true, - height: ULong = 0uL, - targetHeight: ULong = 0uL, - ) = input( - state = state, - running = running, - chainSource = chainSource, - chainInProcess = true, - nodeAvailable = nodeAvailable, - nodeState = nodeState, - height = height, - targetHeight = targetHeight, - ) - - @Test - fun each_core_node_state_maps_to_its_own_phase() { - assertTrue(nodePhase(node(nodeState = "off")) is NodePhase.Off) - assertTrue(nodePhase(node(nodeState = "starting")) is NodePhase.Starting) - assertTrue(nodePhase(node(nodeState = "syncing")) is NodePhase.Syncing) - assertTrue(nodePhase(node(nodeState = "ready")) is NodePhase.Ready) - assertTrue(nodePhase(node(nodeState = "exited")) is NodePhase.Exited) - } - - @Test - fun only_an_in_process_source_has_a_node_segment() { - assertTrue(nodePhase(input("ready", running = true)) is NodePhase.Absent) - assertTrue(nodePhase(null) is NodePhase.Absent) - // In-process, but the core has not reported a node word yet: no segment, - // rather than an invented one. - assertTrue(nodePhase(node(nodeState = "")) is NodePhase.Absent) - } - - @Test - fun an_unknown_node_state_is_never_ready() { - val phase = nodePhase(node(nodeState = "mining")) - assertTrue(phase is NodePhase.Unrecognised) - assertFalse("an unknown node word must not read as ready", phase is NodePhase.Ready) - assertTrue(phase.label.startsWith("unknown")) - } - - @Test - fun the_line_grows_a_node_segment_for_the_in_process_source() { - assertEquals( - "syncing · in-process node · node syncing", - walletChildLine(node(state = "syncing", nodeState = "syncing")), - ) - assertEquals( - "ready · in-process node · node ready", - walletChildLine(node(state = "ready", nodeState = "ready")), - ) - } - - @Test - fun the_line_has_no_node_segment_for_the_other_sources() { - assertFalse(walletChildLine(input("ready", running = true)).contains("node ")) - assertFalse(walletChildLine(input("off", chainSource = "receive-only")).contains("node ")) - } - - // --- the daemon's sync height on the line -------------------------------- - - @Test - fun no_sync_segment_when_the_daemon_reported_nothing() { - // `0/0` is unknown — the probe failed or the daemon is not up — so the - // line says nothing rather than printing a number it does not have. - val line = walletChildLine(input("off", chainSource = "receive-only")) - assertEquals("off · receive-only", line) - // The `sync` *segment*, not the substring: `syncing` is a phase word. - assertFalse("no height is not a height of zero", line.contains(" · sync ")) - assertFalse( - walletChildLine(node(nodeState = "starting")).contains(" · sync "), - ) - } - - @Test - fun the_line_carries_the_daemons_height_and_target() { - assertEquals( - "connecting · in-process mainnet pruned · node starting · sync 1160/3090939", - walletChildLine( - node( - state = "connecting", - chainSource = "in-process mainnet pruned", - nodeState = "starting", - height = 1160uL, - targetHeight = 3_090_939uL, - ), - ), - ) - } - - @Test - fun a_zero_target_still_prints_as_zero_and_never_as_a_percent() { - val line = walletChildLine( - node( - state = "syncing", - chainSource = "in-process mainnet pruned", - nodeState = "syncing", - height = 4549uL, - targetHeight = 0uL, - ), - ) - assertEquals( - "syncing · in-process mainnet pruned · node syncing · sync 4549/0", - line, - ) - assertFalse("no percent is invented", line.contains("%")) - } - - @Test - fun the_height_sits_before_the_failure_text() { - val line = walletChildLine( - input("off", height = 7uL, lastError = "spawn monero-wallet-rpc: Permission denied"), - ) - assertTrue(line, line.startsWith("off · remote daemon · sync 7/0 — ")) - assertTrue(line, line.contains("Permission denied")) - } - - @Test - fun the_spoken_row_says_the_same_height_the_eye_reads() { - val input = node( - state = "connecting", - chainSource = "in-process mainnet pruned", - nodeState = "starting", - height = 1160uL, - targetHeight = 3_090_939uL, - ) - val spoken = walletChildStatusDescription(input) - assertTrue(spoken, spoken.contains("sync 1160/3090939")) - assertTrue( - "a screen reader is told the same as the eye", - spoken.endsWith(walletChildLine(input)), - ) - assertTrue("it is still a sentence", spoken.startsWith("The wallet is starting")) - } - - @Test - fun start_is_blocked_when_the_build_has_no_in_process_daemon() { - val why = startBlockedReason( - bundled, - node(state = "off", nodeState = "off", nodeAvailable = false, running = false), - ) - assertEquals(CUPRATE_NOT_IN_BUILD_NOTICE, why) - assertNull( - "a build that carries the daemon is not blocked", - startBlockedReason( - bundled, - node(state = "off", nodeState = "off", nodeAvailable = true, running = false), - ), - ) - } - - @Test - fun the_on_device_banner_is_titled_and_says_what_it_costs() { - // The banner's title is the plan's exact string; the body keeps every - // honesty bound the old single-sentence warning carried. - assertEquals("Experimental On-Device Node (Cuprate)", CUPRATE_ON_DEVICE_TITLE) - val body = CUPRATE_ON_DEVICE_BODY - assertTrue("it names the software", body.contains("Cuprate")) - assertTrue("it names the parity gap", body.contains("#278")) - assertTrue("it quotes the user book", body.contains("do NOT use cuprated")) - assertTrue("it says mainnet is unvalidated", body.contains("Mainnet is unvalidated")) - assertTrue("it says not to hold funds", body.contains("Do not use for significant funds")) - assertTrue("it is a sentence, not a glyph", body.trim().endsWith(".")) - } - - // --- storage honesty ---------------------------------------------------- - - @Test - fun storage_is_blocked_when_free_space_is_unreadable() { - assertTrue(chainStorageBlockedReason(null)!!.contains("could not be read")) - } - - @Test - fun storage_is_blocked_below_the_floor() { - val why = chainStorageBlockedReason(CHAIN_FREE_SPACE_FLOOR_BYTES - 1) - assertNotNull(why) - assertTrue(why!!, why.contains("Not enough space")) - assertTrue("the number is on screen", why.contains("3.0 GiB")) - } - - @Test - fun storage_is_allowed_at_and_above_the_floor() { - assertNull(chainStorageBlockedReason(CHAIN_FREE_SPACE_FLOOR_BYTES)) - assertNull(chainStorageBlockedReason(64L * 1024 * 1024 * 1024)) - } - - @Test - fun mainnet_pruned_needs_more_than_testnet() { - val forty = 40L * 1024 * 1024 * 1024 - assertNull(chainStorageBlockedReason(forty, mainnet = false, prune = false)) - val why = chainStorageBlockedReason(forty, mainnet = true, prune = true) - assertNotNull(why) - assertTrue(why!!, why.contains("64.0 GiB")) - assertNull( - chainStorageBlockedReason( - CHAIN_MAINNET_PRUNED_FLOOR_BYTES, - mainnet = true, - prune = true, - ), - ) - } - - @Test - fun mainnet_full_needs_more_than_pruned() { - val why = chainStorageBlockedReason( - CHAIN_MAINNET_PRUNED_FLOOR_BYTES, - mainnet = true, - prune = false, - ) - assertNotNull(why) - assertTrue(why!!, why.contains("280.0 GiB")) - } - - @Test - fun selecting_pruned_highlights_that_mode() { - assertEquals( - CuprateMode.MainnetPruned, - selectedCuprateMode(inProcess = true, mainnet = true, prune = true), - ) - assertEquals( - CuprateMode.MainnetFull, - selectedCuprateMode(inProcess = true, mainnet = true, prune = false), - ) - assertEquals( - CuprateMode.Testnet, - selectedCuprateMode(inProcess = true, mainnet = false, prune = false), - ) - assertNull(selectedCuprateMode(inProcess = false, mainnet = true, prune = true)) - } - - @Test - fun selecting_a_mode_starts_unless_storage_or_an_in_flight_start_blocks_it() { - assertTrue(shouldStartAfterSelectingChain(storageBlocked = null, starting = false)) - assertFalse( - shouldStartAfterSelectingChain(storageBlocked = "Not enough space", starting = false), - ) - assertFalse(shouldStartAfterSelectingChain(storageBlocked = null, starting = true)) - } - - @Test - fun the_storage_line_reports_the_measured_number() { - val line = chainStorageLine(41L * 1024 * 1024 * 1024) - assertTrue(line, line.contains("41.0 GiB")) - assertTrue("it says what the number is not", line.contains("no size estimate")) - assertTrue( - "an unreadable filesystem says so", - chainStorageLine(null).contains("could not be read"), - ) - } - - @Test - fun bytes_are_formatted_in_binary_units() { - assertEquals("512 B", formatBytes(512)) - assertEquals("2 MiB", formatBytes(2L * 1024 * 1024)) - assertEquals("1.5 GiB", formatBytes(3L * 1024 * 1024 * 1024 / 2)) - assertEquals("3.0 GiB", formatBytes(CHAIN_FREE_SPACE_FLOOR_BYTES)) - } - - // --- the node card's progress header (plan P4.3) ------------------------- - - @Test - fun block_counts_group_by_three_regardless_of_locale() { - assertEquals("0", formatBlockCount(0uL)) - assertEquals("999", formatBlockCount(999uL)) - assertEquals("1,000", formatBlockCount(1_000uL)) - assertEquals("485,253", formatBlockCount(485_253uL)) - assertEquals("3,794,383", formatBlockCount(3_794_383uL)) - assertEquals("12,345,678", formatBlockCount(12_345_678uL)) - } - - @Test - fun the_progress_header_says_percent_and_formatted_blocks() { - val p = syncProgress(485_253uL, 3_794_383uL) - assertEquals("12.8%", p.percentText) - assertEquals("Block 485,253 of 3,794,383", p.blockText) - assertTrue("a fraction of the track", p.fraction > 0.12f && p.fraction < 0.13f) - } - - @Test - fun a_caught_up_node_fills_the_track_and_does_not_overflow() { - val atTip = syncProgress(3_794_383uL, 3_794_383uL) - assertEquals("100.0%", atTip.percentText) - assertEquals(1f, atTip.fraction) - // A daemon one block ahead of the target it reported must not render - // 108% — the bar clamps and the text is the clamped number. - val ahead = syncProgress(4_100_000uL, 3_794_383uL) - assertEquals("100.0%", ahead.percentText) - assertEquals(1f, ahead.fraction) - } - - @Test - fun an_unknown_target_is_never_a_percentage() { - // `target_height == 0` is "the daemon reported no target" — Cuprate - // omits it even at the tip. Printing 100% there would claim synced. - val p = syncProgress(4_549uL, 0uL) - assertNull("no percent from a zero target", p.percentText) - assertEquals(0f, p.fraction) - assertEquals("Block 4,549 of an unknown target", p.blockText) - assertFalse("no percent string leaks", p.blockText!!.contains("%")) - } - - @Test - fun no_numbers_means_no_progress_row() { - val p = syncProgress(0uL, 0uL) - assertNull(p.percentText) - assertNull(p.blockText) - assertEquals(0f, p.fraction) - } - - @Test - fun the_three_modes_are_named_the_way_the_stored_choice_reads() { - assertEquals("Mainnet Pruned", chainModeLabel(mainnet = true, prune = true)) - assertEquals("Mainnet Full", chainModeLabel(mainnet = true, prune = false)) - assertEquals("Testnet", chainModeLabel(mainnet = false, prune = false)) - } - - @Test - fun the_node_header_never_reads_ready_without_the_cores_word() { - assertEquals("Wallet Offline", nodeStatusHead(input("off", configured = false)).title) - assertEquals("Connecting…", nodeStatusHead(input("connecting", running = true)).title) - assertEquals(NodeStatusTone.Busy, nodeStatusHead(input("connecting", running = true)).tone) - assertTrue( - "a running child that has not answered is not ready", - nodeStatusHead(input("connecting", running = true)).tone != NodeStatusTone.Good, - ) - assertEquals(NodeStatusTone.Good, nodeStatusHead(input("ready", running = true)).tone) - assertEquals(NodeStatusTone.Bad, nodeStatusHead(input("mining", running = true)).tone) - assertEquals( - "an unknown state is never green", - NodeStatusTone.Bad, - nodeStatusHead(input("mining", running = true)).tone, - ) - assertEquals("Wallet Stopped", nodeStatusHead(input("exited")).title) - assertEquals("Reading wallet status", nodeStatusHead(null).title) - } - - @Test - fun the_node_header_names_the_mode_only_for_the_on_device_node() { - assertEquals( - "Syncing Node (Mainnet Pruned)", - nodeStatusHead( - node(state = "syncing", chainSource = "in-process mainnet pruned", nodeState = "syncing"), - inProcess = true, - mainnet = true, - prune = true, - ).title, - ) - assertEquals( - "Node Idle (Testnet)", - nodeStatusHead(input("off", configured = false), inProcess = true, mainnet = false).title, - ) - assertEquals( - "Syncing Wallet", - nodeStatusHead(input("syncing", running = true, chainSource = "remote daemon")).title, - ) - } - - // --- the stored wallet binary: heal before spawn, then gate on it ------- - - private val hostsBundled = "/data/app/~~abc/onionwire-1/lib/arm64/libmonerowalletrpc.so" - - @Test - fun a_stored_bare_name_is_repaired_to_the_bundled_absolute_path() { - // A record written by an older install: a bare name nothing in an APK - // sandbox resolves on PATH. The repair is the absolute path this - // install actually carries. - assertEquals(hostsBundled, walletBinHealPath("monero-wallet-rpc", hostsBundled) { false }) - assertEquals("an empty stored bin is healed too", hostsBundled, walletBinHealPath("", hostsBundled) { false }) - assertEquals("and a missing field", hostsBundled, walletBinHealPath(null, hostsBundled) { false }) - } - - @Test - fun a_stored_path_that_actually_runs_is_never_overwritten() { - val userBin = "/data/user/0/com.siriusdevops.onionwire/files/monero-wallet-rpc" - assertNull( - "a real executable file the user pointed at is left alone", - walletBinHealPath(userBin, hostsBundled) { it == userBin }, - ) - assertNull( - "a bundled path already stored needs no write", - walletBinHealPath(hostsBundled, hostsBundled) { it == hostsBundled }, - ) - } - - @Test - fun no_bundled_binary_means_there_is_nothing_to_repair_with() { - assertNull(walletBinHealPath("monero-wallet-rpc", null) { false }) - assertNull(walletBinHealPath("monero-wallet-rpc", " ") { false }) - } - - @Test - fun a_stored_bin_missing_on_the_device_blocks_start_and_names_the_path() { - val why = startGateReason(bundled, input("off"), "monero-wallet-rpc") { false } - assertNotNull("a stored path that cannot run must block Start", why) - assertTrue("the reason names the stored path it is about", why!!.contains("monero-wallet-rpc")) - assertTrue("and the path this build does carry", why.contains(bundled.walletRpc!!)) - assertTrue("and says it cannot run", why.contains("cannot be run")) - assertFalse( - "a gate that refuses never lets a mode tap auto-start", - shouldStartAfterSelectingChain(storageBlocked = null, starting = false, startBlocked = why), - ) - } - - @Test - fun an_absent_resolved_bin_blocks_with_the_resolved_absence_message() { - // Nothing in this build to spawn: the established string, unchanged. - val why = startGateReason(noBinary, input("off"), "/stale/libmonerowalletrpc.so") { false } - assertEquals(NO_WALLET_RPC_MESSAGE, why) - assertFalse(shouldStartAfterSelectingChain(null, false, why)) - } - - @Test - fun a_runnable_stored_bin_passes_the_gate() { - assertNull(startGateReason(bundled, input("off"), bundled.walletRpc) { it == bundled.walletRpc }) - assertNull(storedWalletBinBlockedReason(bundled.walletRpc, bundled.walletRpc) { true }) - } - - @Test - fun the_gate_keeps_the_established_start_ordering() { - // Reading the status still wins over a stored-path complaint: the - // existing copy and its order were not rewritten to make room. - assertEquals(READING_CHILD_NOTICE, startGateReason(bundled, null, null) { false }) - assertEquals( - NO_CHAIN_SOURCE_NOTICE, - startGateReason(bundled, input("off", configured = false, chainSource = "receive-only"), null) { false }, - ) - } - - @Test - fun a_mode_tap_stores_the_source_but_cannot_auto_start_what_the_gate_refuses() { - assertTrue(shouldStartAfterSelectingChain(storageBlocked = null, starting = false)) - assertTrue( - shouldStartAfterSelectingChain(storageBlocked = null, starting = false, startBlocked = null), - ) - assertFalse( - shouldStartAfterSelectingChain( - storageBlocked = null, - starting = false, - startBlocked = "The stored wallet binary cannot be run on this device: …", - ), - ) - } - - @Test - fun create_and_import_are_blocked_without_a_running_child() { - assertEquals(WALLET_SETUP_NEEDS_CHILD, walletSetupBlockedReason(input("off"))) - assertEquals(WALLET_SETUP_NEEDS_CHILD, walletSetupBlockedReason(input("exited", lastError = "spawn …"))) - assertEquals(WALLET_SETUP_NEEDS_CHILD, walletSetupBlockedReason(input("mining"))) - assertEquals(WALLET_SETUP_STARTING, walletSetupBlockedReason(input("connecting", running = true))) - assertEquals(READING_CHILD_NOTICE, walletSetupBlockedReason(null)) - assertNull( - "a syncing wallet answers RPC, so a create is fine", - walletSetupBlockedReason(input("syncing", running = true)), - ) - assertNull(walletSetupBlockedReason(input("ready", running = true))) - } - - // --- the no-wallet-open state is information, not a failure ------------ - - @Test - fun the_no_wallet_open_state_is_information_never_the_red_failure() { - // The `No wallet open` info banner owns this sentence; printing it a - // second time in red is the duplicate the device report caught. - assertNull( - "already said once by the info banner above", - walletFailureBanner(WALLET_NOT_OPEN_TEXT, openHintVisible = true, walletOpen = false), - ) - val alone = walletFailureBanner(WALLET_NOT_OPEN_TEXT, openHintVisible = false, walletOpen = false) - assertNotNull(alone) - assertEquals(WalletFailureTone.Info, alone!!.tone) - assertEquals("No wallet open", alone.title) - assertEquals(WALLET_NOT_OPEN_TEXT, alone.text) - assertNull( - "the state ended when a wallet was opened", - walletFailureBanner(WALLET_NOT_OPEN_TEXT, openHintVisible = false, walletOpen = true), - ) - } - - @Test - fun a_real_failure_still_paints_red() { - val refused = walletFailureText("wallet connect: Connection refused (os error 111)")!! - val banner = walletFailureBanner(refused, openHintVisible = true, walletOpen = false)!! - assertEquals("a refusal is still a failure", WalletFailureTone.Error, banner.tone) - assertEquals("Wallet error", banner.title) - assertEquals(refused, banner.text) - - val exited = walletFailureText("spawn monero-wallet-rpc: No such file or directory (os error 2)")!! - assertEquals(WalletFailureTone.Error, walletFailureBanner(exited, false, false)!!.tone) - - assertNull(walletFailureBanner(null, true, false)) - assertNull(walletFailureBanner(" ", true, false)) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletManagerTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletManagerTest.kt deleted file mode 100644 index aab4313..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletManagerTest.kt +++ /dev/null @@ -1,503 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNull -import org.junit.Assert.assertTrue -import org.junit.Test -import uniffi.onionwire_sdk.WalletChildStatus - -/** - * The saved-wallets screen's rules, on the JVM. - * - * These are the decisions the screen renders from: what a catalogue row is - * called, whether the child has a wallet open at all, and whether the two - * secret actions may be offered for a given row. Pure logic, so no Robolectric - * and no Compose test dependency — same shape as `SeedBackupGateTest` and - * `WalletChildStatusTextTest`. - */ -class WalletManagerTest { - - private val openFile = "onionwire-main" - private val otherFile = "onionwire-second" - - /** The core's `wallet_status().state` for a child that answered. */ - private val readable = true - - /** No child, or one whose wallet RPC has not answered. */ - private val notReadable = false - - // --- what a row is called ----------------------------------------------- - - @Test - fun a_named_wallet_is_labelled_with_its_name() { - assertEquals("spending", walletRowLabel("spending", openFile)) - } - - @Test - fun an_unnamed_wallet_falls_back_to_its_file_name() { - assertEquals(openFile, walletRowLabel(null, openFile)) - } - - @Test - fun a_blank_name_counts_as_absent() { - // `WalletRow.name` is documented as never an empty string, but a - // whitespace label is a row the user cannot identify either way. - assertEquals(openFile, walletRowLabel("", openFile)) - assertEquals(openFile, walletRowLabel(" ", openFile)) - } - - @Test - fun a_name_is_not_trimmed_out_of_the_label() { - // Only the *blank* case falls back. A name with padding is still the - // user's name and is shown as stored. - assertEquals(" spending ", walletRowLabel(" spending ", openFile)) - } - - // --- is the child reading a wallet at all -------------------------------- - - @Test - fun only_an_answered_wallet_rpc_counts_as_readable() { - // `connecting` is "the RPC has not answered"; `off` and `exited` are - // "there is no child". None of them can answer a key query. - assertTrue(walletChildReadable("ready")) - assertTrue(walletChildReadable("syncing")) - assertFalse(walletChildReadable("connecting")) - assertFalse(walletChildReadable("off")) - assertFalse(walletChildReadable("exited")) - } - - @Test - fun nothing_read_yet_is_not_readable() { - assertFalse(walletChildReadable(null)) - } - - @Test - fun a_behind_chain_still_counts_as_readable() { - // Syncing means the RPC answered: the wallet's keys do not need the - // chain to be caught up. - assertTrue(walletChildReadable("syncing")) - } - - // --- whether the secret actions are offered ------------------------------ - - @Test - fun the_open_wallets_secrets_are_offered() { - assertTrue(walletSecretsEnabled(openFile, openFile, readable)) - } - - @Test - fun another_wallets_secrets_are_not_offered() { - // The seed and the keys come from the file the child has open. A row - // that is not the open one must not read as its own backup. - assertFalse(walletSecretsEnabled(openFile, otherFile, readable)) - } - - @Test - fun nothing_open_means_no_secrets_for_any_row() { - assertFalse(walletSecretsEnabled(null, openFile, readable)) - } - - @Test - fun the_open_wallet_offers_no_secrets_while_the_child_is_not_reading_it() { - // Active but no answer: `wallet_seed()` / `wallet_keys()` can only - // fail, so the buttons stay dead rather than always erroring. - assertFalse(walletSecretsEnabled(openFile, openFile, notReadable)) - assertFalse(walletSecretsEnabled(openFile, otherFile, notReadable)) - assertFalse(walletSecretsEnabled(null, openFile, notReadable)) - } - - // --- and why they are off, in words -------------------------------------- - - @Test - fun an_enabled_row_has_nothing_to_explain() { - assertNull(walletSecretsBlockedReason(isActive = true, walletReadable = readable)) - } - - @Test - fun a_row_that_is_not_open_says_to_open_it() { - val why = walletSecretsBlockedReason(isActive = false, walletReadable = readable) - assertEquals("Open this wallet to view its backup.", why) - } - - @Test - fun an_open_wallet_with_no_child_says_the_child_is_not_running() { - val why = walletSecretsBlockedReason(isActive = true, walletReadable = notReadable) - assertTrue(why != null && why.contains("not running")) - // The two reasons are different fixes and must not read alike. - assertFalse(why == walletSecretsBlockedReason(isActive = false, walletReadable = readable)) - } - - // --- the created-at column ---------------------------------------------- - - @Test - fun a_stored_created_at_renders_as_a_date() { - // 2021-01-01T00:00:00Z. - val rendered = walletRowDate(1609459200L) - assertTrue("got '$rendered'", Regex("""\d{4}-\d{2}-\d{2}""").matches(rendered)) - } - - @Test - fun a_later_created_at_sorts_after_an_earlier_one() { - // The store hands the rows back oldest-first; the rendered date must - // not invert that order in the list. - assertTrue(walletRowDate(1700000000L) > walletRowDate(1609459200L)) - } - - @Test - fun a_row_with_no_assigned_created_at_says_so() { - // The store assigns `created_at` on insert, so 0 is a row that predates - // that — not 1970, and not "today". - assertEquals("date unknown", walletRowDate(0L)) - assertEquals("date unknown", walletRowDate(-1L)) - } - - // --- a wallet this install holds no passphrase for ----------------------- - // - // `needs_passphrase` is the core's own word for "a saved wallet is - // configured and nothing here opens it" — the pre-parent-change wallet. The - // prompt is the only way it becomes openable, so the decision to show it is - // asserted here rather than in a Compose test. - - @Test - fun a_wallet_with_no_stored_passphrase_asks_for_one() { - assertTrue(walletPassphrasePromptVisible(needsPassphrase = true, walletOpen = false)) - } - - @Test - fun an_open_wallet_is_never_asked_for_its_passphrase() { - assertFalse(walletPassphrasePromptVisible(needsPassphrase = false, walletOpen = true)) - } - - @Test - fun an_open_wallet_wins_over_a_stale_needs_passphrase_flag() { - // One `WalletChildStatus` carries both, and "there is a wallet open" is - // the stronger statement: asking for a passphrase the child has already - // used would look like the open failed. - assertFalse(walletPassphrasePromptVisible(needsPassphrase = true, walletOpen = true)) - } - - @Test - fun a_child_with_nothing_to_open_asks_for_nothing() { - // No child, or one never pointed at a file: there is no passphrase to - // ask for yet, and the list below is what the user acts on. - assertFalse(walletPassphrasePromptVisible(needsPassphrase = false, walletOpen = false)) - } - - @Test - fun the_prompt_can_be_submitted_once_a_file_and_a_passphrase_are_known() { - assertTrue( - walletPassphraseSubmitEnabled(activeFilename = openFile, typed = "pw", inFlight = false), - ) - } - - @Test - fun a_blank_passphrase_leaves_submit_dead() { - assertFalse( - walletPassphraseSubmitEnabled(activeFilename = openFile, typed = "", inFlight = false), - ) - } - - @Test - fun submit_is_dead_while_an_open_is_in_flight() { - // Re-submitting restarts the wallet child: one open at a time. - assertFalse( - walletPassphraseSubmitEnabled(activeFilename = openFile, typed = "pw", inFlight = true), - ) - } - - @Test - fun no_pointed_at_file_means_submit_is_dead_and_says_why() { - assertFalse( - walletPassphraseSubmitEnabled(activeFilename = null, typed = "pw", inFlight = false), - ) - val why = walletPassphraseBlockedReason(activeFilename = null, typed = "pw") - assertTrue("got '$why'", why != null && why.contains("No wallet file is open yet")) - // The two reasons are different fixes and must not read alike. - assertFalse(why == walletPassphraseBlockedReason(activeFilename = openFile, typed = "")) - } - - @Test - fun a_typed_passphrase_with_a_file_has_nothing_to_explain() { - assertNull(walletPassphraseBlockedReason(activeFilename = openFile, typed = "pw")) - } - - @Test - fun nothing_typed_is_the_other_reason() { - val why = walletPassphraseBlockedReason(activeFilename = openFile, typed = "") - assertTrue("got '$why'", why != null && why.contains("Type the passphrase")) - } - - // --- the daemon's own words never reach the screen ----------------------- - - /** The three things a user must never be shown, in one place. */ - private fun assertNoRawRpc(text: String) { - assertFalse("raw RPC code on screen: $text", text.contains("-13")) - assertFalse("daemon phrase on screen: $text", text.contains("No wallet file")) - assertFalse("JSON on screen: $text", text.contains("{")) - assertFalse("JSON on screen: $text", text.contains("\"error\"")) - } - - @Test - fun the_daemons_no_wallet_file_never_reaches_the_screen() { - // What actually arrives: `parse_json_rpc` keeps `error.message` and - // drops the envelope, so the bare sentence is the common case. - val shown = walletFailureText("No wallet file") - assertEquals(WALLET_NOT_OPEN_TEXT, shown) - assertNoRawRpc(shown!!) - } - - @Test - fun a_bare_rpc_code_never_reaches_the_screen() { - val shown = walletFailureText("wallet rpc error -13") - assertEquals(WALLET_NOT_OPEN_TEXT, shown) - assertNoRawRpc(shown!!) - } - - @Test - fun a_raw_json_answer_never_reaches_the_screen() { - val raw = """{"error": {"code": -13, "message": "No wallet file"}}""" - val shown = walletFailureText(raw) - assertNoRawRpc(shown!!) - // The envelope is replaced, and because this one *is* the no-wallet-file - // answer the user gets the actionable text rather than the generic one. - assertEquals(WALLET_NOT_OPEN_TEXT, shown) - } - - @Test - fun a_json_answer_is_replaced_even_when_it_names_another_code() { - val shown = walletFailureText("""{"error":{"code":-1,"message":"busy"}}""") - assertEquals(WALLET_DAEMON_REFUSED_TEXT, shown) - assertNoRawRpc(shown!!) - } - - @Test - fun a_wrapped_daemon_phrase_is_still_replaced() { - // The core's open path prefixes the RPC's own message, and the prefix - // is no excuse to hand the daemon's words to the user. - val shown = walletFailureText( - "wallet file onionwire-1 is not open — the RPC refused its passphrase (No wallet file)", - ) - assertEquals(WALLET_NOT_OPEN_TEXT, shown) - assertNoRawRpc(shown!!) - } - - @Test - fun the_core_own_refusals_are_passed_through() { - // These are written for a person, carry no secret, and are the whole - // point of the message — replacing them would hide the reason. - val refusal = "no saved wallet in onionwire-9" - assertEquals(refusal, walletFailureText(refusal)) - val stopped = "node stopped: wallet_keys called on a shut-down node" - assertEquals(stopped, walletFailureText(stopped)) - } - - @Test - fun a_number_that_merely_starts_with_minus_thirteen_is_not_a_code() { - assertEquals("offset -135", walletFailureText("offset -135")) - assertEquals("height -1300", walletFailureText("height -1300")) - } - - @Test - fun nothing_to_show_is_null() { - assertNull(walletFailureText(null)) - assertNull(walletFailureText("")) - assertNull(walletFailureText(" ")) - } - - @Test - fun the_replacement_texts_carry_no_raw_rpc_of_their_own() { - assertNoRawRpc(WALLET_NOT_OPEN_TEXT) - assertNoRawRpc(WALLET_DAEMON_REFUSED_TEXT) - } - - // --- a connect refusal while the child is coming up ----------------------- - - @Test - fun connecting_connect_refusal_is_not_shown() { - // The Rust half stops storing this string in the first place; this is - // the display seam's own belt: a probe that dialled a port the child - // has not bound yet says nothing about whether the wallet is broken. - val raw = "wallet connect: Connection refused (os error 111)" - assertNull(displayLastError("connecting", raw)) - assertNull(displayLastError(" connecting ", "wallet write: Connection reset")) - } - - @Test - fun a_connect_refusal_after_connecting_is_still_shown() { - // Past `connecting` the same string means the child accepted a - // connection once and then died. Hiding that would hide a real failure. - val raw = "wallet connect: Connection refused (os error 111)" - assertEquals(raw, displayLastError("exited", raw)) - assertEquals(raw, displayLastError("syncing", raw)) - assertEquals(raw, displayLastError("off", raw)) - } - - @Test - fun display_last_error_still_rewrites_no_wallet_file() { - assertEquals(WALLET_NOT_OPEN_TEXT, displayLastError("connecting", "No wallet file")) - assertEquals(WALLET_NOT_OPEN_TEXT, displayLastError("syncing", "wallet rpc error -13")) - } - - // --- "there is no wallet open", on the wallet screen --------------------- - - @Test - fun a_live_child_with_no_wallet_says_what_to_do() { - val hint = walletChildOpenHint( - childRunning = true, - walletOpen = false, - needsPassphrase = false, - ) - // The §4.1 replacement copy, verbatim: a live wallet with no file open - // is a state, not an error. - assertEquals( - "Select a saved wallet or create a new one to view your balance and transact.", - hint, - ) - assertNoRawRpc(hint!!) - } - - @Test - fun a_child_that_needs_a_passphrase_says_where_the_prompt_is() { - val hint = walletChildOpenHint( - childRunning = true, - walletOpen = false, - needsPassphrase = true, - ) - assertTrue("got '$hint'", hint != null && hint.contains("Saved wallets")) - assertNoRawRpc(hint!!) - } - - @Test - fun an_open_wallet_has_no_hint() { - assertNull(walletChildOpenHint(childRunning = true, walletOpen = true, needsPassphrase = false)) - // An open wallet wins over a stale flag, same as the prompt. - assertNull(walletChildOpenHint(childRunning = true, walletOpen = true, needsPassphrase = true)) - } - - @Test - fun no_running_child_has_no_hint() { - // The status line already says off/exited and Start is right there. - assertNull(walletChildOpenHint(childRunning = false, walletOpen = false, needsPassphrase = true)) - } - - // --- the status line itself, from the record the screen renders ----------- - - /** - * The child's record as the SDK hands it over, for the state this card - * exists for: a live `connecting` child pointed at a wallet file this - * install holds no passphrase for. Its probe answers `-13 No wallet file` - * and `parse_json_rpc` keeps only `error.message`, so the bare sentence is - * what the core reports as `last_error`. - */ - private fun sdkStatus( - state: String = "connecting", - running: Boolean = true, - walletOpen: Boolean = false, - needsPassphrase: Boolean = true, - lastError: String? = "No wallet file", - ) = WalletChildStatus( - state = state, - running = running, - walletOpen = walletOpen, - needsPassphrase = needsPassphrase, - configured = true, - chainSource = "remote daemon", - chainInProcess = false, - nodeAvailable = false, - nodeState = "", - height = 0uL, - targetHeight = 0uL, - lastError = lastError, - ) - - @Test - fun the_status_line_never_renders_the_daemons_own_words() { - // The render path, not the filter in isolation: the SDK record the - // poller lands is what the status line is drawn from, and the same - // field feeds the screen-reader sentence. - assertNoRawRpc(walletChildLine(sdkStatus().toInput())) - assertNoRawRpc(walletChildStatusDescription(sdkStatus().toInput())) - } - - @Test - fun a_raw_rpc_envelope_on_the_status_line_is_replaced_too() { - // A failure that never reached the parser arrives as the envelope. - val raw = """{"error": {"code": -13, "message": "No wallet file"}}""" - assertNoRawRpc(walletChildLine(sdkStatus(lastError = raw).toInput())) - } - - @Test - fun the_status_line_still_says_the_state_and_the_source() { - // Filtering the trailing text must not cost the line its own words. - val line = walletChildLine(sdkStatus().toInput()) - assertTrue("got '$line'", line.startsWith("connecting · remote daemon")) - } - - @Test - fun an_open_wallet_has_nothing_left_to_filter() { - val line = walletChildLine( - sdkStatus(state = "ready", walletOpen = true, needsPassphrase = false, lastError = null) - .toInput(), - ) - assertEquals("ready · remote daemon", line) - } - - @Test - fun the_cores_own_reason_for_a_dead_child_still_reaches_the_line() { - // The other side of the same seam: a reason written for a person is - // passed through, so the filter is not a mute button. - val line = walletChildLine( - sdkStatus(state = "exited", running = false, needsPassphrase = false, - lastError = "spawn monero-wallet-rpc: No such file").toInput(), - ) - assertTrue("got '$line'", line.contains("No such file")) - assertNoRawRpc(line) - } - - @Test - fun filtering_the_sdk_record_twice_changes_nothing() { - // The sticky error card runs the same filter over the same field, so - // the replacement must survive a second pass unchanged. - val once = sdkStatus().toInput().lastError - assertEquals(WALLET_NOT_OPEN_TEXT, once) - assertEquals(once, walletFailureText(once)) - } - - @Test - fun wallet_reads_reload_only_once_the_child_is_answering() { - // `walletBalance()` answers `"err"` — it does not throw — while the - // child is still dialling, so reloading in that window is what pins the - // headline on `Balance unavailable`. Reload only when the child has answered. - assertFalse(shouldReloadWalletReads(null)) - assertFalse(shouldReloadWalletReads("off")) - assertFalse(shouldReloadWalletReads("connecting")) - assertFalse(shouldReloadWalletReads("exited")) - assertTrue(shouldReloadWalletReads("syncing")) - assertTrue(shouldReloadWalletReads("ready")) - assertTrue(shouldReloadWalletReads(" Ready ")) - } - - @Test - fun the_tui_not_configured_copy_is_mapped_and_never_rendered_verbatim() { - // `src/wallet.rs::NOT_CONFIGURED_MSG` is the desktop TUI's refusal. A - // phone has no F7 key and no ONIONWIRE_WALLET_RPC, so that sentence is - // the second dead end the device report caught: a passphrase was typed - // into Create, and the screen answered with a keyboard shortcut. - val tui = "wallet not configured — open F7 to set it up, or set ONIONWIRE_WALLET_RPC" - val shown = walletFailureText(tui) - assertEquals(WALLET_RPC_NOT_RUNNING_TEXT, shown) - assertFalse("no F7 reaches the screen", shown!!.contains("F7")) - assertFalse("no env var name either", shown.contains("ONIONWIRE_WALLET_RPC")) - assertTrue("the phone sentence says what to do", shown.contains("Start it on the node card")) - - // Each fragment alone is the same fact and is mapped too; case and - // spacing are not load-bearing. - assertEquals(WALLET_RPC_NOT_RUNNING_TEXT, walletFailureText("Open F7")) - assertEquals(WALLET_RPC_NOT_RUNNING_TEXT, walletFailureText("Wallet Not Configured")) - assertEquals(WALLET_RPC_NOT_RUNNING_TEXT, walletFailureText("set ONIONWIRE_WALLET_RPC")) - - // And it is idempotent: the sticky error card re-filters its own text. - assertEquals(WALLET_RPC_NOT_RUNNING_TEXT, walletFailureText(shown)) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/components/IdenticonTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/components/IdenticonTest.kt deleted file mode 100644 index 38d6424..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/components/IdenticonTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * The identicon is a rendering of the identity fingerprint, so it has to be a - * function of that value and nothing else: same fingerprint, same picture, on - * every device and every launch. Pure (a list of cells), no Compose runtime. - */ -class IdenticonTest { - - private val fingerprint = - "9f2c41ab77de03b5c8e1f0a6d4b39c2e5a7f81c0d3e6b492af17c5d80e3b6a49" - - @Test - fun the_same_seed_always_produces_the_same_cells() { - assertEquals(identiconCells(fingerprint), identiconCells(fingerprint)) - } - - @Test - fun the_picture_is_mirrored_about_the_middle_column() { - val cells = identiconCells(fingerprint) - val columns = cells.map { it.first } - cells.forEach { (col, row, tone) -> - assertTrue( - "column $col row $row is not mirrored", - cells.any { it.first == 4 - col && it.second == row && it.third == tone }, - ) - } - assertTrue(columns.all { it in 0..4 }) - } - - @Test - fun a_different_seed_produces_a_different_picture() { - val other = fingerprint.reversed() - assertTrue(identiconCells(fingerprint) != identiconCells(other)) - } - - @Test - fun an_empty_seed_draws_nothing() { - assertEquals(emptyList>(), identiconCells("")) - } -} diff --git a/android/build.gradle.kts b/android/build.gradle.kts deleted file mode 100644 index 81f6a88..0000000 --- a/android/build.gradle.kts +++ /dev/null @@ -1,6 +0,0 @@ -plugins { - alias(libs.plugins.android.application) apply false - alias(libs.plugins.android.library) apply false - alias(libs.plugins.kotlin.android) apply false - alias(libs.plugins.kotlin.compose) apply false -} diff --git a/android/gradle.properties b/android/gradle.properties deleted file mode 100644 index 6338213..0000000 --- a/android/gradle.properties +++ /dev/null @@ -1,12 +0,0 @@ -# Gradle -org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8 -org.gradle.parallel=true -org.gradle.caching=true -org.gradle.configuration-cache=false - -# Android -android.useAndroidX=true -android.nonTransitiveRClass=true - -# Kotlin -kotlin.code.style=official diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml deleted file mode 100644 index 6d44ff6..0000000 --- a/android/gradle/libs.versions.toml +++ /dev/null @@ -1,40 +0,0 @@ -[versions] -agp = "8.13.2" -kotlin = "2.2.21" -coreKtx = "1.17.0" -activityCompose = "1.12.4" -lifecycle = "2.9.4" -navigationCompose = "2.9.8" -composeBom = "2025.12.01" -jna = "5.19.1" -coroutines = "1.11.0" -junit = "4.13.2" -androidxTestJunit = "1.3.0" -androidxTestRunner = "1.7.0" -zxing = "3.5.3" - -[libraries] -androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" } -jna = { module = "net.java.dev.jna:jna", version.ref = "jna" } -junit = { module = "junit:junit", version.ref = "junit" } -androidx-test-ext-junit = { module = "androidx.test.ext:junit", version.ref = "androidxTestJunit" } -androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidxTestRunner" } -kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } -kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } -androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" } -androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" } -androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycle" } -androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" } -compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" } -compose-ui = { module = "androidx.compose.ui:ui" } -compose-ui-graphics = { module = "androidx.compose.ui:ui-graphics" } -compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } -compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } -compose-material3 = { module = "androidx.compose.material3:material3" } -zxing = { module = "com.google.zxing:core", version.ref = "zxing" } - -[plugins] -android-application = { id = "com.android.application", version.ref = "agp" } -android-library = { id = "com.android.library", version.ref = "agp" } -kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } -kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 1b33c55..0000000 Binary files a/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 4f5eb9d..0000000 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew deleted file mode 100755 index 23d15a9..0000000 --- a/android/gradlew +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH="\\\"\\\"" - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat deleted file mode 100644 index 5eed7ee..0000000 --- a/android/gradlew.bat +++ /dev/null @@ -1,94 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH= - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/android/monero-binaries.sha256 b/android/monero-binaries.sha256 deleted file mode 100644 index c3557f1..0000000 --- a/android/monero-binaries.sha256 +++ /dev/null @@ -1 +0,0 @@ -d9126788030ecd1ccdb40c7764e66e9a14d158a147ad335b256f0577681b5ad4 app/src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so diff --git a/android/sdk/build.gradle.kts b/android/sdk/build.gradle.kts deleted file mode 100644 index 87a0aa8..0000000 --- a/android/sdk/build.gradle.kts +++ /dev/null @@ -1,356 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - alias(libs.plugins.android.library) - alias(libs.plugins.kotlin.android) -} - -// --------------------------------------------------------------------------- -// Rust: build crates/onionwire-sdk for the requested Android ABIs and generate -// the UniFFI Kotlin bindings from the host cdylib. -// -// Nothing here touches the Linux TUI crate's feature graph: the SDK crate is -// its own Cargo workspace that selects Arti's rustls backend. -// --------------------------------------------------------------------------- - -val repoRoot: File = rootProject.projectDir.parentFile -val sdkCrateDir: File = repoRoot.resolve("crates/onionwire-sdk") - -/** NDK version used for the Rust link step. Must match an installed NDK. */ -val onionwireNdkVersion: String = (findProperty("onionwire.ndk") as String?) - ?: "28.2.13676358" - -/** Compile against this API level. Keep in sync with `minSdk`. */ -val onionwireApiLevel: Int = ((findProperty("onionwire.api") as String?) ?: "26").toInt() - -val androidSdkDir: File = sequenceOf( - System.getenv("ANDROID_HOME"), - System.getenv("ANDROID_SDK_ROOT"), -).filterNotNull().map(::File).firstOrNull() - ?: rootProject.file("local.properties") - .takeIf { it.exists() } - ?.readLines() - ?.firstOrNull { it.startsWith("sdk.dir=") } - ?.substringAfter('=') - ?.trim() - ?.let(::File) - ?: error("ANDROID_HOME / ANDROID_SDK_ROOT unset and no sdk.dir in android/local.properties") - -val ndkDir: File = androidSdkDir.resolve("ndk/$onionwireNdkVersion") -require(ndkDir.isDirectory) { - "NDK $onionwireNdkVersion not found at $ndkDir — run: sdkmanager --install \"ndk;$onionwireNdkVersion\"" -} - -val cargoExe: String = (findProperty("onionwire.cargo") as String?) - ?: System.getenv("CARGO") - ?: File(System.getProperty("user.home"), ".cargo/bin/cargo").takeIf { it.canExecute() }?.absolutePath - ?: "cargo" - -/** `-Ponionwire.abis=arm64-v8a,x86_64` to build more than one ABI. */ -val onionwireAbis: List = (findProperty("onionwire.abis") as String?) - ?.split(',')?.map(String::trim)?.filter(String::isNotEmpty) - ?: listOf("arm64-v8a") - -/** - * Rust features for the **Android** target build. - * - * `cuprate-daemon` is what puts the in-process Monero chain daemon (Cuprate) in - * the APK — the SDK crate's passthrough to the core - * (`cuprate-daemon = ["onionwire/cuprate-daemon"]`), so `WalletChildStatus.node_available` - * is `true` on the device and `ChainChoice.InProcessCuprate` can actually start. - * - * Deliberately **not** applied to `cargoHostLib` / `uniffiBindgen`: those build a - * host cdylib only so `uniffi-bindgen --library` can dlopen it, the cuprated graph - * (152 crates plus a C++ RandomX build) buys nothing there, and the UniFFI surface - * does not fork on a cargo feature. The Kotlin bindings are byte-identical either - * way, which is what `crates/onionwire-sdk`'s own tests cover. - */ -val onionwireRustFeatures: List = listOf("cuprate-daemon") - -/** `arm64-v8a` -> the Rust triple, the sysroot dir name and the builtins archive. */ -data class AndroidTarget( - val abi: String, - val triple: String, - /** Sysroot library dir under `.../sysroot/usr/lib/`. */ - val sysrootLib: String, - /** `libclang_rt.builtins-.a`, from the NDK clang resource dir. */ - val builtins: String, - /** NDK clang driver prefix: `-clang`. */ - val clangPrefix: String, -) - -val androidTargets: Map = listOf( - AndroidTarget("arm64-v8a", "aarch64-linux-android", "aarch64-linux-android", "aarch64-android", "aarch64-linux-android"), - AndroidTarget("x86_64", "x86_64-linux-android", "x86_64-linux-android", "x86_64-android", "x86_64-linux-android"), - AndroidTarget("armeabi-v7a", "armv7-linux-androideabi", "arm-linux-androideabi", "arm-android", "armv7a-linux-androideabi"), - AndroidTarget("x86", "i686-linux-android", "i686-linux-android", "i386-android", "i686-linux-android"), -).associateBy(AndroidTarget::abi) - -/** The NDK's host tag (`linux-x86_64`, `darwin-x86_64`, …) — exactly one prebuilt tree. */ -val ndkHostTag: String = ndkDir.resolve("toolchains/llvm/prebuilt").listFiles() - ?.filter(File::isDirectory)?.singleOrNull()?.name - ?: error("expected exactly one NDK prebuilt toolchain under $ndkDir/toolchains/llvm/prebuilt") - -/** The NDK clang resource dir (`lib/clang//lib/linux`) — exactly one version. */ -val ndkClangLibDir: File = ndkDir.resolve("toolchains/llvm/prebuilt/$ndkHostTag/lib/clang") - .listFiles()?.filter(File::isDirectory)?.singleOrNull() - ?.resolve("lib/linux") - ?: error("expected exactly one clang resource dir under $ndkDir/toolchains/llvm/prebuilt/$ndkHostTag/lib/clang") - -/** - * Per-ABI link flags for the Android build. - * - * RandomX is C++ and its aarch64 JIT calls `__clear_cache`, and `randomx-rs`'s - * build script emits `rustc-link-lib=static=stdc++` against the NDK's *stub* - * `libstdc++.a`. Without libc++ and the compiler-rt builtins on the link line the - * build dies on `__cxa_allocate_exception` / `std::runtime_error` / `typeinfo` - * (and `__clear_cache`) undefined. `cargo ndk --link-builtins` covers only the - * builtins, not libc++ — and `-static-libstdc++` is ignored by NDK clang — so the - * whole set is spelled out. Recipe and evidence: `docs/cuprate-android-spike.md`. - * - * Exported as `CARGO_TARGET__RUSTFLAGS` rather than `RUSTFLAGS`: a global - * rustflags would also apply to build scripts and proc macros, which are - * **host**-targeted, and `-lc++_static` there breaks the host link. - * - * The same variables also *replace* any `target..rustflags` in - * `~/.cargo/config.toml`, so the sysroot `-L` it carried is repeated here. - */ -fun linkFlags(target: AndroidTarget): String { - val sysrootLib = ndkDir.resolve("toolchains/llvm/prebuilt/$ndkHostTag/sysroot/usr/lib/${target.sysrootLib}") - // The *dynamic* libc/libm/libdl stubs live in a per-API subdirectory; the - // arch directory above holds the static `libc.a` and the libc++ archives. - // Both must be on the search path, and this one must come first: `-lc` - // resolves to whichever the linker finds first, and bionic linked - // statically into a shared object is a landmine — its `getauxval` reads an - // auxv vector only the dynamic linker fills in, so the first C++ static - // initializer that asks for it (RandomX's, from `cuprate-daemon`) null-derefs - // inside `dlopen` and takes the process with it. - val sysrootStubLib = sysrootLib.resolve(onionwireApiLevel.toString()) - require(sysrootStubLib.resolve("libc.so").isFile) { - "no dynamic libc stub at $sysrootStubLib/libc.so — NDK $onionwireNdkVersion layout changed? " + - "Linking the arch dir alone would pull in the static libc.a." - } - return listOf( - // Hygiene on a hand-written link line: lld defaults to --no-as-needed, - // which records a DT_NEEDED for every `-l` mentioned even when nothing - // is taken from it. (`libstdc++.so` survives this anyway — randomx-rs's - // cmake half asks for it and it satisfies symbols the static libc++ - // archives were already scanned for. That shim is present on every - // Android release to date; the device run in the PR loads it.) - "-C", "link-arg=-Wl,--as-needed", - "-C", "link-arg=-L$sysrootStubLib", - "-C", "link-arg=-L$sysrootLib", - "-C", "link-arg=-L$ndkClangLibDir", - "-C", "link-arg=-lclang_rt.builtins-${target.builtins}", - "-C", "link-arg=-lc++_static", - "-C", "link-arg=-lc++abi", - "-C", "link-arg=-Wl,--exclude-libs,libc++_static.a", - "-C", "link-arg=-Wl,--exclude-libs,libc++abi.a", - ).joinToString(" ") -} - -/** The NDK clang driver for one ABI at [onionwireApiLevel]. */ -private fun clangDriver(target: AndroidTarget): File = - ndkDir.resolve("toolchains/llvm/prebuilt/$ndkHostTag/bin/${target.clangPrefix}$onionwireApiLevel-clang") - -val jniLibsDir = layout.buildDirectory.dir("rustJniLibs") -val uniffiKotlinDir = layout.buildDirectory.dir("generated/uniffi") - -// cargo honors CARGO_TARGET_DIR when set (CI sibling container). UniFFI's -// --library path must match, or bindgen dies with ENOENT after a green compile. -val cargoTargetDir: File = System.getenv("CARGO_TARGET_DIR")?.let(::File) - ?: sdkCrateDir.resolve("target") -val hostCdylib: File = cargoTargetDir.resolve("release/libonionwire_sdk.so") - -/** - * Host cdylib. UniFFI's `--library` mode dlopens it, so it must be host-arch. - * - * Feature-free **on purpose**: this exists only to emit the Kotlin bindings, and - * `cuprate-daemon` would drag the whole Cuprate graph (152 crates + a C++ RandomX - * build) through a host compile that never runs the daemon. The UniFFI surface - * does not fork on a cargo feature — `ChainChoice.InProcessCuprate` is present in - * both — so the generated Kotlin is the same. `onionwireRustFeatures` is for - * [cargoBuildAndroid] only. - */ -val cargoHostLib by tasks.registering(Exec::class) { - group = "onionwire" - description = "Builds libonionwire_sdk.so for the host (used only to emit bindings)." - workingDir = sdkCrateDir - environment("ANDROID_HOME", androidSdkDir.absolutePath) - commandLine(cargoExe, "build", "--release", "--lib") -} - -val uniffiBindgen by tasks.registering(Exec::class) { - group = "onionwire" - description = "Generates the Kotlin UniFFI bindings into build/generated/uniffi." - dependsOn(cargoHostLib) - workingDir = sdkCrateDir - inputs.file(sdkCrateDir.resolve("src/lib.rs")) - outputs.dir(uniffiKotlinDir) - environment("ANDROID_HOME", androidSdkDir.absolutePath) - doFirst { uniffiKotlinDir.get().asFile.mkdirs() } - commandLine( - cargoExe, "run", "--release", "--bin", "uniffi-bindgen", "--", - "generate", - "--library", hostCdylib.absolutePath, - "--language", "kotlin", - "--no-format", - "--config", "uniffi.toml", - "--out-dir", uniffiKotlinDir.get().asFile.absolutePath, - ) -} - -val cargoBuildAndroid by tasks.registering(Exec::class) { - group = "onionwire" - description = "Cross-compiles crates/onionwire-sdk for ${onionwireAbis.joinToString()}." - workingDir = sdkCrateDir - inputs.dir(sdkCrateDir.resolve("src")) - inputs.file(sdkCrateDir.resolve("Cargo.toml")) - inputs.file(sdkCrateDir.resolve("Cargo.lock")) - inputs.dir(repoRoot.resolve("src")) - inputs.file(repoRoot.resolve("Cargo.toml")) - // The feature set is an input: `-Ponionwire.features=` … there is no knob - // (a build that silently dropped `cuprate-daemon` would ship an APK whose - // on-device node can only fail), but the task must not stay "up to date" - // across a change to this list. - inputs.property("rustFeatures", onionwireRustFeatures) - outputs.dir(jniLibsDir) - environment("ANDROID_HOME", androidSdkDir.absolutePath) - environment("ANDROID_NDK_HOME", ndkDir.absolutePath) - environment("NDK_HOME", ndkDir.absolutePath) - // `cmake-rs` (RandomX's C++ half) aborts with "Neither the NDK or a standalone - // toolchain was found" unless ANDROID_NDK itself is exported — NDK_HOME and - // ANDROID_NDK_HOME are not enough, and `randomx-rs`'s build script then panics - // inside `cmake`. - environment("ANDROID_NDK", ndkDir.absolutePath) - environment("ANDROID_NDK_ROOT", ndkDir.absolutePath) - // Per-ABI link env. The clang driver is named explicitly because - // `~/.cargo/config.toml` on the dev machines pins the *API 21* wrapper for - // `aarch64-linux-android`, and API 21 fails this link (`pthread_atfork` is - // API 23+); `cargo-ndk`'s own linker wrapper is bypassed on purpose so the - // `-Wl,…` args below reach clang as link args. - onionwireAbis.forEach { abi -> - val target = androidTargets[abi] - ?: error("no Android target mapping for ABI '$abi' — add it to androidTargets in sdk/build.gradle.kts") - val rustFlagsVar = "CARGO_TARGET_${target.triple.uppercase().replace('-', '_')}_RUSTFLAGS" - val linkerVar = "CARGO_TARGET_${target.triple.uppercase().replace('-', '_')}_LINKER" - val linker = clangDriver(target) - require(linker.canExecute()) { - "NDK clang driver for $abi not found at $linker — NDK $onionwireNdkVersion incomplete?" - } - environment(rustFlagsVar, linkFlags(target)) - environment(linkerVar, linker.absolutePath) - } - commandLine( - buildList { - add(cargoExe); add("ndk") - onionwireAbis.forEach { add("-t"); add(it) } - add("--platform"); add(onionwireApiLevel.toString()) - add("-o"); add(jniLibsDir.get().asFile.absolutePath) - add("build"); add("--release"); add("--lib") - if (onionwireRustFeatures.isNotEmpty()) { - add("--features"); add(onionwireRustFeatures.joinToString(",")) - } - } - ) - // The CI log has to show the feature actually requested, not merely the task - // name: "the feature is in the artifact" is checked against this line. - doFirst { - logger.lifecycle( - "cargo ndk build for ${onionwireAbis.joinToString()} " + - "features=${onionwireRustFeatures.joinToString(",").ifEmpty { "(none)" }} " + - "api=$onionwireApiLevel ndk=$onionwireNdkVersion", - ) - } -} - -// --------------------------------------------------------------------------- - -android { - namespace = "com.siriusdevops.onionwire.sdk" - compileSdk = 36 - ndkVersion = onionwireNdkVersion - - defaultConfig { - minSdk = onionwireApiLevel - consumerProguardFiles("consumer-rules.pro") - ndk { - abiFilters += onionwireAbis - } - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - - sourceSets["main"].jniLibs.srcDir(jniLibsDir) - sourceSets["main"].kotlin.srcDir(uniffiKotlinDir) - - buildTypes { - release { - isMinifyEnabled = false - } - } -} - -kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_17) - } -} - -dependencies { - // UniFFI's Kotlin backend talks to the Rust cdylib through JNA direct - // mapping, and the async bindings need coroutines. Both are part of the - // public API surface, so they are `api` — a consumer of the AAR needs them - // on its own compile classpath. JNA's `aar` variant is what carries - // libjnidispatch.so for each ABI. - api(variantOf(libs.jna) { artifactType("aar") }) - api(libs.kotlinx.coroutines.core) -} - -tasks.withType().configureEach { - dependsOn(uniffiBindgen) -} - -/** - * Fails the build if the SDK's shared object did not link bionic dynamically. - * - * `linkFlags()` spells the NDK search path out by hand, and `-L` order decides - * whether `-lc` resolves to the per-API `libc.so` stub or to the arch - * directory's `libc.a`. Static bionic inside a `.so` leaves `getauxval` reading - * an auxv vector only the dynamic linker fills in, so the first C++ static - * initializer that asks for CPU features null-derefs inside `dlopen` — a crash - * with no Java stack, at the first SDK call, on every ABI. Reading the built - * ELF is the only check that catches it before a device does. - */ -val verifyDynamicLibc by tasks.registering { - group = "verification" - description = "Asserts libonionwire_sdk.so links libc.so dynamically (no static bionic)." - dependsOn(cargoBuildAndroid) - val libsDir = jniLibsDir - val abis = onionwireAbis - val readelf = ndkDir.resolve("toolchains/llvm/prebuilt/$ndkHostTag/bin/llvm-readelf") - doLast { - abis.forEach { abi -> - val so = libsDir.get().asFile.resolve(abi).resolve("libonionwire_sdk.so") - check(so.isFile) { "no $so to verify — did cargoBuildAndroid run for $abi?" } - val proc = ProcessBuilder(readelf.absolutePath, "-d", so.absolutePath) - .redirectErrorStream(true) - .start() - val dump = proc.inputStream.bufferedReader().use { it.readText() } - check(proc.waitFor() == 0) { "$readelf failed on $so:\n$dump" } - check(dump.lineSequence().any { it.contains("(NEEDED)") && it.contains("libc.so") }) { - "$so has no libc.so in DT_NEEDED — it linked the static libc.a. " + - "That is the `-L` order in linkFlags() regressing; a device crashes " + - "with a null deref in getauxval the first time the SDK is dlopen'd.\n$dump" - } - } - } -} - -tasks.matching { it.name == "preBuild" }.configureEach { - dependsOn(cargoBuildAndroid, uniffiBindgen, verifyDynamicLibc) -} diff --git a/android/sdk/consumer-rules.pro b/android/sdk/consumer-rules.pro deleted file mode 100644 index 0710fac..0000000 --- a/android/sdk/consumer-rules.pro +++ /dev/null @@ -1,9 +0,0 @@ -# Applied to any app that depends on :sdk (AAR consumer rules). -# -# UniFFI calls back into Kotlin from the Rust side over JNI, so the generated -# classes are reachable only via reflection/native lookup. Without these keeps -# an R8-enabled consumer app strips them and fails at load time. --keep class uniffi.onionwire_sdk.** { *; } --keepclasseswithmembernames class uniffi.onionwire_sdk.** { - native ; -} diff --git a/android/sdk/src/main/AndroidManifest.xml b/android/sdk/src/main/AndroidManifest.xml deleted file mode 100644 index ddb6ba0..0000000 --- a/android/sdk/src/main/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts deleted file mode 100644 index c6f32e6..0000000 --- a/android/settings.gradle.kts +++ /dev/null @@ -1,28 +0,0 @@ -pluginManagement { - repositories { - google { - content { - includeGroupByRegex("com\\.android.*") - includeGroupByRegex("com\\.google.*") - includeGroupByRegex("androidx.*") - } - } - mavenCentral() - gradlePluginPortal() - } -} - -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - } -} - -rootProject.name = "onionwire-android" - -// The Android library that ships as the AAR (Kotlin bindings + native .so). -include(":sdk") -// The installable Compose messenger. Depends on :sdk only — never on the TUI. -include(":app") diff --git a/crates/onionwire-sdk/Cargo.lock b/crates/onionwire-sdk/Cargo.lock deleted file mode 100644 index c327104..0000000 --- a/crates/onionwire-sdk/Cargo.lock +++ /dev/null @@ -1,8286 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "adler2" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" - -[[package]] -name = "aead" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" -dependencies = [ - "crypto-common 0.1.7", - "generic-array", -] - -[[package]] -name = "aes" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" -dependencies = [ - "cfg-if", - "cipher 0.4.4", - "cpufeatures 0.2.17", -] - -[[package]] -name = "aes" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35f0f96ce78e38c3dc6d8948aa8163d06385be74000f3c7a95bf1eef35d3ea32" -dependencies = [ - "cipher 0.5.2", - "cpubits", - "cpufeatures 0.3.1", - "zeroize", -] - -[[package]] -name = "aes-gcm" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" -dependencies = [ - "aead", - "aes 0.8.4", - "cipher 0.4.4", - "ctr 0.9.2", - "ghash", - "subtle", -] - -[[package]] -name = "aho-corasick" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" -dependencies = [ - "memchr", -] - -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - -[[package]] -name = "amplify" -version = "4.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f7fb4ac7c881e54a8e7015e399b6112a2a5bc958b6c89ac510840ff20273b31" -dependencies = [ - "amplify_derive", - "amplify_num", - "ascii", - "getrandom 0.2.17", - "getrandom 0.3.4", - "wasm-bindgen", -] - -[[package]] -name = "amplify_derive" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a6309e6b8d89b36b9f959b7a8fa093583b94922a0f6438a24fb08936de4d428" -dependencies = [ - "amplify_syn", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "amplify_num" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afed304556696656d2d71495e1e5f2c4b524a3fb6eb0f2f3778ffc482a40b8a8" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "amplify_syn" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7736fb8d473c0d83098b5bac44df6a561e20470375cd8bcae30516dc889fd62a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "android_system_properties" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" -dependencies = [ - "libc", -] - -[[package]] -name = "anstyle" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" - -[[package]] -name = "anyhow" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" - -[[package]] -name = "approx" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" -dependencies = [ - "num-traits", -] - -[[package]] -name = "arc-swap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c049c0be4daef0b145cb3555416b3b8ef5b7888a38aea1a3a155801fe7b0810b" -dependencies = [ - "rustversion", -] - -[[package]] -name = "argon2" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072" -dependencies = [ - "base64ct", - "blake2", - "cpufeatures 0.2.17", - "password-hash", -] - -[[package]] -name = "arrayvec" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" - -[[package]] -name = "arti-client" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b3624d7bee91f821b04fe5412f561671e5500677781d3f070a2fa101a128b0" -dependencies = [ - "async-trait", - "cfg-if", - "derive-deftly", - "derive_builder_fork_arti", - "derive_more", - "educe", - "fs-mistrust", - "futures", - "hostname-validator", - "humantime", - "humantime-serde", - "libc", - "once_cell", - "postage", - "rand 0.10.4", - "safelog", - "serde", - "thiserror 2.0.20", - "time", - "tor-async-utils", - "tor-basic-utils", - "tor-chanmgr", - "tor-circmgr", - "tor-config", - "tor-config-path", - "tor-dircommon", - "tor-dirmgr", - "tor-error", - "tor-guardmgr", - "tor-hsclient", - "tor-hscrypto", - "tor-hsservice", - "tor-keymgr", - "tor-linkspec", - "tor-llcrypto", - "tor-memquota", - "tor-netdir", - "tor-netdoc", - "tor-persist", - "tor-proto", - "tor-protover", - "tor-rtcompat", - "tracing", - "void", - "web-time-compat", -] - -[[package]] -name = "ascii" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" - -[[package]] -name = "askama" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6024d73179f43f15ccd2b881bfea6fee7f3a46ec53f33b52210dea749ebebaa4" -dependencies = [ - "askama_macros", - "itoa", - "percent-encoding", - "serde", - "serde_json", -] - -[[package]] -name = "askama_derive" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071ee5ebf2138e3ad180e0aacf6940c2cab5e6d8333741d9925c7bee2b153f39" -dependencies = [ - "askama_parser", - "basic-toml", - "glob", - "memchr", - "proc-macro2", - "quote", - "rustc-hash", - "serde", - "serde_derive", - "syn 3.0.5", -] - -[[package]] -name = "askama_macros" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643e1c7cbb6aec1d920332fe51a7c0d8219e273dcb8602db03f5263e4d16487b" -dependencies = [ - "askama_derive", -] - -[[package]] -name = "askama_parser" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c5ae75772275d268b03ab8bdccdd12117b6169ee23256942b34e46c9f476583" -dependencies = [ - "rustc-hash", - "serde", - "serde_derive", - "unicode-ident", - "winnow 1.0.4", -] - -[[package]] -name = "asn1-rs" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f43a50ac4fdca5df8e885c21b835997f0a1cdee65494a6847694a98652d9d8" -dependencies = [ - "asn1-rs-derive", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror 2.0.20", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", - "synstructure 0.13.2", -] - -[[package]] -name = "asn1-rs-impl" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "async-compat" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c97d7ff3c25d6c10d64170c12acaf5d4245e76dece3779c1d92b153a64f11df" -dependencies = [ - "futures-core", - "futures-io", - "once_cell", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "async-compression" -version = "0.4.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c31224bd2c09447484a1143f2fc1d871eb405789859c8e5470a3e7f95f40a18" -dependencies = [ - "compression-codecs", - "compression-core", - "futures-io", - "pin-project-lite", -] - -[[package]] -name = "async-trait" -version = "0.1.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "async_executors" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a982d2f86de6137cc05c9db9a915a19886c97911f9790d04f174cede74be01a5" -dependencies = [ - "blanket", - "futures-core", - "futures-task", - "futures-util", - "pin-project", - "rustc_version", - "tokio", -] - -[[package]] -name = "asynchronous-codec" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a860072022177f903e59730004fb5dc13db9275b79bb2aef7ba8ce831956c233" -dependencies = [ - "bytes", - "futures-sink", - "futures-util", - "memchr", - "pin-project-lite", -] - -[[package]] -name = "atomic" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" - -[[package]] -name = "atomic" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89cbf775b137e9b968e67227ef7f775587cde3fd31b0d8599dbd0f598a48340" -dependencies = [ - "bytemuck", -] - -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - -[[package]] -name = "autocfg" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" - -[[package]] -name = "axum" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90" -dependencies = [ - "axum-core", - "bytes", - "futures-util", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-util", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "serde_core", - "serde_json", - "serde_path_to_error", - "sync_wrapper", - "tokio", - "tower", - "tower-layer", - "tower-service", -] - -[[package]] -name = "axum-core" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" -dependencies = [ - "bytes", - "futures-core", - "http", - "http-body", - "http-body-util", - "mime", - "pin-project-lite", - "sync_wrapper", - "tower-layer", - "tower-service", -] - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" - -[[package]] -name = "base64ct" -version = "1.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" - -[[package]] -name = "basic-toml" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a" -dependencies = [ - "serde", -] - -[[package]] -name = "bincode" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" -dependencies = [ - "serde", - "unty", -] - -[[package]] -name = "bit-set" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" -dependencies = [ - "bit-vec", -] - -[[package]] -name = "bit-vec" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" -dependencies = [ - "bytemuck", - "serde_core", -] - -[[package]] -name = "bitvec" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddcec3d12c579d40898fe0a9a358a803c23e9c52ca3c425707f81c9436211837" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "blake2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "blake3" -version = "1.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d9e454fc11f76977dc803893aff6304ed33d6a26efae8696573bea74baa27ae" -dependencies = [ - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq", - "cpufeatures 0.3.1", -] - -[[package]] -name = "blanket" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0b121a9fe0df916e362fb3271088d071159cdf11db0e4182d02152850756eff" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "block-buffer" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" -dependencies = [ - "hybrid-array", - "zeroize", -] - -[[package]] -name = "borsh" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a" -dependencies = [ - "borsh-derive", - "bytes", - "cfg_aliases", -] - -[[package]] -name = "borsh-derive" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cdfe656708a01f89b451a7d36466e6fe6c414de0aa18fc54f864f6f9ca9f56" -dependencies = [ - "once_cell", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "bs58" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "bstr" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb31b46c14244e20ee9984b11bf5c992b91fb6939fea616e3512c8baecdbe5f" -dependencies = [ - "memchr", - "regex-automata", - "serde_core", -] - -[[package]] -name = "bumpalo" -version = "3.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" - -[[package]] -name = "by_address" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06" - -[[package]] -name = "bytemuck" -version = "1.25.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" -dependencies = [ - "bytemuck_derive", -] - -[[package]] -name = "bytemuck_derive" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "byteorder-lite" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" - -[[package]] -name = "bytes" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" -dependencies = [ - "serde", -] - -[[package]] -name = "byteview" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d74937895e761d5984206f82ca8ff7725d0fd8021921011921894b41ab1b9f7" - -[[package]] -name = "camino" -version = "1.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1307f12aa967b5a58416e87b3653360e0fd614a016b6e970db08fecbb1b80d" -dependencies = [ - "serde_core", -] - -[[package]] -name = "caret" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3f1a1c7fa296eb2367469e6226783ed07cb778d75d13f7b6ee3f1de593ba7f4" - -[[package]] -name = "cargo-platform" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0061da739915fae12ea00e16397555ed4371a6bb285431aab930f61b0aa4ba" -dependencies = [ - "serde", - "serde_core", -] - -[[package]] -name = "cargo_metadata" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "serde", - "serde_json", - "thiserror 2.0.20", -] - -[[package]] -name = "castaway" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" -dependencies = [ - "rustversion", -] - -[[package]] -name = "cc" -version = "1.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "005ec2760ca554fae18df7a11195552ec576cd665632a881bc011d5bb2fd4d80" -dependencies = [ - "find-msvc-tools", - "jobserver", - "libc", - "shlex", -] - -[[package]] -name = "cfg-if" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" - -[[package]] -name = "cfg_aliases" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" - -[[package]] -name = "chacha20" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" -dependencies = [ - "cfg-if", - "cipher 0.4.4", - "cpufeatures 0.2.17", -] - -[[package]] -name = "chacha20" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "rand_core 0.10.1", -] - -[[package]] -name = "chacha20poly1305" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" -dependencies = [ - "aead", - "chacha20 0.9.1", - "cipher 0.4.4", - "poly1305", - "zeroize", -] - -[[package]] -name = "chrono" -version = "0.4.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" -dependencies = [ - "iana-time-zone", - "num-traits", - "serde", - "windows-link", -] - -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common 0.1.7", - "inout 0.1.4", - "zeroize", -] - -[[package]] -name = "cipher" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" -dependencies = [ - "block-buffer 0.12.1", - "crypto-common 0.2.2", - "inout 0.2.2", - "zeroize", -] - -[[package]] -name = "clap" -version = "4.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473c7e07f409a8d772161724aa8db6a765a2532a70f9667eeb7b49d3d02fbdca" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889" -dependencies = [ - "anstyle", - "clap_lex", - "strsim 0.11.1", - "terminal_size", -] - -[[package]] -name = "clap_derive" -version = "4.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d012d2b9d65aca7f18f4d9878a045bc17899bba951561ba5ec3c2ba1eed9a061" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "clap_lex" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" - -[[package]] -name = "cmake" -version = "0.1.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" -dependencies = [ - "cc", -] - -[[package]] -name = "cmov" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" - -[[package]] -name = "coarsetime" -version = "0.1.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae63702c5627c75addbfb1ea9d1b3842205a6ffd43e4cce884a2a9eb1828fd7" -dependencies = [ - "libc", - "wasix", - "wasm-bindgen", -] - -[[package]] -name = "compact_str" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab" -dependencies = [ - "castaway", - "cfg-if", - "itoa", - "rustversion", - "ryu", - "static_assertions", -] - -[[package]] -name = "compare" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0095f6103c2a8b44acd6fd15960c801dafebf02e21940360833e0673f48ba7" - -[[package]] -name = "compression-codecs" -version = "0.4.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f938fc0d88fbe2c8d6f0e1ba96ba1165d89ff698e98468cd019d92cff2ecd367" -dependencies = [ - "compression-core", - "flate2", - "liblzma", - "zstd", - "zstd-safe", -] - -[[package]] -name = "compression-core" -version = "0.4.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ebdda89edc534bf8d5dd2857562633b6495557e5846552ade994b99ed13c36a" - -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - -[[package]] -name = "const-oid" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" - -[[package]] -name = "const_format" -version = "0.2.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4481a617ad9a412be3b97c5d403fef8ed023103368908b9c50af598ff467cc1e" -dependencies = [ - "const_format_proc_macros", - "konst", -] - -[[package]] -name = "const_format_proc_macros" -version = "0.2.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - -[[package]] -name = "constant_time_eq" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b" - -[[package]] -name = "convert_case" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "cookie-factory" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9885fa71e26b8ab7855e2ec7cae6e9b380edff76cd052e07c683a0319d51b3a2" -dependencies = [ - "futures", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - -[[package]] -name = "cpubits" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" - -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - -[[package]] -name = "cpufeatures" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" -dependencies = [ - "libc", -] - -[[package]] -name = "crc32fast" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8498c871161e1742aaa9d52551b2d6ebdd4c3d45a3be423e3728f33b955be550" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e71406cd8807725f7ac2f999a4cdd32e98f829fdf65f528343cebf945e41df1e" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-epoch", - "crossbeam-queue", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-queue" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e8bd762f7479489c70ed6c768ddca99d7296857de437a68dcb2a94365b3fae" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-skiplist" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df29de440c58ca2cc6e587ec3d22347551a32435fbde9d2bff64e78a9ffa151b" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" - -[[package]] -name = "crossterm" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" -dependencies = [ - "bitflags 2.13.2", - "crossterm_winapi", - "derive_more", - "document-features", - "mio", - "parking_lot", - "rustix", - "signal-hook", - "signal-hook-mio", - "winapi", -] - -[[package]] -name = "crossterm_winapi" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" -dependencies = [ - "winapi", -] - -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-bigint" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a52aa3fcda4e6302a9f48734f234d35d4721b96f8fe07d073f07ce9df4f0271" -dependencies = [ - "cpubits", - "ctutils", - "num-traits", -] - -[[package]] -name = "crypto-common" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "typenum", -] - -[[package]] -name = "crypto-common" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" -dependencies = [ - "getrandom 0.4.3", - "hybrid-array", - "rand_core 0.10.1", -] - -[[package]] -name = "ctr" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" -dependencies = [ - "cipher 0.4.4", -] - -[[package]] -name = "ctr" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baaca1c4b237092596f64d571e9db6ce4109c4ef9742e27590f1709594461f21" -dependencies = [ - "cipher 0.5.2", -] - -[[package]] -name = "ctutils" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e" -dependencies = [ - "cmov", -] - -[[package]] -name = "cuprate-address-book" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "borsh", - "cuprate-constants", - "cuprate-p2p-core", - "cuprate-pruning", - "futures", - "indexmap 2.14.2", - "rand 0.8.8", - "thiserror 2.0.20", - "tokio", - "tokio-util", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-async-buffer" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "futures", - "pin-project", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-blockchain" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "arc-swap", - "bytemuck", - "bytes", - "crossbeam", - "cuprate-constants", - "cuprate-helper", - "cuprate-pruning", - "cuprate-types", - "fjall", - "futures", - "indexmap 2.14.2", - "monero-oxide", - "rand 0.8.8", - "rayon", - "serde", - "tapes", - "thiserror 2.0.20", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-consensus" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "cfg-if", - "cuprate-consensus-context", - "cuprate-consensus-rules", - "cuprate-helper", - "cuprate-types", - "hex", - "indexmap 2.14.2", - "monero-oxide", - "rand 0.8.8", - "rayon", - "thiserror 2.0.20", - "thread_local", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-consensus-context" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "arc-swap", - "cuprate-consensus-rules", - "cuprate-helper", - "cuprate-types", - "futures", - "hex", - "monero-oxide", - "randomx-rs", - "rayon", - "strum", - "thread_local", - "tokio", - "tokio-util", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-consensus-rules" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "cfg-if", - "crypto-bigint 0.7.5", - "cuprate-constants", - "cuprate-cryptonight", - "cuprate-helper", - "cuprate-types", - "curve25519-dalek 4.1.3", - "hex", - "hex-literal 1.1.0", - "indexmap 2.14.2", - "monero-oxide", - "rand 0.8.8", - "rayon", - "thiserror 2.0.20", - "tracing", -] - -[[package]] -name = "cuprate-constants" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" - -[[package]] -name = "cuprate-cryptonight" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "digest 0.10.7", - "groestl", - "jh", - "keccak 0.1.6", - "seq-macro", - "sha3 0.10.9", - "skein", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-dandelion-tower" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "futures", - "rand 0.8.8", - "rand_distr", - "thiserror 2.0.20", - "tokio", - "tokio-util", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-epee-encoding" -version = "0.5.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bytes", - "cuprate-fixed-bytes", - "cuprate-hex", - "paste", - "ref-cast", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-fast-sync" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "blake3", - "clap", - "cuprate-blockchain", - "cuprate-consensus", - "cuprate-consensus-context", - "cuprate-helper", - "cuprate-hex", - "cuprate-p2p", - "cuprate-p2p-core", - "cuprate-types", - "fjall", - "futures", - "hex", - "monero-oxide", - "rayon", - "serde_json", - "tokio", - "tower", - "tracing-subscriber", -] - -[[package]] -name = "cuprate-fixed-bytes" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bytes", - "serde", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-helper" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "chrono", - "cuprate-constants", - "curve25519-dalek 4.1.3", - "dirs 6.0.0", - "futures", - "libc", - "monero-oxide", - "rayon", - "serde", - "windows", -] - -[[package]] -name = "cuprate-hex" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "hex", - "serde", -] - -[[package]] -name = "cuprate-json-rpc" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "serde", - "serde_json", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-levin" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bitflags 2.13.2", - "bytes", - "cfg-if", - "cuprate-helper", - "thiserror 2.0.20", - "tokio-util", - "tracing", -] - -[[package]] -name = "cuprate-p2p" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "borsh", - "bytes", - "cuprate-address-book", - "cuprate-async-buffer", - "cuprate-constants", - "cuprate-fixed-bytes", - "cuprate-helper", - "cuprate-p2p-core", - "cuprate-pruning", - "cuprate-types", - "cuprate-wire", - "futures", - "indexmap 2.14.2", - "monero-oxide", - "pin-project", - "rand 0.8.8", - "rand_distr", - "rayon", - "thiserror 2.0.20", - "tokio", - "tokio-stream", - "tokio-util", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-p2p-core" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "async-trait", - "borsh", - "cfg-if", - "cuprate-helper", - "cuprate-pruning", - "cuprate-types", - "cuprate-wire", - "futures", - "hex", - "hex-literal 1.1.0", - "rand 0.8.8", - "thiserror 2.0.20", - "tokio", - "tokio-stream", - "tokio-util", - "tower", - "tracing", -] - -[[package]] -name = "cuprate-p2p-transport" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "async-trait", - "cuprate-p2p-core", - "cuprate-wire", - "futures", - "tokio", - "tokio-socks", - "tokio-util", -] - -[[package]] -name = "cuprate-pruning" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "borsh", - "cuprate-constants", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-rpc-interface" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "anyhow", - "axum", - "cuprate-epee-encoding", - "cuprate-helper", - "cuprate-json-rpc", - "cuprate-rpc-types", - "futures", - "paste", - "serde", - "serde_json", - "tower", -] - -[[package]] -name = "cuprate-rpc-types" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "cuprate-epee-encoding", - "cuprate-fixed-bytes", - "cuprate-helper", - "cuprate-hex", - "cuprate-p2p-core", - "cuprate-types", - "hex", - "monero-oxide", - "paste", - "serde", - "serde_json", -] - -[[package]] -name = "cuprate-txpool" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bitflags 2.13.2", - "blake3", - "bytemuck", - "cuprate-helper", - "cuprate-types", - "fjall", - "futures", - "hex", - "monero-oxide", - "rayon", - "thiserror 2.0.20", - "tower", -] - -[[package]] -name = "cuprate-types" -version = "0.0.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bitflags 2.13.2", - "bytes", - "cfg-if", - "cuprate-epee-encoding", - "cuprate-fixed-bytes", - "cuprate-helper", - "cuprate-hex", - "indexmap 2.14.2", - "monero-oxide", - "proptest", - "proptest-derive", - "serde", - "strum", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprate-wire" -version = "0.1.0" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "bitflags 2.13.2", - "borsh", - "bytes", - "cuprate-epee-encoding", - "cuprate-fixed-bytes", - "cuprate-helper", - "cuprate-levin", - "cuprate-types", - "serde", - "thiserror 2.0.20", -] - -[[package]] -name = "cuprated" -version = "0.1.0-preview" -source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d50de4adb6825bf#4f8fcd1bf468f566fcd89c460d50de4adb6825bf" -dependencies = [ - "anyhow", - "axum", - "borsh", - "bytes", - "clap", - "const_format", - "cuprate-address-book", - "cuprate-blockchain", - "cuprate-consensus", - "cuprate-consensus-context", - "cuprate-consensus-rules", - "cuprate-constants", - "cuprate-cryptonight", - "cuprate-dandelion-tower", - "cuprate-fast-sync", - "cuprate-fixed-bytes", - "cuprate-helper", - "cuprate-hex", - "cuprate-p2p", - "cuprate-p2p-core", - "cuprate-p2p-transport", - "cuprate-pruning", - "cuprate-rpc-interface", - "cuprate-rpc-types", - "cuprate-txpool", - "cuprate-types", - "cuprate-wire", - "dashmap", - "fjall", - "futures", - "hex", - "hyper", - "hyper-util", - "indexmap 2.14.2", - "monero-address", - "monero-oxide", - "nu-ansi-term", - "pin-project-lite", - "rayon", - "serde", - "serde_json", - "sysinfo", - "thiserror 2.0.20", - "tokio", - "tokio-util", - "toml 1.2.3+spec-1.1.0", - "toml_edit 0.25.14+spec-1.1.0", - "tower", - "tower-http", - "tracing", - "tracing-appender", - "tracing-subscriber", -] - -[[package]] -name = "curve25519-dalek" -version = "4.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" -dependencies = [ - "cfg-if", - "cpufeatures 0.2.17", - "curve25519-dalek-derive", - "digest 0.10.7", - "fiat-crypto 0.2.9", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "5.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c1aa5a9b7626ed65ac0cf5ea9d4f1547af89017fbac20bd4de40022fff516f" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "curve25519-dalek-derive", - "digest 0.11.3", - "fiat-crypto 0.3.0", - "rand_core 0.10.1", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core 0.14.4", - "darling_macro 0.14.4", -] - -[[package]] -name = "darling" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" -dependencies = [ - "darling_core 0.21.3", - "darling_macro 0.21.3", -] - -[[package]] -name = "darling" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" -dependencies = [ - "darling_core 0.24.1", - "darling_macro 0.24.1", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn 1.0.109", -] - -[[package]] -name = "darling_core" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "darling_core" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" -dependencies = [ - "ident_case", - "proc-macro2", - "quote", - "strsim 0.11.1", - "syn 3.0.5", -] - -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core 0.14.4", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" -dependencies = [ - "darling_core 0.21.3", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "darling_macro" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" -dependencies = [ - "darling_core 0.24.1", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "dashmap" -version = "6.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6361d5c062261c78a176addb82d4c821ae42bed6089de0e12603cd25de2059c" -dependencies = [ - "cfg-if", - "crossbeam-utils", - "hashbrown 0.14.5", - "lock_api", - "once_cell", - "parking_lot_core", -] - -[[package]] -name = "data-encoding" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" - -[[package]] -name = "defmt" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2953bfe4f93bbd20cc71198842756f77d161884c99ebbabc41d80231ded88d1" -dependencies = [ - "bitflags 1.3.2", - "defmt-macros", -] - -[[package]] -name = "defmt-macros" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad9c72e7ca2137e0dc3813245a0d282fd6daad32fd800af018306a9169b5fe8" -dependencies = [ - "defmt-parser", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "defmt-parser" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e" -dependencies = [ - "thiserror 2.0.20", -] - -[[package]] -name = "der" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" -dependencies = [ - "const-oid 0.9.6", - "pem-rfc7468", - "zeroize", -] - -[[package]] -name = "der" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a" -dependencies = [ - "const-oid 0.10.2", - "zeroize", -] - -[[package]] -name = "der-parser" -version = "10.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6" -dependencies = [ - "asn1-rs", - "cookie-factory", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", -] - -[[package]] -name = "deranged" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" -dependencies = [ - "serde_core", -] - -[[package]] -name = "derive-deftly" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "724949bdda5310709ca2f97bf69c2b01e3362f44fef1fb47913445db4c1debb5" -dependencies = [ - "derive-deftly-macros", - "heck", -] - -[[package]] -name = "derive-deftly-macros" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17933e749f2502cfcd1c27519292fbbea22e8fc64ce680e863f855e8cd8cce23" -dependencies = [ - "heck", - "indexmap 2.14.2", - "itertools 0.15.0", - "proc-macro-crate", - "proc-macro2", - "quote", - "sha3 0.12.0", - "strum", - "syn 3.0.5", - "unicode-ident", - "void", -] - -[[package]] -name = "derive_builder_core_fork_arti" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24c1b715c79be6328caa9a5e1a387a196ea503740f0722ec3dd8f67a9e72314d" -dependencies = [ - "darling 0.14.4", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder_fork_arti" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3eae24d595f4d0ecc90a9a5a6d11c2bd8dafe2375ec4a1ec63250e5ade7d228" -dependencies = [ - "derive_builder_macro_fork_arti", -] - -[[package]] -name = "derive_builder_macro_fork_arti" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69887769a2489cd946bf782eb2b1bb2cb7bc88551440c94a765d4f040c08ebf3" -dependencies = [ - "derive_builder_core_fork_arti", - "syn 1.0.109", -] - -[[package]] -name = "derive_more" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 2.0.119", - "unicode-xid", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer 0.10.4", - "const-oid 0.9.6", - "crypto-common 0.1.7", - "subtle", -] - -[[package]] -name = "digest" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" -dependencies = [ - "block-buffer 0.12.1", - "const-oid 0.10.2", - "crypto-common 0.2.2", - "ctutils", -] - -[[package]] -name = "directories" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.61.2", -] - -[[package]] -name = "displaydoc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "document-features" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" -dependencies = [ - "litrs", -] - -[[package]] -name = "downcast-rs" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "117240f60069e65410b3ae1bb213295bd828f707b5bec6596a1afc8793ce0cbc" - -[[package]] -name = "dyn-clone" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der 0.7.10", - "digest 0.10.7", - "elliptic-curve", - "rfc6979", - "signature 2.2.0", - "spki 0.7.3", -] - -[[package]] -name = "ed25519" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" -dependencies = [ - "pkcs8 0.10.2", - "signature 2.2.0", -] - -[[package]] -name = "ed25519" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29fcf32e6c73d1079f83ab4d782de2d81620346a5f38c6237a86a22f8368980a" -dependencies = [ - "pkcs8 0.11.0", - "signature 3.0.0", -] - -[[package]] -name = "ed25519-dalek" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" -dependencies = [ - "curve25519-dalek 4.1.3", - "ed25519 2.2.3", - "rand_core 0.6.4", - "serde", - "sha2 0.10.9", - "subtle", - "zeroize", -] - -[[package]] -name = "ed25519-dalek" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de" -dependencies = [ - "curve25519-dalek 5.1.0", - "ed25519 3.0.0", - "keccak 0.2.2", - "rand_core 0.10.1", - "serde", - "sha2 0.11.3", - "signature 3.0.0", - "strobe-rs", - "subtle", - "zeroize", -] - -[[package]] -name = "educe" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0042ff8246a363dbe77d2ceedb073339e85a804b9a47636c6e016a9a32c05f" -dependencies = [ - "enum-ordinalize", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "either" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint 0.5.5", - "digest 0.10.7", - "ff", - "generic-array", - "group", - "pkcs8 0.10.2", - "rand_core 0.6.4", - "sec1", - "subtle", - "zeroize", -] - -[[package]] -name = "enum-ordinalize" -version = "3.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf1fa3f06bbff1ea5b1a9c7b14aa992a39657db60a2759457328d7e058f49ee" -dependencies = [ - "num-bigint", - "num-traits", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "enum_dispatch" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd" -dependencies = [ - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "enumset" -version = "1.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccc5801fd11762e24d1e420d01d2ac518f2a2ca4329d4fbb6639f2412b6204e0" -dependencies = [ - "enumset_derive", -] - -[[package]] -name = "enumset_derive" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd536557b58c682b217b8fb199afdff47cd3eff260623f19e77074eb073d63a" -dependencies = [ - "darling 0.21.3", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - -[[package]] -name = "errno" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" -dependencies = [ - "libc", - "windows-sys 0.61.2", -] - -[[package]] -name = "event-listener" -version = "5.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" -dependencies = [ - "parking", - "pin-project-lite", -] - -[[package]] -name = "extend" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311a6d2f1f9d60bff73d2c78a0af97ed27f79672f15c238192a5bbb64db56d00" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "fallible-iterator" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" - -[[package]] -name = "fallible-streaming-iterator" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" - -[[package]] -name = "fastrand" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" - -[[package]] -name = "ff" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "fiat-crypto" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" - -[[package]] -name = "fiat-crypto" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" - -[[package]] -name = "figment" -version = "0.10.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cb01cd46b0cf372153850f4c6c272d9cbea2da513e07538405148f95bd789f3" -dependencies = [ - "atomic 0.6.1", - "serde", - "toml 0.8.23", - "uncased", - "version_check", -] - -[[package]] -name = "filetime" -version = "0.2.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759" -dependencies = [ - "cfg-if", - "libc", -] - -[[package]] -name = "find-msvc-tools" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d" - -[[package]] -name = "fjall" -version = "3.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd201c93927cdf4712e8f7d4c9c8d34d68c7534380c05d4a58864a309f91c33f" -dependencies = [ - "byteorder-lite", - "byteview", - "dashmap", - "flume", - "log", - "lsm-tree", - "lz4_flex", - "tempfile", - "xxhash-rust", -] - -[[package]] -name = "flate2" -version = "1.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb" -dependencies = [ - "crc32fast", - "miniz_oxide", - "zlib-rs", -] - -[[package]] -name = "fluid-let" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "749cff877dc1af878a0b31a41dd221a753634401ea0ef2f87b62d3171522485a" - -[[package]] -name = "flume" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e139bc46ca777eb5efaf62df0ab8cc5fd400866427e56c68b22e414e53bd3be" -dependencies = [ - "spin 0.9.9", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - -[[package]] -name = "foldhash" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" - -[[package]] -name = "form_urlencoded" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "fs-err" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91aa448ca50d7e79433bdf3ee8d99215430d2ec02ade5aefab2a073a1822e8a" -dependencies = [ - "autocfg", -] - -[[package]] -name = "fs-mistrust" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628799db8c034e020e48ee393c271f423aa749fde1c3195bd3bbc8bb5cfcbe8" -dependencies = [ - "derive_builder_fork_arti", - "dirs 7.0.0", - "extend", - "libc", - "pwd-grp", - "serde", - "thiserror 2.0.20", - "void", - "walkdir", -] - -[[package]] -name = "fslock-guard" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba455a614874a0b1814cf3e30f8a6d4c8858e2bc38569bd293e3ff8cbad49032" -dependencies = [ - "libc", - "thiserror 2.0.20", - "windows-sys 0.61.2", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "futures" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" - -[[package]] -name = "futures-executor" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" - -[[package]] -name = "futures-macro" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "futures-rustls" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" -dependencies = [ - "futures-io", - "rustls", - "rustls-pki-types", -] - -[[package]] -name = "futures-sink" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" - -[[package]] -name = "futures-task" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" - -[[package]] -name = "futures-util" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "slab", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", - "zeroize", -] - -[[package]] -name = "getrandom" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "wasi", - "wasm-bindgen", -] - -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "r-efi 5.3.0", - "wasip2", - "wasm-bindgen", -] - -[[package]] -name = "getrandom" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "r-efi 6.0.0", - "rand_core 0.10.1", - "wasm-bindgen", -] - -[[package]] -name = "getset" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cf442baaabe4213ce7d1239afc26c039180b6456da2cededa316ae2c8a77a77" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "ghash" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" -dependencies = [ - "opaque-debug", - "polyval 0.6.2", -] - -[[package]] -name = "glob" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" - -[[package]] -name = "glob-match" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985c9503b412198aa4197559e9a318524ebc4519c229bfa05a535828c950b9d" - -[[package]] -name = "goblin" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b363a30c165f666402fe6a3024d3bec7ebc898f96a4a23bd1c99f8dbf3f4f47" -dependencies = [ - "log", - "plain", - "scroll", -] - -[[package]] -name = "groestl" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343cfc165f92a988fd60292f7a0bfde4352a5a0beff9fbec29251ca4e9676e4d" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "growable-bloom-filter" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d174ccb4ba660d431329e7f0797870d0a4281e36353ec4b4a3c5eab6c2cfb6f1" -dependencies = [ - "serde", - "serde_bytes", - "serde_derive", - "xxhash-rust", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash 0.1.5", -] - -[[package]] -name = "hashbrown" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash 0.2.0", -] - -[[package]] -name = "hashbrown" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash 0.2.0", -] - -[[package]] -name = "hashlink" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" -dependencies = [ - "hashbrown 0.15.5", -] - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -dependencies = [ - "serde", -] - -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - -[[package]] -name = "hex-literal" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e712f64ec3850b98572bffac52e2c6f282b29fe6c5fa6d42334b30be438d95c1" - -[[package]] -name = "hkdf" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" -dependencies = [ - "hmac 0.12.1", -] - -[[package]] -name = "hkdf" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018" -dependencies = [ - "hmac 0.13.0", -] - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "hmac" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" -dependencies = [ - "digest 0.11.3", -] - -[[package]] -name = "hostname-validator" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f558a64ac9af88b5ba400d99b579451af0d39c6d360980045b91aac966d705e2" - -[[package]] -name = "http" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" -dependencies = [ - "bytes", - "itoa", -] - -[[package]] -name = "http-body" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" -dependencies = [ - "bytes", - "http", -] - -[[package]] -name = "http-body-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" -dependencies = [ - "bytes", - "futures-core", - "http", - "http-body", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" - -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - -[[package]] -name = "humantime" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15cdd26707701c53297e2fa6afb323d55fbc1d0810c3aec078ae3ef0424c3c15" - -[[package]] -name = "humantime-serde" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" -dependencies = [ - "humantime", - "serde", -] - -[[package]] -name = "hybrid-array" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" -dependencies = [ - "ctutils", - "typenum", - "zeroize", -] - -[[package]] -name = "hyper" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b501faa50e7a26c3d3560ca625132f4078a17771f4810baf70475ae48cbe43" -dependencies = [ - "atomic-waker", - "bytes", - "futures-channel", - "futures-core", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", -] - -[[package]] -name = "hyper-util" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" -dependencies = [ - "bytes", - "http", - "http-body", - "hyper", - "pin-project-lite", - "tokio", - "tower-service", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.65" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "log", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "icu_collections" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" -dependencies = [ - "displaydoc", - "potential_utf", - "utf8_iter", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locale_core" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_normalizer" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" -dependencies = [ - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" - -[[package]] -name = "icu_properties" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locale_core", - "icu_properties_data", - "icu_provider", - "zerotrie", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" - -[[package]] -name = "icu_provider" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73" -dependencies = [ - "displaydoc", - "icu_locale_core", - "writeable", - "yoke", - "zerofrom", - "zerotrie", - "zerovec", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "idna" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" -dependencies = [ - "idna_adapter", - "smallvec", - "utf8_iter", -] - -[[package]] -name = "idna_adapter" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" -dependencies = [ - "icu_normalizer", - "icu_properties", -] - -[[package]] -name = "imara-diff" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f01d462f766df78ab820dd06f5eb700233c51f0f4c2e846520eaf4ba6aa5c5c" -dependencies = [ - "hashbrown 0.15.5", - "memchr", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "indexmap" -version = "2.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" -dependencies = [ - "equivalent", - "hashbrown 0.17.1", - "rayon", - "serde", - "serde_core", -] - -[[package]] -name = "indoc" -version = "2.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706" -dependencies = [ - "rustversion", -] - -[[package]] -name = "inotify" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cc00ea907cab49550b7da656f80ebb97be1b997d931fbcd28d39734e17ce592" -dependencies = [ - "bitflags 2.13.2", - "inotify-sys", - "libc", -] - -[[package]] -name = "inotify-sys" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c033f80b2c113cdf91ab7a33faa9cbc014726dcad99880c8609af2a370edf37d" -dependencies = [ - "libc", -] - -[[package]] -name = "inout" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" -dependencies = [ - "generic-array", -] - -[[package]] -name = "inout" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7" -dependencies = [ - "hybrid-array", -] - -[[package]] -name = "instability" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf84e73fa6f27f299dec58e13223cf70db80da872eb921d4f6138342a0eabc8" -dependencies = [ - "darling 0.24.1", - "indoc", - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "interval-heap" -version = "0.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11274e5e8e89b8607cfedc2910b6626e998779b48a019151c7604d0adcb86ac6" -dependencies = [ - "compare", -] - -[[package]] -name = "inventory" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" -dependencies = [ - "rustversion", -] - -[[package]] -name = "ipnet" -version = "2.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" - -[[package]] -name = "iprange" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37209be0ad225457e63814401415e748e2453a5297f9b637338f5fb8afa4ec00" -dependencies = [ - "ipnet", -] - -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - -[[package]] -name = "itertools" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" - -[[package]] -name = "jh" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f65735f9e73adc203417d2e05352aef71d7e832ec090f65de26c96c9ec563aa5" -dependencies = [ - "digest 0.10.7", - "hex-literal 0.4.1", - "ppv-lite86", -] - -[[package]] -name = "jiff" -version = "0.2.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668b7183bd07af9a4885f5c35b0cc5c83c4607a913c16b7e17291832910d2dcc" -dependencies = [ - "defmt", - "jiff-core 0.1.0", - "jiff-static 0.2.35", - "jiff-tzdb-platform 0.1.3", - "log", - "portable-atomic", - "portable-atomic-util", - "serde_core", - "windows-link", -] - -[[package]] -name = "jiff" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379ed44bd4e16d3926160e2b3a78b79ca0952ef5c037f124f554842ba272ef92" -dependencies = [ - "jiff-core 1.1.0", - "jiff-static 1.1.0", - "jiff-tzdb-platform 1.0.0", - "log", - "portable-atomic", - "portable-atomic-util", - "serde_core", - "windows-link", -] - -[[package]] -name = "jiff-core" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7feca88439efe53da3754500c1851dedf3cb36c524dd5cf8225cc0794de95d09" -dependencies = [ - "defmt", -] - -[[package]] -name = "jiff-core" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df46fc314b4f458aee614afcd8676ed6cb3637413aa359d47d2646cbc038b79" -dependencies = [ - "log", -] - -[[package]] -name = "jiff-static" -version = "0.2.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a69dcb3a21cfb32ce1cd056169337ca284af0766dd766e7878819b251a49204" -dependencies = [ - "jiff-core 0.1.0", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "jiff-static" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b729c549d3efb5855b3c80b0ee8ee1850d56330a127382fe2760965741c1f3" -dependencies = [ - "jiff-core 1.1.0", - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "jiff-tzdb" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142bd39932ad231f10513df9ab62661fead8719872150b7ad02a2df79f4e141e" - -[[package]] -name = "jiff-tzdb" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e71a1b68a875a44a33bb7a1dd84392cb77145a3367a552a3cfe6a4f5cf3afc" - -[[package]] -name = "jiff-tzdb-platform" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" -dependencies = [ - "jiff-tzdb 0.1.8", -] - -[[package]] -name = "jiff-tzdb-platform" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc65b284afcfa8f6cf189c7274c805505314a7ab975c60e1f548bff56525420e" -dependencies = [ - "jiff-tzdb 1.0.0", -] - -[[package]] -name = "jobserver" -version = "0.1.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" -dependencies = [ - "getrandom 0.4.3", - "libc", -] - -[[package]] -name = "js-sys" -version = "0.3.105" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e" -dependencies = [ - "cfg-if", - "futures-util", - "wasm-bindgen", -] - -[[package]] -name = "k12" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38a8cc72399dffa4a445bc5f5a84d4af4d441c76604231bc52e9c529c1d47693" -dependencies = [ - "digest 0.11.3", - "keccak 0.2.2", - "sponge-cursor", -] - -[[package]] -name = "kasuari" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde5057d6143cc94e861d90f591b9303d6716c6b9602309150bd068853c10899" -dependencies = [ - "hashbrown 0.16.1", - "portable-atomic", - "thiserror 2.0.20", -] - -[[package]] -name = "keccak" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb26cec98cce3a3d96cbb7bced3c4b16e3d13f27ec56dbd62cbc8f39cfb9d653" -dependencies = [ - "cpufeatures 0.2.17", -] - -[[package]] -name = "keccak" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f198d1db720e4940b5a493201d199d9f24f568f8f746bd13706243a2f71598" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "hybrid-array", -] - -[[package]] -name = "kem" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01737161ba802849cfd486b5bd209d38ba4943494c249a8126005170c7621edd" -dependencies = [ - "crypto-common 0.2.2", - "rand_core 0.10.1", -] - -[[package]] -name = "konst" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128133ed7824fcd73d6e7b17957c5eb7bacb885649bd8c69708b2331a10bcefb" -dependencies = [ - "konst_macro_rules", -] - -[[package]] -name = "konst_macro_rules" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37" - -[[package]] -name = "kqueue" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d763e5b24120b4ddf50de6c92308156765aabfbbccebf401da7cff2d70a41ea" -dependencies = [ - "kqueue-sys", - "libc", -] - -[[package]] -name = "kqueue-sys" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07293a4e297ac234359b510362495713f75ea345d5307140414f20c69ffeb087" -dependencies = [ - "bitflags 2.13.2", - "libc", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin 0.9.9", -] - -[[package]] -name = "libc" -version = "0.2.189" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" - -[[package]] -name = "liblzma" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fe0a34ca854fd4f20c07f696fc8675aec78f87d88d29f5e10257a7490a1b2e1" -dependencies = [ - "liblzma-sys", -] - -[[package]] -name = "liblzma-sys" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0dad045e4b1b7b170be4b60b54b780cafb4490165461bac7d1cf7b703f61d5f" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - -[[package]] -name = "libm" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" - -[[package]] -name = "libredox" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d8f1ea3f21fd3405dcaf6c9b5c1630af9afc422d9073ea39c5f6d6c772e08ed" -dependencies = [ - "libc", -] - -[[package]] -name = "libsqlite3-sys" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91632f3b4fb6bd1d72aa3d78f41ffecfcf2b1a6648d8c241dbe7dbfaf4875e15" -dependencies = [ - "cc", - "openssl-sys", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "line-clipping" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e752191d037c44ad111a8caa762921926658402f01cc1253f7bef2020ece4f5e" -dependencies = [ - "bitflags 2.13.2", -] - -[[package]] -name = "linux-raw-sys" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" - -[[package]] -name = "litemap" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" - -[[package]] -name = "litrs" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" - -[[package]] -name = "lock_api" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" - -[[package]] -name = "lru" -version = "0.18.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff9840bcc50b71349309900da0ce7279aa336ae71d73250b07998932c7d97c25" -dependencies = [ - "hashbrown 0.17.1", -] - -[[package]] -name = "lsm-tree" -version = "3.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5498808f4d41cf785079d3ef3f28716f1b4364af1b512f3097bfb651bded1b3e" -dependencies = [ - "byteorder-lite", - "byteview", - "crossbeam-skiplist", - "enum_dispatch", - "interval-heap", - "log", - "lz4_flex", - "quick_cache", - "rustc-hash", - "self_cell", - "sfa", - "tempfile", - "varint-rs", - "xxhash-rust", -] - -[[package]] -name = "lz4_flex" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef0d4ed8669f8f8826eb00dc878084aa8f253506c4fd5e8f58f5bce72ddb97e" -dependencies = [ - "twox-hash", -] - -[[package]] -name = "matchit" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" - -[[package]] -name = "md-5" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" -dependencies = [ - "cfg-if", - "digest 0.10.7", -] - -[[package]] -name = "memchr" -version = "2.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" - -[[package]] -name = "memmap2" -version = "0.9.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" -dependencies = [ - "libc", -] - -[[package]] -name = "metrics" -version = "0.24.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89550ee9f79e88fef3119de263694973a8adb26c21d75322164fb8c493039fe2" -dependencies = [ - "portable-atomic", - "rapidhash", -] - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "miniz_oxide" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" -dependencies = [ - "adler2", - "simd-adler32", -] - -[[package]] -name = "mio" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b18443e9c262bfe8fa82f51666e2642c53393f7e5c27b3e1aeab922cff5b9d8" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.61.2", -] - -[[package]] -name = "ml-kem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ba01ebcf90f6aff8e9b9f55bb69b19e6250e4ade5787d0040eaa27dd226238" -dependencies = [ - "hybrid-array", - "kem", - "module-lattice", - "pkcs8 0.11.0", - "rand_core 0.10.1", - "sha3 0.12.0", - "shake", - "zeroize", -] - -[[package]] -name = "module-lattice" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c61b87c9683ab7cb1c6871d261ad5479b6b10ceb52c4352aaca3b5d35a8febe" -dependencies = [ - "ctutils", - "hybrid-array", - "num-traits", - "zeroize", -] - -[[package]] -name = "monero-address" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "monero-base58", - "monero-ed25519", - "monero-io", - "monero-primitives", - "thiserror 2.0.20", - "zeroize", -] - -[[package]] -name = "monero-base58" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "monero-primitives", - "std-shims", -] - -[[package]] -name = "monero-borromean" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "monero-ed25519", - "monero-io", - "std-shims", - "zeroize", -] - -[[package]] -name = "monero-bulletproofs" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "monero-bulletproofs-generators", - "monero-ed25519", - "monero-io", - "monero-primitives", - "rand_core 0.6.4", - "std-shims", - "thiserror 2.0.20", - "zeroize", -] - -[[package]] -name = "monero-bulletproofs-generators" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "monero-ed25519", - "monero-io", - "monero-primitives", - "std-shims", -] - -[[package]] -name = "monero-clsag" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "group", - "monero-ed25519", - "monero-io", - "rand_chacha 0.3.1", - "rand_core 0.6.4", - "std-shims", - "subtle", - "thiserror 2.0.20", - "zeroize", -] - -[[package]] -name = "monero-ed25519" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "crypto-bigint 0.5.5", - "curve25519-dalek 4.1.3", - "monero-io", - "rand_core 0.6.4", - "sha3 0.10.9", - "std-shims", - "subtle", - "zeroize", -] - -[[package]] -name = "monero-io" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "std-shims", -] - -[[package]] -name = "monero-mlsag" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "monero-ed25519", - "monero-io", - "std-shims", - "thiserror 2.0.20", - "zeroize", -] - -[[package]] -name = "monero-oxide" -version = "0.1.4-alpha" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "curve25519-dalek 4.1.3", - "hex-literal 1.1.0", - "monero-borromean", - "monero-bulletproofs", - "monero-clsag", - "monero-ed25519", - "monero-io", - "monero-mlsag", - "monero-primitives", - "std-shims", - "zeroize", -] - -[[package]] -name = "monero-primitives" -version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" -dependencies = [ - "sha3 0.10.9", -] - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "nonany" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6b8866ec53810a9a4b3d434a29801e78c707430a9ae11c2db4b8b62bb9675a0" - -[[package]] -name = "notify" -version = "8.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3" -dependencies = [ - "bitflags 2.13.2", - "inotify", - "kqueue", - "libc", - "log", - "mio", - "notify-types", - "walkdir", - "windows-sys 0.60.2", -] - -[[package]] -name = "notify-types" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42b8cfee0e339a0337359f3c88165702ac6e600dc01c0cc9579a92d62b08477a" -dependencies = [ - "bitflags 2.13.2", -] - -[[package]] -name = "ntapi" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae" -dependencies = [ - "winapi", -] - -[[package]] -name = "nu-ansi-term" -version = "0.50.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" -dependencies = [ - "windows-sys 0.61.2", -] - -[[package]] -name = "num-bigint" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-bigint-dig" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" -dependencies = [ - "lazy_static", - "libm", - "num-integer", - "num-iter", - "num-traits", - "rand 0.8.8", - "smallvec", - "zeroize", -] - -[[package]] -name = "num-conv" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" - -[[package]] -name = "num-integer" -version = "0.1.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", - "libm", -] - -[[package]] -name = "num_enum" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" -dependencies = [ - "num_enum_derive", - "rustversion", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "num_threads" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" -dependencies = [ - "libc", -] - -[[package]] -name = "objc2-core-foundation" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" -dependencies = [ - "bitflags 2.13.2", -] - -[[package]] -name = "objc2-io-kit" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" -dependencies = [ - "libc", - "objc2-core-foundation", -] - -[[package]] -name = "once_cell" -version = "1.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" - -[[package]] -name = "oneshot-fused-workaround" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f851210432a7498257e0f1675c25b95131308f157b87821b70df756b01aa1dbc" -dependencies = [ - "futures", -] - -[[package]] -name = "onionwire" -version = "0.2.1" -dependencies = [ - "argon2", - "arti-client", - "chacha20poly1305", - "cuprated", - "ed25519-dalek 2.2.0", - "futures", - "hkdf 0.12.4", - "hmac 0.12.1", - "md-5", - "ml-kem", - "qrcode", - "rand 0.8.8", - "ratatui", - "rpassword", - "rusqlite", - "rustls", - "safelog", - "serde_json", - "sha2 0.10.9", - "sha3 0.10.9", - "snow", - "tokio", - "toml 0.8.23", - "tor-cell", - "tor-hsservice", - "tor-rtcompat", - "x25519-dalek 2.0.1", - "zeroize", -] - -[[package]] -name = "onionwire-sdk" -version = "0.1.0" -dependencies = [ - "arti-client", - "onionwire", - "rustls", - "thiserror 2.0.20", - "tokio", - "uniffi", -] - -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - -[[package]] -name = "openssl-src" -version = "300.6.1+3.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46eb8fb9fb3b61ce1c0f8a026c4c1a0714d3a9e138e7fbde78753ce2babc3846" -dependencies = [ - "cc", -] - -[[package]] -name = "openssl-sys" -version = "0.9.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" -dependencies = [ - "cc", - "libc", - "openssl-src", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - -[[package]] -name = "ordered-float" -version = "2.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" -dependencies = [ - "num-traits", -] - -[[package]] -name = "os_str_bytes" -version = "6.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" -dependencies = [ - "memchr", -] - -[[package]] -name = "p256" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" -dependencies = [ - "ecdsa", - "elliptic-curve", - "primeorder", - "sha2 0.10.9", -] - -[[package]] -name = "p384" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe42f1670a52a47d448f14b6a5c61dd78fce51856e68edaa38f7ae3a46b8d6b6" -dependencies = [ - "ecdsa", - "elliptic-curve", - "primeorder", - "sha2 0.10.9", -] - -[[package]] -name = "p521" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc9e2161f1f215afdfce23677034ae137bbd45016a880c2eb3ba8eb95f085b2" -dependencies = [ - "base16ct", - "ecdsa", - "elliptic-curve", - "primeorder", - "rand_core 0.6.4", - "sha2 0.10.9", -] - -[[package]] -name = "palette" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddeed8580d347d2abf3dcf06a5f0b3dc020258338526b277847cd4248a70fc64" -dependencies = [ - "approx", - "libm", - "palette_derive", - "palette_math", -] - -[[package]] -name = "palette_derive" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88537020289b719d81be994ccf1bbf4990f477e2f69ee52fe3e45f43a02e56be" -dependencies = [ - "by_address", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "palette_math" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e6eb142958d64335fb0e345c5b9ead2ecd6fc438c307e9d7d3c4fd428dbaf12" -dependencies = [ - "libm", -] - -[[package]] -name = "parking" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" - -[[package]] -name = "parking_lot" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-link", -] - -[[package]] -name = "password-hash" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" -dependencies = [ - "base64ct", - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - -[[package]] -name = "percent-encoding" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" - -[[package]] -name = "phf" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6" -dependencies = [ - "phf_macros", - "phf_shared", - "serde", -] - -[[package]] -name = "phf_generator" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100" -dependencies = [ - "fastrand", - "phf_shared", -] - -[[package]] -name = "phf_macros" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085" -dependencies = [ - "phf_generator", - "phf_shared", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "phf_shared" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89" -dependencies = [ - "siphasher", -] - -[[package]] -name = "pin-project" -version = "1.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" - -[[package]] -name = "pkcs1" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" -dependencies = [ - "der 0.7.10", - "pkcs8 0.10.2", - "spki 0.7.3", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der 0.7.10", - "spki 0.7.3", -] - -[[package]] -name = "pkcs8" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7" -dependencies = [ - "der 0.8.2", - "spki 0.8.1", -] - -[[package]] -name = "pkg-config" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" - -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - -[[package]] -name = "poly1305" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" -dependencies = [ - "cpufeatures 0.2.17", - "opaque-debug", - "universal-hash 0.5.1", -] - -[[package]] -name = "polyval" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" -dependencies = [ - "cfg-if", - "cpufeatures 0.2.17", - "opaque-debug", - "universal-hash 0.5.1", -] - -[[package]] -name = "polyval" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0fa31d631f2b2cb2a544d0aa321ce847a94764d701ca2becc411138b93d49cd" -dependencies = [ - "cpubits", - "cpufeatures 0.3.1", - "universal-hash 0.6.1", -] - -[[package]] -name = "portable-atomic" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" - -[[package]] -name = "portable-atomic-util" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" -dependencies = [ - "portable-atomic", -] - -[[package]] -name = "postage" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af3fb618632874fb76937c2361a7f22afd393c982a2165595407edc75b06d3c1" -dependencies = [ - "atomic 0.5.3", - "crossbeam-queue", - "futures", - "parking_lot", - "pin-project", - "static_assertions", - "thiserror 1.0.69", -] - -[[package]] -name = "potential_utf" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" -dependencies = [ - "zerovec", -] - -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "primeorder" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" -dependencies = [ - "elliptic-curve", -] - -[[package]] -name = "proc-macro-crate" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" -dependencies = [ - "toml_edit 0.25.14+spec-1.1.0", -] - -[[package]] -name = "proc-macro2" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "proptest" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b45fcc2344c680f5025fe57779faef368840d0bd1f42f216291f0dc4ace4744" -dependencies = [ - "bit-set", - "bit-vec", - "bitflags 2.13.2", - "num-traits", - "rand 0.9.5", - "rand_chacha 0.9.0", - "rand_xorshift", - "regex-syntax", - "rusty-fork", - "tempfile", - "unarray", -] - -[[package]] -name = "proptest-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c57924a81864dddafba92e1bf92f9bf82f97096c44489548a60e888e1547549b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "pwd-grp" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e2023f41b5fcb7c30eb5300a5733edfaa9e0e0d502d51b586f65633fd39e40c" -dependencies = [ - "derive-deftly", - "libc", - "paste", - "thiserror 2.0.20", -] - -[[package]] -name = "qrcode" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68782463e408eb1e668cf6152704bd856c78c5b6417adaee3203d8f4c1fc9ec" - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quick_cache" -version = "0.6.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9c6658afe513a3b484e3abfdaa0d03ef3c0bbf017542c178dd55f94eb3051f9" -dependencies = [ - "equivalent", - "hashbrown 0.16.1", -] - -[[package]] -name = "quote" -version = "1.0.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - -[[package]] -name = "r-efi" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" -dependencies = [ - "rand_chacha 0.9.0", - "rand_core 0.9.5", -] - -[[package]] -name = "rand" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" -dependencies = [ - "chacha20 0.10.2", - "getrandom 0.4.3", - "rand_core 0.10.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" -dependencies = [ - "ppv-lite86", - "rand_core 0.9.5", -] - -[[package]] -name = "rand_chacha" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e6af7f3e25ded52c41df4e0b1af2d047e45896c2f3281792ed68a1c243daedb" -dependencies = [ - "ppv-lite86", - "rand_core 0.10.1", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.17", -] - -[[package]] -name = "rand_core" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" -dependencies = [ - "getrandom 0.3.4", -] - -[[package]] -name = "rand_core" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" - -[[package]] -name = "rand_distr" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" -dependencies = [ - "num-traits", - "rand 0.8.8", -] - -[[package]] -name = "rand_jitter" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdcd80e68f0a8f9ca5ec7cfd02fd5fbb8fbe6ef4e9b90ea2f48bb929b74f88e" -dependencies = [ - "libc", - "rand_core 0.10.1", - "windows-sys 0.59.0", -] - -[[package]] -name = "rand_xorshift" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" -dependencies = [ - "rand_core 0.9.5", -] - -[[package]] -name = "randomx-rs" -version = "1.4.1" -source = "git+https://github.com/Cuprate/randomx-rs.git?rev=76c2385#76c2385771ca5aca941e0991ebd822e6edb8d94d" -dependencies = [ - "bitflags 1.3.2", - "cc", - "cmake", - "libc", - "thiserror 1.0.69", -] - -[[package]] -name = "rangemap" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d" - -[[package]] -name = "rapidhash" -version = "4.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da7e78a036ce858e8d55b7e7dc8ba3a88b78350fd2155d3591bbd966b58589e" -dependencies = [ - "rustversion", -] - -[[package]] -name = "ratatui" -version = "0.30.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3274ba0a2c5e1bcad2a2005d20f4dc59dad26b2eb0940fb094500dba4099d57d" -dependencies = [ - "instability", - "ratatui-core", - "ratatui-crossterm", - "ratatui-widgets", - "serde", -] - -[[package]] -name = "ratatui-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbb175c433c8e28a809d1f5773a2ae96e68c0ce40db865cbab1020bf33ae479c" -dependencies = [ - "bitflags 2.13.2", - "compact_str", - "hashbrown 0.17.1", - "itertools 0.14.0", - "kasuari", - "lru", - "palette", - "serde", - "strum", - "thiserror 2.0.20", - "unicode-segmentation", - "unicode-truncate", - "unicode-width", -] - -[[package]] -name = "ratatui-crossterm" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567584a3b0e6a8203c23de40b4861497266725eb5363dbfd18a1edd603cca9f0" -dependencies = [ - "cfg-if", - "crossterm", - "instability", - "ratatui-core", -] - -[[package]] -name = "ratatui-widgets" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66e3d19bcc9130ca376277d93b60767ff121ace3be06f5f95f81dd68956407d1" -dependencies = [ - "bitflags 2.13.2", - "hashbrown 0.17.1", - "indoc", - "instability", - "itertools 0.14.0", - "line-clipping", - "ratatui-core", - "serde", - "strum", - "time", - "unicode-segmentation", - "unicode-width", -] - -[[package]] -name = "rayon" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - -[[package]] -name = "rdrand" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84448986e59427c795b929d8dbe12d176275c7d0887ee48098c35b7206f51bae" -dependencies = [ - "libc", - "rand_core 0.10.1", -] - -[[package]] -name = "redox_syscall" -version = "0.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" -dependencies = [ - "bitflags 2.13.2", -] - -[[package]] -name = "redox_users" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" -dependencies = [ - "getrandom 0.2.17", - "libredox", - "thiserror 2.0.20", -] - -[[package]] -name = "ref-cast" -version = "1.0.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "regex" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" - -[[package]] -name = "reseeding_rng" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecfc8e855ab517235426ec1290bfb0745e73fa478b29619eb66a2a81be9d8716" -dependencies = [ - "rand_core 0.10.1", -] - -[[package]] -name = "retry-error" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67f26b5caa81adf9b23ab230ce975acbf46aec461bc357f9fb51cfd4f2bfaebf" -dependencies = [ - "humantime", - "web-time", -] - -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac 0.12.1", - "subtle", -] - -[[package]] -name = "ring" -version = "0.17.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" -dependencies = [ - "cc", - "cfg-if", - "getrandom 0.2.17", - "libc", - "untrusted", - "windows-sys 0.52.0", -] - -[[package]] -name = "rpassword" -version = "7.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da316a15f47e3d053de9cb2c439650bd8fa4aaeb9365f2e5f27f492ff73c196" -dependencies = [ - "libc", - "rtoolbox", - "windows-sys 0.61.2", -] - -[[package]] -name = "rsa" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" -dependencies = [ - "const-oid 0.9.6", - "digest 0.10.7", - "num-bigint-dig", - "num-integer", - "num-traits", - "pkcs1", - "pkcs8 0.10.2", - "rand_core 0.6.4", - "sha2 0.10.9", - "signature 2.2.0", - "spki 0.7.3", - "subtle", - "zeroize", -] - -[[package]] -name = "rtoolbox" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1efe12a1469752d0e6ff5ebec0b6ef4924cc5c4c71046b0ec730040535819d" -dependencies = [ - "libc", - "windows-sys 0.61.2", -] - -[[package]] -name = "rusqlite" -version = "0.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3de23c3319433716cf134eed225fe9986bc24f63bed9be9f20c329029e672dc7" -dependencies = [ - "bitflags 2.13.2", - "fallible-iterator", - "fallible-streaming-iterator", - "hashlink", - "libsqlite3-sys", - "smallvec", - "time", -] - -[[package]] -name = "rustc-hash" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "rusticata-macros" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" -dependencies = [ - "nom", -] - -[[package]] -name = "rustix" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" -dependencies = [ - "bitflags 2.13.2", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.61.2", -] - -[[package]] -name = "rustls" -version = "0.23.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" -dependencies = [ - "log", - "once_cell", - "ring", - "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", -] - -[[package]] -name = "rustls-pki-types" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" -dependencies = [ - "zeroize", -] - -[[package]] -name = "rustls-webpki" -version = "0.103.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - -[[package]] -name = "rustversion" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" - -[[package]] -name = "rusty-fork" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6bf79ff24e648f6da1f8d1f011e9cac26491b619e6b9280f2b47f1774e6ee2" -dependencies = [ - "fnv", - "quick-error", - "tempfile", - "wait-timeout", -] - -[[package]] -name = "ryu" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" - -[[package]] -name = "safelog" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c090399e87e5eaec9515d6b859fdb7ec417c269c2e7564c169a8963df75a2ce" -dependencies = [ - "derive_more", - "educe", - "either", - "fluid-let", - "thiserror 2.0.20", -] - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "sanitize-filename" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc984f4f9ceb736a7bb755c3e3bd17dc56370af2600c9780dcc48c66453da34d" -dependencies = [ - "regex", -] - -[[package]] -name = "saturating-time" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950f7f265dc6fc082387eccf710b1adbf22d75f17c4ee0db4648c9b6959b50d" -dependencies = [ - "web-time-compat", -] - -[[package]] -name = "schemars" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - -[[package]] -name = "schemars" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "687274d293b6cdc6e73e0fee520bf2049650090d7164f87672d212a3c530cf4a" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "scroll" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6" -dependencies = [ - "scroll_derive", -] - -[[package]] -name = "scroll_derive" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1783eabc414609e28a5ba76aee5ddd52199f7107a0b24c2e9746a1ecc34a683d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der 0.7.10", - "generic-array", - "pkcs8 0.10.2", - "subtle", - "zeroize", -] - -[[package]] -name = "self_cell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" - -[[package]] -name = "semver" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" -dependencies = [ - "serde", - "serde_core", -] - -[[package]] -name = "seq-macro" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" - -[[package]] -name = "serde" -version = "1.0.229" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" -dependencies = [ - "serde_core", - "serde_derive", -] - -[[package]] -name = "serde-value" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" -dependencies = [ - "ordered-float", - "serde", -] - -[[package]] -name = "serde_bytes" -version = "0.11.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8" -dependencies = [ - "serde", - "serde_core", -] - -[[package]] -name = "serde_core" -version = "1.0.229" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.229" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "serde_ignored" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115dffd5f3853e06e746965a20dcbae6ee747ae30b543d91b0e089668bb07798" -dependencies = [ - "serde", - "serde_core", -] - -[[package]] -name = "serde_json" -version = "1.0.154" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" -dependencies = [ - "itoa", - "memchr", - "serde", - "serde_core", - "zmij", -] - -[[package]] -name = "serde_path_to_error" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" -dependencies = [ - "itoa", - "serde", - "serde_core", -] - -[[package]] -name = "serde_spanned" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_spanned" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782" -dependencies = [ - "serde_core", -] - -[[package]] -name = "serde_with" -version = "3.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56cb1ca7c93ae63d6439b5250f6b6b040f7e121f32e5dd2f5d523dd4149b3204" -dependencies = [ - "base64", - "bs58", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.14.2", - "jiff 0.2.35", - "jiff 1.1.0", - "schemars 0.9.0", - "schemars 1.2.2", - "serde_core", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff15a7c864bbec77d9586ca6822bc7c369bdf19e9243134a62b0b51ce26b31f" -dependencies = [ - "darling 0.24.1", - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "sfa" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1296838937cab56cd6c4eeeb8718ec777383700c33f060e2869867bd01d1175" -dependencies = [ - "byteorder-lite", - "log", - "xxhash-rust", -] - -[[package]] -name = "sha1" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "digest 0.11.3", -] - -[[package]] -name = "sha2" -version = "0.10.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" -dependencies = [ - "cfg-if", - "cpufeatures 0.2.17", - "digest 0.10.7", -] - -[[package]] -name = "sha2" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "820083d430c52864bf834423fc988cbcf61685d6f9d22a765a64e3f6cfe3521c" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "digest 0.11.3", -] - -[[package]] -name = "sha3" -version = "0.10.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77fd7028345d415a4034cf8777cd4f8ab1851274233b45f84e3d955502d93874" -dependencies = [ - "digest 0.10.7", - "keccak 0.1.6", -] - -[[package]] -name = "sha3" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9bad02c26382724b2d2692c6f179285e4b54eeecd7968f52a50059c3c11759" -dependencies = [ - "digest 0.11.3", - "keccak 0.2.2", - "sponge-cursor", -] - -[[package]] -name = "shake" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09057cb2149ad4cbd2da1e26b351f9a4c354219421229c69c3063e6f61947c4a" -dependencies = [ - "digest 0.11.3", - "keccak 0.2.2", - "sponge-cursor", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "shellexpand" -version = "3.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32824fab5e16e6c4d86dc1ba84489390419a39f97699852b66480bb87d297ed8" -dependencies = [ - "bstr", - "dirs 6.0.0", - "os_str_bytes", -] - -[[package]] -name = "shlex" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" - -[[package]] -name = "signal-hook" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" -dependencies = [ - "libc", - "signal-hook-registry", -] - -[[package]] -name = "signal-hook-mio" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc" -dependencies = [ - "libc", - "mio", - "signal-hook", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" -dependencies = [ - "errno", - "libc", -] - -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - -[[package]] -name = "signature" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" -dependencies = [ - "rand_core 0.10.1", -] - -[[package]] -name = "simd-adler32" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" - -[[package]] -name = "siphasher" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" - -[[package]] -name = "skein" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96a90a220ab98dbbfeabeae7c558a79f37839c10b9ef55c77082a741a463cab7" -dependencies = [ - "digest 0.10.7", - "threefish", -] - -[[package]] -name = "slab" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" - -[[package]] -name = "slotmap" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" -dependencies = [ - "serde", - "version_check", -] - -[[package]] -name = "slotmap-careful" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e13aa7333b92ad3a6d3136abaa7fb5d8c19cc121441fcb435f6947d6ef2f8f7" -dependencies = [ - "paste", - "serde", - "slotmap", - "thiserror 2.0.20", -] - -[[package]] -name = "smallvec" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9be42f50aa861c555654aa3a37f52f4b1074bacf4e48fe0ef7fa584e80f1f0f" - -[[package]] -name = "smawk" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e2fb0f499abb4d162f2bedad68f5ef91a1682b5a03596ddb67efd37768d100" - -[[package]] -name = "snow" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599b506ccc4aff8cf7844bc42cf783009a434c1e26c964432560fb6d6ad02d82" -dependencies = [ - "aes-gcm", - "blake2", - "chacha20poly1305", - "curve25519-dalek 4.1.3", - "getrandom 0.3.4", - "ring", - "rustc_version", - "sha2 0.10.9", - "subtle", -] - -[[package]] -name = "socket2" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" -dependencies = [ - "libc", - "windows-sys 0.61.2", -] - -[[package]] -name = "spin" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spin" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "023a211cb3138dbc438680b32560ad89f699977624c9f8dbb95a47d5b4c07dd3" - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der 0.7.10", -] - -[[package]] -name = "spki" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef958a98b9d5da290cfc78946e9f3e61e1e62a18db0d92cac0b83cc161491a9" -dependencies = [ - "base64ct", - "der 0.8.2", -] - -[[package]] -name = "sponge-cursor" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a0219bd7d979d58245a4f41f695e1ac9f8befdffadd7f61f1bae9e39abc6620" - -[[package]] -name = "ssh-cipher-fork-arti" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125c5795103fc93fced42d123c8044180afc55469caa1ab56487c3c5543c898d" -dependencies = [ - "cipher 0.4.4", - "ssh-encoding-fork-arti", -] - -[[package]] -name = "ssh-encoding-fork-arti" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cf03c3a7ea88451ff83a129a79451fd9891d44fc76c25e916a11848b81814c" -dependencies = [ - "base64ct", - "pem-rfc7468", - "sha2 0.10.9", -] - -[[package]] -name = "ssh-key-fork-arti" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433782176b73ea7907763dc314c4a17438a231864d4aa683ba47c07c1cf0a388" -dependencies = [ - "num-bigint-dig", - "p256", - "p384", - "p521", - "rand_core 0.6.4", - "rsa", - "sec1", - "sha2 0.10.9", - "signature 2.2.0", - "ssh-cipher-fork-arti", - "ssh-encoding-fork-arti", - "subtle", - "zeroize", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "std-shims" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "227c4f8561598188d0df96dbe749824576174bba278b5b6bb2eacff1066067d0" -dependencies = [ - "hashbrown 0.16.1", - "rustversion", - "spin 0.10.1", -] - -[[package]] -name = "strobe-rs" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83561175f0a962dea437885589480d216d8741debf853e0d36edd526344fd273" -dependencies = [ - "bitflags 2.13.2", - "byteorder", - "keccak 0.2.2", - "subtle", - "zeroize", -] - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "strum" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - -[[package]] -name = "symlink" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.119" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "3.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "sync_wrapper" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" - -[[package]] -name = "synstructure" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "synstructure" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "sysinfo" -version = "0.38.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ab6a2f8bfe508deb3c6406578252e491d299cbbf3bc0529ecc3313aee4a52f" -dependencies = [ - "libc", - "memchr", - "ntapi", - "objc2-core-foundation", - "objc2-io-kit", - "windows", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "tapes" -version = "0.2.0" -source = "git+https://github.com/Cuprate/Tapes.git?rev=04562f4#04562f44fd8e029ce0caf7dfa993682ffe69837d" -dependencies = [ - "blake2", - "borsh", - "bytemuck", - "parking_lot", - "slab", -] - -[[package]] -name = "tempfile" -version = "3.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" -dependencies = [ - "fastrand", - "getrandom 0.4.3", - "once_cell", - "rustix", - "windows-sys 0.61.2", -] - -[[package]] -name = "terminal_size" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" -dependencies = [ - "rustix", - "windows-sys 0.61.2", -] - -[[package]] -name = "textwrap" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b81c0cb5fce14f53e49c1d4da0c508334ff12040221bb8ab01b2dabd91d04b6e" -dependencies = [ - "smawk", - "unicode-width", -] - -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl 1.0.69", -] - -[[package]] -name = "thiserror" -version = "2.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" -dependencies = [ - "thiserror-impl 2.0.20", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "thread_local" -version = "1.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "threefish" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a693d0c8cf16973fac5a93fbe47b8c6452e7097d4fcac49f3d7a18e39c76e62e" - -[[package]] -name = "time" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" -dependencies = [ - "deranged", - "libc", - "num-conv", - "num_threads", - "powerfmt", - "serde_core", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" - -[[package]] -name = "time-macros" -version = "0.2.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" -dependencies = [ - "num-conv", - "time-core", -] - -[[package]] -name = "tinystr" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" -dependencies = [ - "displaydoc", - "serde_core", - "zerovec", -] - -[[package]] -name = "tinyvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf0ded5c4e56918d8f8a339e1bb67d038d3bc6d144ac407904015ba2e4cde9b" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.54.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" -dependencies = [ - "bytes", - "libc", - "mio", - "parking_lot", - "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "windows-sys 0.61.2", -] - -[[package]] -name = "tokio-macros" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "tokio-socks" -version = "0.5.2" -source = "git+https://github.com/Cuprate/tokio-socks.git?rev=8737caf#8737caf429a86ab181954444fac4f9b917795b19" -dependencies = [ - "either", - "futures-util", - "thiserror 1.0.69", - "tokio", -] - -[[package]] -name = "tokio-stream" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d06f0b082ba57c26b79407372e57cf2a1e28124f78e9479fe80322cf53420b" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", - "tokio-util", -] - -[[package]] -name = "tokio-util" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e464cf451ba96ebfc6f9b6542f17ee8b8956e33f1e40d9690624e59d7a7f8a4b" -dependencies = [ - "bytes", - "futures-core", - "futures-io", - "futures-sink", - "futures-util", - "libc", - "pin-project-lite", - "slab", - "tokio", - "tracing", -] - -[[package]] -name = "toml" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" -dependencies = [ - "serde", - "serde_spanned 0.6.9", - "toml_datetime 0.6.11", - "toml_edit 0.22.27", -] - -[[package]] -name = "toml" -version = "1.2.3+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b1f26e9485c1fa43ee89fe76e9f3fb9e2e52bb227f8594b4d687496b83d073" -dependencies = [ - "indexmap 2.14.2", - "serde_core", - "serde_spanned 1.1.3", - "toml_datetime 1.1.3+spec-1.1.0", - "toml_parser", - "toml_writer", - "winnow 1.0.4", -] - -[[package]] -name = "toml_datetime" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_datetime" -version = "1.1.3+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" -dependencies = [ - "serde_core", -] - -[[package]] -name = "toml_edit" -version = "0.22.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" -dependencies = [ - "indexmap 2.14.2", - "serde", - "serde_spanned 0.6.9", - "toml_datetime 0.6.11", - "toml_write", - "winnow 0.7.15", -] - -[[package]] -name = "toml_edit" -version = "0.25.14+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2195eec204e2764644a4ea619704f9fbe5e0673038eded55ad9956f24fca0cc" -dependencies = [ - "indexmap 2.14.2", - "toml_datetime 1.1.3+spec-1.1.0", - "toml_parser", - "toml_writer", - "winnow 1.0.4", -] - -[[package]] -name = "toml_parser" -version = "1.1.7+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb28d6e049a9766c3bd91a8326e6179f5b132dec87906bb97018ef7a2f3431a" -dependencies = [ - "winnow 1.0.4", -] - -[[package]] -name = "toml_write" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" - -[[package]] -name = "toml_writer" -version = "1.2.0+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a" - -[[package]] -name = "tor-async-utils" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea51881be51a4dff308071d7cf6489445fd658e821a8bf35c47a4830effd1ab" -dependencies = [ - "cfg-if", - "derive-deftly", - "educe", - "extend", - "futures", - "oneshot-fused-workaround", - "pin-project", - "postage", - "slotmap-careful", - "sync_wrapper", - "thiserror 2.0.20", - "tokio", - "tokio-util", - "tor-basic-utils", - "tor-rtcompat", - "tracing", - "void", - "web-time-compat", -] - -[[package]] -name = "tor-basic-utils" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235993fcf72e09e597e6b609d52b4cfc2f28bfa8ca827ed304127889639d5776" -dependencies = [ - "derive-deftly", - "derive_more", - "educe", - "extend", - "getrandom 0.4.3", - "hex", - "itertools 0.15.0", - "libc", - "paste", - "rand 0.10.4", - "rand_chacha 0.10.0", - "serde", - "slab", - "smallvec", - "thiserror 2.0.20", - "tracing", - "weak-table", - "web-time-compat", -] - -[[package]] -name = "tor-bytes" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb3c0504ae2bca19b92e55c869fe58f68688505737ce2ddae85b60b9806ed4c" -dependencies = [ - "bytes", - "derive-deftly", - "digest 0.11.3", - "educe", - "getrandom 0.4.3", - "safelog", - "thiserror 2.0.20", - "tor-error", - "tor-llcrypto", - "zeroize", -] - -[[package]] -name = "tor-cell" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6a814400b9bd2a8d07ee89057db816eed53b2b2719066f77630698f0bd2cb0" -dependencies = [ - "amplify", - "bitflags 2.13.2", - "bytes", - "caret", - "derive-deftly", - "derive_more", - "educe", - "itertools 0.15.0", - "paste", - "rand 0.10.4", - "smallvec", - "thiserror 2.0.20", - "tor-basic-utils", - "tor-bytes", - "tor-cert", - "tor-error", - "tor-hscrypto", - "tor-linkspec", - "tor-llcrypto", - "tor-memquota", - "tor-protover", - "tor-units", - "void", -] - -[[package]] -name = "tor-cert" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68df0747b5d218cfb2c481b2a267bbdbf89dda2849911630e966eed3dc630f7b" -dependencies = [ - "caret", - "derive_builder_fork_arti", - "derive_more", - "digest 0.11.3", - "thiserror 2.0.20", - "tor-bytes", - "tor-checkable", - "tor-error", - "tor-llcrypto", - "web-time-compat", -] - -[[package]] -name = "tor-chanmgr" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b5dec2bf27e75dd65bfe9289f24eee230c49ac4a65f85f0ead3b3b3c19f51d" -dependencies = [ - "async-trait", - "base64ct", - "caret", - "cfg-if", - "derive-deftly", - "derive_more", - "educe", - "futures", - "httparse", - "oneshot-fused-workaround", - "percent-encoding", - "postage", - "rand 0.10.4", - "safelog", - "serde", - "serde_with", - "thiserror 2.0.20", - "tor-async-utils", - "tor-basic-utils", - "tor-cell", - "tor-config", - "tor-error", - "tor-keymgr", - "tor-linkspec", - "tor-llcrypto", - "tor-memquota", - "tor-netdir", - "tor-proto", - "tor-rtcompat", - "tor-socksproto", - "tor-units", - "tracing", - "url", - "void", - "web-time-compat", -] - -[[package]] -name = "tor-checkable" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee5237cfbec5e4e7860b6579932072e2dd3dfa91a950a3d2c4c8c253f405c4a" -dependencies = [ - "humantime", - "itertools 0.15.0", - "signature 3.0.0", - "thiserror 2.0.20", - "tor-llcrypto", - "web-time-compat", -] - -[[package]] -name = "tor-circmgr" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bead875b0e3876110dbfa584ea65af47ed44ebc7ffebb32c460723837aa4843" -dependencies = [ - "amplify", - "async-trait", - "cfg-if", - "derive-deftly", - "derive_builder_fork_arti", - "derive_more", - "downcast-rs", - "dyn-clone", - "educe", - "futures", - "humantime-serde", - "itertools 0.15.0", - "once_cell", - "oneshot-fused-workaround", - "pin-project", - "rand 0.10.4", - "retry-error", - "safelog", - "serde", - "thiserror 2.0.20", - "tor-async-utils", - "tor-basic-utils", - "tor-cell", - "tor-chanmgr", - "tor-config", - "tor-dircommon", - "tor-error", - "tor-guardmgr", - "tor-linkspec", - "tor-memquota", - "tor-netdir", - "tor-netdoc", - "tor-persist", - "tor-proto", - "tor-protover", - "tor-relay-selection", - "tor-rtcompat", - "tor-units", - "tracing", - "void", - "weak-table", - "web-time-compat", -] - -[[package]] -name = "tor-config" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9788a9af2a0303e4c05a9bdbf08efbba485c4e92978f140713bc5e201f14580" -dependencies = [ - "amplify", - "cfg-if", - "derive-deftly", - "derive_builder_fork_arti", - "educe", - "either", - "extend", - "figment", - "fs-mistrust", - "futures", - "humantime-serde", - "itertools 0.15.0", - "notify", - "paste", - "postage", - "regex", - "serde", - "serde-value", - "serde_ignored", - "strum", - "thiserror 2.0.20", - "toml 1.2.3+spec-1.1.0", - "tor-basic-utils", - "tor-error", - "tor-rtcompat", - "tracing", - "void", -] - -[[package]] -name = "tor-config-path" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d165d5b36b7518e8cf0a51a9ed831019cf9d02afd88b408f2ca8d922710565" -dependencies = [ - "directories", - "serde", - "shellexpand", - "thiserror 2.0.20", - "tor-error", - "tor-general-addr", -] - -[[package]] -name = "tor-consdiff" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "543cd2e0796c7959fe89a2c264ea09ebbb0d1bb70ce4870a2b394ee8d099bbea" -dependencies = [ - "derive_more", - "digest 0.11.3", - "hex", - "imara-diff", - "static_assertions", - "thiserror 2.0.20", - "tor-error", - "tor-llcrypto", - "tor-netdoc", -] - -[[package]] -name = "tor-dirclient" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d683861c37ff8c0c522c5cdfed94a8f43d8c07fc9ae6ce3622ca29ec1b76db2" -dependencies = [ - "async-compression", - "base64ct", - "derive_more", - "futures", - "hex", - "http", - "httparse", - "httpdate", - "itertools 0.15.0", - "thiserror 2.0.20", - "tor-circmgr", - "tor-error", - "tor-hscrypto", - "tor-linkspec", - "tor-llcrypto", - "tor-netdoc", - "tor-proto", - "tor-rtcompat", - "tracing", - "web-time-compat", -] - -[[package]] -name = "tor-dircommon" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c9d4239fe25e4797edc7cf7b6efb4935bcec4552d7fe1ed1b61a30b165736b6" -dependencies = [ - "base64ct", - "derive-deftly", - "getset", - "humantime", - "humantime-serde", - "serde", - "tor-basic-utils", - "tor-checkable", - "tor-config", - "tor-linkspec", - "tor-llcrypto", - "tor-netdoc", - "tracing", -] - -[[package]] -name = "tor-dirmgr" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed9e6665621160a7065f3bb56f7bbc77b85aff362f0950415dd882e8c22af9" -dependencies = [ - "async-trait", - "base64ct", - "derive_builder_fork_arti", - "derive_more", - "digest 0.11.3", - "educe", - "event-listener", - "fs-mistrust", - "fslock-guard", - "futures", - "hex", - "humantime", - "humantime-serde", - "itertools 0.15.0", - "memmap2", - "oneshot-fused-workaround", - "paste", - "postage", - "rand 0.10.4", - "rusqlite", - "safelog", - "saturating-time", - "scopeguard", - "serde", - "serde_json", - "signature 3.0.0", - "static_assertions", - "strum", - "thiserror 2.0.20", - "time", - "tor-async-utils", - "tor-basic-utils", - "tor-checkable", - "tor-circmgr", - "tor-config", - "tor-consdiff", - "tor-dirclient", - "tor-dircommon", - "tor-error", - "tor-guardmgr", - "tor-llcrypto", - "tor-netdir", - "tor-netdoc", - "tor-persist", - "tor-proto", - "tor-protover", - "tor-rtcompat", - "tracing", - "void", - "web-time-compat", -] - -[[package]] -name = "tor-error" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1caef18eb269eab70a6244cbfc003e92c8a28c4017fa5f7cb17be718787f151c" -dependencies = [ - "derive_more", - "futures", - "paste", - "retry-error", - "static_assertions", - "strum", - "thiserror 2.0.20", - "tracing", - "void", - "web-time-compat", -] - -[[package]] -name = "tor-general-addr" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09068bc76af4da4bbf0f17be95693c02253b12ed0aa2b4979bee786a1c7f24b5" -dependencies = [ - "derive_more", - "thiserror 2.0.20", - "void", -] - -[[package]] -name = "tor-guardmgr" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d430b1785b1e8f6569043b2ae2ca6c340ff5327f39ba3a19b7cfa9c99ad9a1d" -dependencies = [ - "amplify", - "base64ct", - "derive-deftly", - "derive_builder_fork_arti", - "derive_more", - "dyn-clone", - "educe", - "futures", - "humantime", - "humantime-serde", - "itertools 0.15.0", - "num_enum", - "oneshot-fused-workaround", - "pin-project", - "postage", - "rand 0.10.4", - "safelog", - "saturating-time", - "serde", - "strum", - "thiserror 2.0.20", - "tor-async-utils", - "tor-basic-utils", - "tor-config", - "tor-dircommon", - "tor-error", - "tor-linkspec", - "tor-llcrypto", - "tor-netdir", - "tor-netdoc", - "tor-persist", - "tor-proto", - "tor-relay-selection", - "tor-rtcompat", - "tor-units", - "tracing", - "web-time-compat", -] - -[[package]] -name = "tor-hsclient" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa940dbbff0c4c9323623acb4a49ac40fa227a6a3a07236918f4723db6ab7f9c" -dependencies = [ - "async-trait", - "cfg-if", - "derive-deftly", - "derive_more", - "educe", - "either", - "futures", - "itertools 0.15.0", - "oneshot-fused-workaround", - "postage", - "rand 0.10.4", - "retry-error", - "safelog", - "slotmap-careful", - "strum", - "thiserror 2.0.20", - "tor-async-utils", - "tor-basic-utils", - "tor-bytes", - "tor-cell", - "tor-checkable", - "tor-circmgr", - "tor-config", - "tor-dirclient", - "tor-error", - "tor-hscrypto", - "tor-keymgr", - "tor-linkspec", - "tor-llcrypto", - "tor-memquota", - "tor-netdir", - "tor-netdoc", - "tor-persist", - "tor-proto", - "tor-protover", - "tor-rtcompat", - "tracing", - "web-time-compat", -] - -[[package]] -name = "tor-hscrypto" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a262916c319c77cd6dacb3c2aa1e1cdae1d2bf40dae18b1138cf9d544b927dc2" -dependencies = [ - "cipher 0.5.2", - "data-encoding", - "derive-deftly", - "derive_more", - "digest 0.11.3", - "hex", - "humantime", - "itertools 0.15.0", - "paste", - "rand 0.10.4", - "safelog", - "serde", - "signature 3.0.0", - "subtle", - "thiserror 2.0.20", - "tor-basic-utils", - "tor-bytes", - "tor-error", - "tor-key-forge", - "tor-llcrypto", - "tor-memquota", - "tor-units", - "void", - "web-time-compat", - "zeroize", -] - -[[package]] -name = "tor-hsservice" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cfbd1aa7939e12a7dc56b6eefc1e44444de1f0bdf1a5fbd2eb897e4286733c9" -dependencies = [ - "amplify", - "async-trait", - "base64ct", - "cfg-if", - "derive-deftly", - "derive_builder_fork_arti", - "derive_more", - "digest 0.11.3", - "educe", - "fs-mistrust", - "futures", - "growable-bloom-filter", - "hex", - "humantime", - "itertools 0.15.0", - "k12", - "once_cell", - "oneshot-fused-workaround", - "postage", - "rand 0.10.4", - "rand_core 0.10.1", - "retry-error", - "safelog", - "serde", - "serde_with", - "strum", - "thiserror 2.0.20", - "tor-async-utils", - "tor-basic-utils", - "tor-bytes", - "tor-cell", - "tor-circmgr", - "tor-config", - "tor-config-path", - "tor-dirclient", - "tor-error", - "tor-hscrypto", - "tor-keymgr", - "tor-linkspec", - "tor-llcrypto", - "tor-log-ratelim", - "tor-netdir", - "tor-netdoc", - "tor-persist", - "tor-proto", - "tor-protover", - "tor-relay-selection", - "tor-rtcompat", - "tracing", - "void", - "web-time-compat", -] - -[[package]] -name = "tor-key-forge" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2788d37b8b723a83da9c3f22ee44530ffef4bf0fb13588bd88f44c90cdaa9bae" -dependencies = [ - "derive-deftly", - "derive_more", - "downcast-rs", - "paste", - "rand 0.10.4", - "rsa", - "signature 3.0.0", - "ssh-key-fork-arti", - "thiserror 2.0.20", - "tor-bytes", - "tor-cert", - "tor-checkable", - "tor-error", - "tor-llcrypto", -] - -[[package]] -name = "tor-keymgr" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119f0f26e6b2a11cd0868374a2287c786e97f22330cd8a8ff69cee96b08670cb" -dependencies = [ - "amplify", - "cfg-if", - "data-encoding", - "derive-deftly", - "derive_builder_fork_arti", - "derive_more", - "downcast-rs", - "dyn-clone", - "fs-mistrust", - "glob-match", - "humantime", - "inventory", - "itertools 0.15.0", - "rand 0.10.4", - "safelog", - "serde", - "signature 3.0.0", - "ssh-key-fork-arti", - "thiserror 2.0.20", - "tor-basic-utils", - "tor-bytes", - "tor-config", - "tor-config-path", - "tor-error", - "tor-hscrypto", - "tor-key-forge", - "tor-llcrypto", - "tor-persist", - "tracing", - "visibility", - "walkdir", - "web-time-compat", - "zeroize", -] - -[[package]] -name = "tor-linkspec" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bb55ea69084a82b1f69709059ecfcfb3097adaad6d522dff99d8c52735cb899" -dependencies = [ - "base64ct", - "by_address", - "caret", - "derive-deftly", - "derive_builder_fork_arti", - "derive_more", - "hex", - "itertools 0.15.0", - "safelog", - "serde", - "serde_with", - "strum", - "thiserror 2.0.20", - "tor-basic-utils", - "tor-bytes", - "tor-config", - "tor-llcrypto", - "tor-memquota", - "tor-protover", -] - -[[package]] -name = "tor-llcrypto" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1f114c13c14b0b2668304e2c9f102534ef95a2a004d1294ede969211c9bc60d" -dependencies = [ - "aes 0.9.3", - "base64ct", - "ctr 0.10.1", - "curve25519-dalek 5.1.0", - "der-parser", - "derive-deftly", - "derive_more", - "digest 0.11.3", - "ed25519-dalek 3.0.0", - "educe", - "getrandom 0.2.17", - "getrandom 0.3.4", - "getrandom 0.4.3", - "hex", - "rand 0.10.4", - "rand_chacha 0.10.0", - "rand_core 0.10.1", - "rand_core 0.6.4", - "rand_jitter", - "rdrand", - "reseeding_rng", - "rsa", - "safelog", - "serde", - "sha1", - "sha2 0.11.3", - "sha3 0.12.0", - "shake", - "signature 3.0.0", - "subtle", - "thiserror 2.0.20", - "tor-error", - "tor-memquota-cost", - "visibility", - "x25519-dalek 3.0.0", - "zeroize", -] - -[[package]] -name = "tor-log-ratelim" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eea1296076775d399e0b750117c2e1cfba7fe9463add26f056b7c1397c9a3357" -dependencies = [ - "futures", - "humantime", - "thiserror 2.0.20", - "tor-error", - "tor-rtcompat", - "tracing", - "weak-table", - "web-time-compat", -] - -[[package]] -name = "tor-memquota" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "075e39b9ac84cd15c8249df1499c642e2fbea2a02cc7f146f19df31d771be0dc" -dependencies = [ - "cfg-if", - "derive-deftly", - "derive_more", - "dyn-clone", - "educe", - "extend", - "futures", - "itertools 0.15.0", - "paste", - "pin-project", - "serde", - "slotmap-careful", - "static_assertions", - "sysinfo", - "thiserror 2.0.20", - "tor-async-utils", - "tor-basic-utils", - "tor-config", - "tor-error", - "tor-log-ratelim", - "tor-memquota-cost", - "tor-rtcompat", - "tracing", - "void", -] - -[[package]] -name = "tor-memquota-cost" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7fc75adc50ee789c2ef1633f95647aefc10942bb8a9e6294343dfb574c616c" -dependencies = [ - "derive-deftly", - "itertools 0.15.0", - "paste", - "void", -] - -[[package]] -name = "tor-netdir" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27eb00ecbb05d92471bf7ca386ac929ebca28e1034893045679645293bbddbd0" -dependencies = [ - "async-trait", - "bitflags 2.13.2", - "derive_more", - "digest 0.11.3", - "futures", - "hex", - "humantime", - "itertools 0.15.0", - "num_enum", - "rand 0.10.4", - "serde", - "strum", - "thiserror 2.0.20", - "time", - "tor-basic-utils", - "tor-error", - "tor-hscrypto", - "tor-linkspec", - "tor-llcrypto", - "tor-netdoc", - "tor-protover", - "tor-units", - "tracing", - "typed-index-collections", - "web-time-compat", -] - -[[package]] -name = "tor-netdoc" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4f3fdfb2e47f82c6a15c11fb9bfac8bd4ec9e4bbff786fc23a8f8438436f040" -dependencies = [ - "amplify", - "base64ct", - "cipher 0.5.2", - "derive-deftly", - "derive_builder_fork_arti", - "derive_more", - "digest 0.11.3", - "educe", - "enumset", - "extend", - "hex", - "hostname-validator", - "humantime", - "ipnet", - "iprange", - "itertools 0.15.0", - "memchr", - "paste", - "phf", - "rand 0.10.4", - "rangemap", - "saturating-time", - "serde", - "serde_with", - "signature 3.0.0", - "smallvec", - "strum", - "subtle", - "thiserror 2.0.20", - "time", - "tinystr", - "tor-basic-utils", - "tor-bytes", - "tor-cell", - "tor-cert", - "tor-checkable", - "tor-error", - "tor-hscrypto", - "tor-linkspec", - "tor-llcrypto", - "tor-protover", - "tor-units", - "void", - "web-time-compat", - "zeroize", -] - -[[package]] -name = "tor-persist" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48567a8e69f69edc6cfc3a7bfcd83e9ffb8c16617e81b6a4fbe11c391bd6356f" -dependencies = [ - "amplify", - "derive-deftly", - "derive_more", - "extend", - "filetime", - "fs-mistrust", - "fslock-guard", - "futures", - "itertools 0.15.0", - "oneshot-fused-workaround", - "paste", - "sanitize-filename", - "serde", - "serde_json", - "thiserror 2.0.20", - "time", - "tor-basic-utils", - "tor-error", - "tracing", - "void", - "web-time-compat", -] - -[[package]] -name = "tor-proto" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ee0a62b16f6bde3e1dee30a20e6c6755c5cd912e781c01b96c9d451886848d" -dependencies = [ - "aes 0.9.3", - "amplify", - "async-trait", - "asynchronous-codec", - "bitvec", - "bytes", - "caret", - "cfg-if", - "cipher 0.5.2", - "coarsetime", - "ctr 0.10.1", - "derive-deftly", - "derive_builder_fork_arti", - "derive_more", - "digest 0.11.3", - "educe", - "enum_dispatch", - "futures", - "futures-util", - "hkdf 0.13.0", - "hmac 0.13.0", - "itertools 0.15.0", - "metrics", - "nonany", - "oneshot-fused-workaround", - "pin-project", - "polyval 0.7.3", - "postage", - "rand 0.10.4", - "rand_core 0.10.1", - "safelog", - "slotmap-careful", - "smallvec", - "static_assertions", - "strum", - "subtle", - "thiserror 2.0.20", - "tokio", - "tokio-util", - "tor-async-utils", - "tor-basic-utils", - "tor-bytes", - "tor-cell", - "tor-cert", - "tor-checkable", - "tor-config", - "tor-error", - "tor-hscrypto", - "tor-linkspec", - "tor-llcrypto", - "tor-log-ratelim", - "tor-memquota", - "tor-protover", - "tor-rtcompat", - "tor-units", - "tracing", - "typenum", - "visibility", - "void", - "web-time-compat", - "zeroize", -] - -[[package]] -name = "tor-protover" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac0c7d7cc07222e72cc77231839d23259e4a1fdbbb02345c6c85d8ba142ad352" -dependencies = [ - "caret", - "derive-deftly", - "derive_more", - "itertools 0.15.0", - "paste", - "serde_with", - "thiserror 2.0.20", - "tor-basic-utils", - "tor-bytes", -] - -[[package]] -name = "tor-relay-selection" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91947cd895147e04a4600103608a3e935541d399e1a0b1b400788ceb7583b6c5" -dependencies = [ - "rand 0.10.4", - "serde", - "tor-basic-utils", - "tor-linkspec", - "tor-netdir", - "tor-netdoc", -] - -[[package]] -name = "tor-rtcompat" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ecbaf82921338764c80b302abf5a75671400cc26d1daf3ee91826c653d5b9fc" -dependencies = [ - "amplify", - "async-trait", - "async_executors", - "asynchronous-codec", - "cfg-if", - "coarsetime", - "derive_builder_fork_arti", - "derive_more", - "dyn-clone", - "educe", - "futures", - "futures-rustls", - "hex", - "libc", - "paste", - "pin-project", - "rustls", - "rustls-pki-types", - "rustls-webpki", - "socket2", - "thiserror 2.0.20", - "tokio", - "tokio-util", - "tor-error", - "tor-general-addr", - "tracing", - "void", - "web-time-compat", - "zeroize", -] - -[[package]] -name = "tor-socksproto" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "040951b4e279a0ac1b315a4845b69557f7d1ea1376fa911d482333b0693225a6" -dependencies = [ - "caret", - "derive-deftly", - "educe", - "safelog", - "subtle", - "thiserror 2.0.20", - "tor-bytes", - "tor-error", -] - -[[package]] -name = "tor-units" -version = "0.49.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475566f8ee463e219980befbdc7b46397c1db5a8f54bd6ac75c41563712c5903" -dependencies = [ - "derive-deftly", - "derive_more", - "serde", - "thiserror 2.0.20", - "tor-memquota", -] - -[[package]] -name = "tower" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" -dependencies = [ - "futures-core", - "futures-util", - "pin-project-lite", - "sync_wrapper", - "tokio", - "tokio-util", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-http" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c" -dependencies = [ - "bitflags 2.13.2", - "bytes", - "http", - "http-body", - "http-body-util", - "percent-encoding", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" - -[[package]] -name = "tower-service" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" - -[[package]] -name = "tracing" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-appender" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "050686193eb999b4bb3bc2acfa891a13da00f79734704c4b8b4ef1a10b368a3c" -dependencies = [ - "crossbeam-channel", - "symlink", - "thiserror 2.0.20", - "time", - "tracing-subscriber", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "tracing-core" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" -dependencies = [ - "nu-ansi-term", - "sharded-slab", - "smallvec", - "thread_local", - "tracing-core", - "tracing-log", -] - -[[package]] -name = "twox-hash" -version = "2.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5283634e518fe9e82c7b20520bb4bc209009fd16c82077c802f8111ecbb0117a" - -[[package]] -name = "typed-index-collections" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898160f1dfd383b4e92e17f0512a7d62f3c51c44937b23b6ffc3a1614a8eaccd" -dependencies = [ - "bincode", - "serde", -] - -[[package]] -name = "typenum" -version = "1.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" - -[[package]] -name = "unarray" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" - -[[package]] -name = "uncased" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" -dependencies = [ - "version_check", -] - -[[package]] -name = "unicode-ident" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" - -[[package]] -name = "unicode-segmentation" -version = "1.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" - -[[package]] -name = "unicode-truncate" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b380a1238663e5f8a691f9039c73e1cdae598a30e9855f541d29b08b53e9a5" -dependencies = [ - "itertools 0.14.0", - "unicode-segmentation", - "unicode-width", -] - -[[package]] -name = "unicode-width" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" - -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - -[[package]] -name = "uniffi" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edf78ecfb9bb8d7c4f8da11e8eb2ab6304e8ec0adb3ab32d8fc77c21a5bb0b86" -dependencies = [ - "anyhow", - "camino", - "cargo_metadata", - "clap", - "uniffi_bindgen", - "uniffi_core", - "uniffi_macros", - "uniffi_pipeline", -] - -[[package]] -name = "uniffi_bindgen" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdea7c4574723928bef87dfc04b203d96321d0bf34ab295a56379e633be579f3" -dependencies = [ - "anyhow", - "askama", - "camino", - "cargo_metadata", - "fs-err", - "glob", - "goblin", - "heck", - "indexmap 2.14.2", - "once_cell", - "serde", - "tempfile", - "textwrap", - "toml 1.2.3+spec-1.1.0", - "uniffi_internal_macros", - "uniffi_meta", - "uniffi_pipeline", - "uniffi_udl", -] - -[[package]] -name = "uniffi_core" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8b1c62ee415b805f063c82e8ef6bbcaa1b87f8eed360cf217537b7724e05601" -dependencies = [ - "anyhow", - "async-compat", - "bytes", - "once_cell", - "static_assertions", -] - -[[package]] -name = "uniffi_internal_macros" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79d4a3129d6c2c15e367d3954886a0533dd3e85d445ce4d93379f62c6949d7b" -dependencies = [ - "anyhow", - "indexmap 2.14.2", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "uniffi_macros" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f6a9826a83f1140b2ec67c7944f562e1ef616e6eaf40e76247adccbd5b8a091" -dependencies = [ - "camino", - "fs-err", - "once_cell", - "proc-macro2", - "quote", - "serde", - "syn 2.0.119", - "toml 1.2.3+spec-1.1.0", - "uniffi_meta", -] - -[[package]] -name = "uniffi_meta" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf233eb014b595e8997c98df4ac6863b486a4ac6d54bd00230c7700753d7ef13" -dependencies = [ - "anyhow", - "siphasher", - "uniffi_internal_macros", - "uniffi_pipeline", -] - -[[package]] -name = "uniffi_pipeline" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55179706fbb6e7a23e729780d2c6165e6afe1ce725fa63754bcf217b440afc04" -dependencies = [ - "anyhow", - "heck", - "indexmap 2.14.2", - "tempfile", - "uniffi_internal_macros", -] - -[[package]] -name = "uniffi_udl" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "421a9add7a19c5a264a2aba760514125ef3840a8b246ec88237fc91e3f2f79b1" -dependencies = [ - "anyhow", - "textwrap", - "uniffi_meta", - "weedle2", -] - -[[package]] -name = "universal-hash" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" -dependencies = [ - "crypto-common 0.1.7", - "subtle", -] - -[[package]] -name = "universal-hash" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96" -dependencies = [ - "crypto-common 0.2.2", - "ctutils", -] - -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - -[[package]] -name = "unty" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" - -[[package]] -name = "url" -version = "2.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", - "serde", -] - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - -[[package]] -name = "valuable" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" - -[[package]] -name = "varint-rs" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa6c38708f6257f1ec2ca7e5a11f9bbf58a27d7060078b6b333624968183d96" - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "visibility" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d674d135b4a8c1d7e813e2f8d1c9a58308aee4a680323066025e53132218bd91" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "wait-timeout" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" -dependencies = [ - "libc", -] - -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - -[[package]] -name = "wasip2" -version = "1.0.4+wasi-0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" -dependencies = [ - "wit-bindgen", -] - -[[package]] -name = "wasix" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae86f02046da16a333a9129d31451423e1657737ecdafed4193838a5f54c5cfe" -dependencies = [ - "wasi", -] - -[[package]] -name = "wasm-bindgen" -version = "0.2.128" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf" -dependencies = [ - "cfg-if", - "once_cell", - "rustversion", - "wasm-bindgen-macro", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.128" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.128" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a" -dependencies = [ - "bumpalo", - "proc-macro2", - "quote", - "syn 3.0.5", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.128" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "weak-table" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eba2ec791141b0bf4db542f6b038a8f9310cee33e076cb181245780b09a24ff" -dependencies = [ - "cfg-if", - "hashbrown 0.16.1", -] - -[[package]] -name = "web-time" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "web-time-compat" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f854754465eaf0d17b96236f75c6ddfaebf5907dc31c24ecdc265ffe609756c5" -dependencies = [ - "web-time", -] - -[[package]] -name = "weedle2" -version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "998d2c24ec099a87daf9467808859f9d82b61f1d9c9701251aea037f514eae0e" -dependencies = [ - "nom", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" -dependencies = [ - "windows-sys 0.61.2", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows" -version = "0.62.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" -dependencies = [ - "windows-collections", - "windows-core", - "windows-future", - "windows-numerics", -] - -[[package]] -name = "windows-collections" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" -dependencies = [ - "windows-core", -] - -[[package]] -name = "windows-core" -version = "0.62.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-link", - "windows-result", - "windows-strings", -] - -[[package]] -name = "windows-future" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" -dependencies = [ - "windows-core", - "windows-link", - "windows-threading", -] - -[[package]] -name = "windows-implement" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "windows-interface" -version = "0.59.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "windows-link" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" - -[[package]] -name = "windows-numerics" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" -dependencies = [ - "windows-core", - "windows-link", -] - -[[package]] -name = "windows-result" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-strings" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets 0.53.5", -] - -[[package]] -name = "windows-sys" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.53.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" -dependencies = [ - "windows-link", - "windows_aarch64_gnullvm 0.53.1", - "windows_aarch64_msvc 0.53.1", - "windows_i686_gnu 0.53.1", - "windows_i686_gnullvm 0.53.1", - "windows_i686_msvc 0.53.1", - "windows_x86_64_gnu 0.53.1", - "windows_x86_64_gnullvm 0.53.1", - "windows_x86_64_msvc 0.53.1", -] - -[[package]] -name = "windows-threading" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_i686_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" - -[[package]] -name = "winnow" -version = "0.7.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" -dependencies = [ - "memchr", -] - -[[package]] -name = "winnow" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" -dependencies = [ - "memchr", -] - -[[package]] -name = "wit-bindgen" -version = "0.57.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" - -[[package]] -name = "writeable" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "x25519-dalek" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" -dependencies = [ - "curve25519-dalek 4.1.3", - "rand_core 0.6.4", - "serde", - "zeroize", -] - -[[package]] -name = "x25519-dalek" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e8131a03190127fb2263afc72b322ecadae46b6ff8c6f399ff5d02f5559af6" -dependencies = [ - "curve25519-dalek 5.1.0", - "rand_core 0.10.1", - "zeroize", -] - -[[package]] -name = "xxhash-rust" -version = "0.8.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aee1b19627c7c60102ab80d3a9cbe18de90bfe03bfa6c3715447681f0e8c8af6" - -[[package]] -name = "yoke" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" -dependencies = [ - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", - "synstructure 0.14.0", -] - -[[package]] -name = "zerocopy" -version = "0.8.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d35102a9f36d089ccae9e4c6802bc118be4487b80aaffc0ab4e0cf5ce92d2873" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c01f5ab44258da43cf276c74a2763db2ff3969c9c652c3f2de07041d0b2bc" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "zerofrom" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", - "synstructure 0.13.2", -] - -[[package]] -name = "zeroize" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "zerotrie" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", -] - -[[package]] -name = "zerovec" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" -dependencies = [ - "serde", - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.11.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - -[[package]] -name = "zlib-rs" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34b31d188d9d685a4f9c7b46d6e36631b07058d2cfe190267adce54dc230bf12" - -[[package]] -name = "zmij" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" - -[[package]] -name = "zstd" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf06bd8162af0734b344780deb55b42a2429ae430870d13fcc12f238e880fe6e" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "8.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae42c0555055784c70058d19ba8e275528e8a99a706684868ace5da4e716a4ab" -dependencies = [ - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.1.0+zstd.1.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef0a8027ec3ee71300ab3bcbcd0393f434aa72b91ca6d635a39941deae8eea0" -dependencies = [ - "cc", - "pkg-config", -] diff --git a/crates/onionwire-sdk/Cargo.toml b/crates/onionwire-sdk/Cargo.toml deleted file mode 100644 index ff24a3a..0000000 --- a/crates/onionwire-sdk/Cargo.toml +++ /dev/null @@ -1,61 +0,0 @@ -[package] -name = "onionwire-sdk" -version = "0.1.0" -edition = "2024" -# Follows the root crate. The SDK builds onionwire with `default-features = -# false` (no `cuprate-daemon`), which would still compile on 1.91, but cargo -# checks the path dependency's `rust-version` anyway, and that floor is 1.98. -rust-version = "1.98" -description = "OnionWire Android/Kotlin SDK: in-process Arti onion transport, Noise IK, identity = ed25519 pubkey." -license = "MIT" -publish = false - -# 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" - -[lib] -name = "onionwire_sdk" -crate-type = ["cdylib", "lib"] - -[features] -default = [] - -# The in-process Monero chain daemon (Cuprate). Off by default: it pulls a -# pinned `cuprated` git revision, ~152 crates and a C++ RandomX cross-build -# (+11.8 MiB on an aarch64 release binary). Without it the SDK can still store -# and read back a `ChainChoice.InProcessCuprate` setting — starting one fails -# with the core's "rebuild with --features cuprate-daemon" message. -cuprate-daemon = ["onionwire/cuprate-daemon"] - -[dependencies] -onionwire = { path = "../..", default-features = false, features = ["rustls"] } -# `static-sqlite`: Android has no system libsqlite3 to link against. -arti-client = { version = "0.49", default-features = false, features = [ - "tokio", - "onion-service-client", - "onion-service-service", - "compression", - "rustls", - "static-sqlite", -] } -tokio = { version = "1", features = ["rt-multi-thread", "time"] } -# rustls 0.23 resolves its provider from its OWN `ring` / `aws-lc-rs` features, -# never from whichever crypto crates happen to be linked in the graph. Arti -# pulls rustls in through `tor-rtcompat` with `default-features = false`, so -# without this line rustls compiles with zero providers and the first TLS config -# built from the process default fails at runtime — the "Failed to start / -# Could not automatically determine the process-level CryptoProvider" screen. -# -# `ring`, not `aws-lc-rs`: aws-lc-rs needs CMake and a C toolchain for the NDK -# and fights the Android cross-compile. The `ring` crate was already in the -# graph (via `snow`, for Noise) but that is a different thing entirely. -rustls = { version = "0.23", default-features = false, features = ["ring"] } -uniffi = { version = "0.32", features = ["cli", "tokio"] } -thiserror = "2" - -[[bin]] -name = "uniffi-bindgen" -path = "src/bin/uniffi-bindgen.rs" diff --git a/crates/onionwire-sdk/README.md b/crates/onionwire-sdk/README.md deleted file mode 100644 index 545263b..0000000 --- a/crates/onionwire-sdk/README.md +++ /dev/null @@ -1,159 +0,0 @@ -# onionwire-sdk (Android) - -Kotlin-facing UniFFI bindings over the same Rust crate the OnionWire Linux TUI -runs on. An Android peer and a Linux peer that exchange invites interoperate — -there is one protocol, not two. - -This is **not** a WebView wrapper and **not** a client for a hosted service. -Each install runs Arti in-process (`arti-client` 0.49, `onion-service-client` + -`onion-service-service`), hosts its own v3 onion service, and dials friends' -onions directly. There is no `tor` binary, no torrc, no Orbot as the pipe. - -## Locked protocol facts - -| Piece | Rule | -|---|---| -| Identity | ed25519 keypair. The pubkey **is** who you are. | -| Roster key | `friends.pubkey`, `UNIQUE`. Petnames are local only. | -| Onion | A **locator**, not an identity. It rotates. | -| Invite | `onionwire:v1:k=…:o=…:spk=…:sig=…` | -| Crypto | Noise IK (`Noise_IK_25519_ChaChaPoly_BLAKE2s`). `spk` is x25519. | -| Chat send | Unreachable peer onion → the message goes to the **local outbox** and is retried with backoff. `send()` returns `SendState.Sent` or `SendState.Queued`. File transfer and payments stay fail-closed. | -| At rest | The whole sqlite file is SQLCipher (key = Argon2id of the store passphrase), and chat bodies carry a second per-row ChaCha20-Poly1305 layer with row-bound AAD. Identity keys live in that same encrypted file. | - -### Invite string - -``` -onionwire:v1:k=:o=:spk=:sig= -``` - -* `sig` is ed25519 over `onionwire-invite-v1` + `0x00`-separated `k`, `o`, `spk` (hex/onion as they appear in the string). Decode still accepts the legacy raw concatenation so old invites verify. See [docs/PROTOCOL.md](../../docs/PROTOCOL.md). -* A malformed, unsigned, or tampered invite is rejected before anything is stored. -* **Same `k` never creates a second friend.** It updates the stored locator on - the existing row. That is the whole point of keying the roster on the pubkey. -* The invite carries no display name and no Monero address — those arrive later - over the wire as signed `prf` frames, not through the invite. - -## Adding the AAR to another Android app - -The SDK ships as `onionwire-sdk-.aar` on the Forgejo release, with a -matching `.sha256`. - -```kotlin -// settings.gradle.kts -dependencyResolutionManagement { - repositories { - google() - mavenCentral() - flatDir { dirs("libs") } // or however you vendor the AAR - } -} - -// app/build.gradle.kts -dependencies { - implementation(files("libs/onionwire-sdk-0.1.0.aar")) -} -``` - -Requirements: - -* `minSdk >= 26`. The AAR is built with the NDK against `android-26`. -* `abiFilters` must include an ABI the AAR ships. The release AAR includes - `arm64-v8a`. Add `x86_64` at build time with `-Ponionwire.abis=arm64-v8a,x86_64` - if you need an emulator. -* Keep `uniffi.onionwire_sdk.**` (see the AAR's `consumer-rules.pro`, applied - automatically by AGP) if you enable R8. - -## Kotlin surface - -Everything is a `suspend fun` — Arti bootstrap and onion publish take minutes. -A send that cannot reach the peer comes back immediately as `QUEUED` (it is not -a long retry inside the call): the message is stored locally and a background -worker in the core keeps retrying it. - -```kotlin -import uniffi.onionwire_sdk.* - -// 1. Open (or create) the identity inside app-private storage. -// `filesDir`, never external storage. Empty passphrase fails closed. -val wire: Wire = openWire(File(context.filesDir, "onionwire").absolutePath, passphrase) - -// 2. Who you are, and where you are right now. -val fingerprint: String = wire.fingerprint() // stable forever -val onion: String = wire.onion() // changes on rotate - -// 3. Invite out / invite in. -val mine: String = wire.invite() -val preview: InviteInfo = decodeInvite(pasted) // verifies sig, stores nothing -val friend: FriendInfo = wire.addFriend(pasted) - -// 4. Roster and chat. -val roster: List = wire.friends() -wire.setPetname(friend.pubkeyHex, "ada") -when (wire.send(friend.pubkeyHex, "hello wire")) { - SendState.SENT -> { /* the peer's onion took the frame */ } - SendState.QUEUED -> { /* unreachable: stored in the local outbox and - retried in the background. Show it as pending — - it is local-only until a circuit takes it. */ } -} -val msgs: List = wire.messages(friend.pubkeyHex) -// msgs[i].direction == "out" -> msgs[i].delivery is "sent" | "queued" | -// "sending" | "failed: "; null for incoming messages. Render the -// queued and failed states distinctly from sent. - -// 5. Locator rotation. Do NOT wire this to a single tap — the app that embeds -// the SDK owns the typed confirmation. -val out: RotateOutcome = wire.rotateOnion() // out.notified / out.friends - -// 6. Saved wallets, and which one is open. -val wallets: List = wire.wallets() // a store read: never dials -val active: String? = wire.activeWalletFilename() // the open file, or null -val open = wallets.firstOrNull { it.walletFilename == active } -wire.openWallet("onionwire-2") // may restart a running wallet child; a name - // outside the catalogue is refused -// A wallet child is up but its file is not open -> the child answers `-13 No -// wallet file` to every read. `walletStatus()` says which: -val st: WalletChildStatus = wire.walletStatus() -if (st.running && !st.walletOpen && st.needsPassphrase) { - val pass = askForTheWalletPassphrase() // your own input surface, echo off - wire.openWalletWithPassphrase(active!!, pass) // stored (sealed) on success; - // a refused passphrase is an - // error and is NOT stored -} -val keys: WalletKeys = wire.walletKeys() // the OPEN wallet's private keys -// keys.spendKey == null -> a view-only wallet (the RPC's -29 watch-only answer). -// That is not an error. The seed (`walletSeed()`) and these keys always belong -// to `activeWalletFilename()`: to show another wallet's backup, open it first. -// Both are spend secrets — show them from an explicit user action only, never -// log them, never persist them. - -// 7. Your own profile (nickname, bio, Monero address). -val me: SelfProfile = wire.selfProfile() -wire.setSelfProfile("ada", "on the wire", "4AdUnd...") // validated on write -wire.pushSelfProfile(friend.pubkeyHex) // signed `prf`, one-shot and fail-closed -``` - -All peer references are lowercase hex strings so nothing Rust-shaped leaks into -the AAR. - -## Building the bindings yourself - -The Gradle task `:sdk:uniffiBindgen` runs, inside `crates/onionwire-sdk`: - -``` -cargo build --release --lib # host cdylib -cargo run --release --bin uniffi-bindgen -- generate \ - --library target/release/libonionwire_sdk.so \ - --language kotlin --out-dir -``` - -Do not hand-edit anything under `android/sdk/build/generated/`; it is a build -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 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. diff --git a/crates/onionwire-sdk/src/bin/uniffi-bindgen.rs b/crates/onionwire-sdk/src/bin/uniffi-bindgen.rs deleted file mode 100644 index ab9d7ed..0000000 --- a/crates/onionwire-sdk/src/bin/uniffi-bindgen.rs +++ /dev/null @@ -1,8 +0,0 @@ -//! UniFFI binding generator entry point. -//! -//! `cargo run -p onionwire-sdk --bin uniffi-bindgen -- generate --library \ -//! target/release/libonionwire_sdk.so --language kotlin --out-dir ` - -fn main() { - uniffi::uniffi_bindgen_main() -} diff --git a/crates/onionwire-sdk/src/lib.rs b/crates/onionwire-sdk/src/lib.rs deleted file mode 100644 index 390d653..0000000 --- a/crates/onionwire-sdk/src/lib.rs +++ /dev/null @@ -1,2626 +0,0 @@ -//! OnionWire Android/Kotlin SDK. -//! -//! UniFFI façade over the existing `onionwire` library — the same crate the -//! Linux TUI runs on. Nothing about the wire protocol is reimplemented here: -//! an Android peer and a Linux peer that exchange invites interoperate. -//! -//! Locked facts this surface assumes: -//! * Identity is an ed25519 pubkey. Fingerprint is a display of that key. -//! * `onionwire:v1:k=…:o=…:spk=…:sig=…` — the onion is a *locator* and can -//! change; re-scanning the same `k` updates the locator, never duplicates -//! the friend. -//! * Transport is in-process Arti. There is no `tor` binary, no torrc, no -//! Orbot pipe. If the onion service cannot publish, this fails closed. -//! * Chat bodies are encrypted at rest, and the whole sqlite file is -//! SQLCipher on top of that (see the root crate). -//! * A chat send that cannot reach the peer's onion is queued in a local -//! outbox and retried — see [`SendState`]. Nothing leaves the device. -//! -//! Lifecycle: a node is started by [`open_wire`] and stopped by -//! [`Wire::shutdown`]. Between those, [`Wire::tor_state`] is the observable -//! state and [`Wire::flush`] is "deliver what is deliverable now". A process -//! killed by Doze or the background-process killer never runs `shutdown`, which -//! is exactly why queued sends live in sqlite and not in memory. -//! -//! The façade deliberately exposes only plain data (records + hex strings) so -//! no TUI/ratatui type leaks into the AAR. - -use std::path::{Path, PathBuf}; -use std::sync::{Arc, Mutex, OnceLock}; - -use onionwire::hs::TorState as CoreTorState; -use onionwire::node::{FlushOutcome as CoreFlushOutcome, Node}; -use onionwire::outbox::{DEFAULT_MAX_ATTEMPTS, OutboxEntry, OutboxStatus}; -use onionwire::pay; -use onionwire::qr; -use onionwire::wallet::{ChainNetwork, ChainSource, WalletKeys as CoreWalletKeys}; -use onionwire::wallet_child::{ChildConfig, WalletChildState}; -use onionwire::{FriendProfile, Message, WalletRecord}; - -uniffi::setup_scaffolding!(); - -/// Install rustls's process-level default `CryptoProvider`, exactly once. -/// Belt and braces. `Cargo.toml` pins `rustls` with the `ring` feature, which -/// is what actually fixes the missing-provider failure: with it, rustls -/// resolves a provider from crate features on its own. This function exists -/// because the cdylib is loaded into a process we do not own — an explicitly -/// installed provider makes the SDK independent of how the surrounding app's -/// feature graph happens to resolve rustls. -/// -/// Idempotent and cheap after the first call (`OnceLock` short-circuits it). -/// An `Err` means some provider is already installed process-wide, which is the -/// outcome we want, so it is deliberately ignored — including the case of a -/// consumer that installed `aws-lc-rs` itself. A genuine *conflict* — both -/// provider features compiled in — is a build-graph bug, not something to -/// paper over here; `Cargo.toml` enables `ring` only. -/// -/// Not exported over UniFFI: it is Rust-side plumbing, not part of the Kotlin -/// surface. -pub fn install_crypto_provider() { - static INSTALLED: OnceLock<()> = OnceLock::new(); - INSTALLED.get_or_init(|| { - let _ = rustls::crypto::ring::default_provider().install_default(); - }); -} - -#[derive(Debug, thiserror::Error, uniffi::Error)] -#[uniffi(flat_error)] -pub enum WireError { - #[error("{message}")] - Failed { message: String }, - /// The node was shut down (or never opened). Distinct from `Failed` so - /// Kotlin can branch on it instead of string-matching a message, and so - /// "you must unlock again" is a different UI state from "the network is - /// broken". - #[error("node stopped: {message}")] - Stopped { message: String }, -} - -impl WireError { - fn new(e: impl std::fmt::Display) -> Self { - Self::Failed { - message: e.to_string(), - } - } - - fn stopped(what: &str) -> Self { - Self::Stopped { - message: format!("{what} called on a shut-down node"), - } - } -} - -type WResult = std::result::Result; - -#[derive(Debug, Clone, uniffi::Record)] -pub struct FriendInfo { - /// ed25519 identity pubkey, lowercase hex. This is the roster key. - pub pubkey_hex: String, - /// Display form of the same key. - pub fingerprint: String, - /// Local label. Never sent on the wire. - pub petname: Option, - /// Current locator. May be stale if the peer rotated while you were down. - pub onion: String, - pub last_connect_ok: bool, - /// True when the friend was added from `onionwire:v2` (has an ML-KEM key), - /// so sessions are hybrid. False is a legacy v1 friend: classical - /// transport, and the UI must say so. - pub pq: bool, -} - -/// What `send()` did with the message. -/// -/// The core has a local outbox: when a friend's onion is unreachable the -/// message is written to the local sqlite store and a background worker -/// retries it with backoff. Nothing is handed to a third party — every attempt -/// is a fresh handshake straight to that friend's onion — but until a circuit -/// takes it the message exists only on this device. A consumer must not render -/// `Queued` as delivered. -#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Enum)] -pub enum SendState { - /// The frame reached the peer's onion service during this call. - Sent, - /// The peer's onion was unreachable: the message is in the local outbox, - /// local-only until the retry worker delivers it (or it ends `Failed`). - Queued, -} - -#[derive(Debug, Clone, uniffi::Record)] -pub struct ChatMessage { - /// `messages.id` of the stored row. This is the join key an - /// [`OutboxRow::message_id`] refers to, so a client matches an outbox row to - /// this message by id instead of matching bodies or counting rows. Stable - /// for the life of the row; never `0`. - pub id: i64, - /// "in" or "out". - pub direction: String, - pub body: String, - /// Outgoing messages only: `"sent"`, `"queued"`, `"sending"` or - /// `"failed: "`. `None` for incoming messages. An outgoing row with - /// no outbox row is one the peer accepted on the first attempt, so it reads - /// `"sent"` — never treat a missing value as "delivered" on the app side, - /// read this field. - pub delivery: Option, -} - -/// One row of the local outbox for a friend: a chat send the core has not -/// finished delivering. -/// -/// The join key is `message_id` — the `messages.id` a [`ChatMessage`] belongs -/// to — so a client matches these against its own list instead of matching -/// bodies. Delivered rows are deleted, which is why a message with no row here -/// was accepted by the peer and never needed a retry. -#[derive(Debug, Clone, PartialEq, Eq, uniffi::Record)] -pub struct OutboxRow { - /// `messages.id` of the chat row this outbox row belongs to. - pub message_id: i64, - /// `"queued"`, `"sending"` or `"failed"` — the store's own encoding of - /// `OutboxStatus`, the same string [`ChatMessage::delivery`] uses. - /// `"sent"` does not occur: a delivered row is deleted before this is read. - pub status: String, - /// Attempts already spent on this row. Compare against - /// [`outbox_max_attempts`] to render `try n/8`. - pub attempts: u32, - /// Absolute unix seconds of the next attempt, so the client renders its own - /// countdown from `now` instead of a stale number baked into a record. - /// Only meaningful while `status == "queued"`: a `"failed"` row is terminal - /// and keeps the last time it was scheduled for, which must not be shown as - /// a countdown. - pub next_attempt_at: i64, - /// Why the last attempt failed, as the core reported it. `None` until the - /// row has been attempted once. - pub last_error: Option, -} - -/// Retry budget after which a queued message turns terminally `"failed"` — the -/// denominator in `try n/8`. -/// -/// A constant of the core's outbox, not per-node state, so it is a free -/// function: fetch it once and render `attempts` against it. It is exposed at -/// all because the client cannot read the Rust constant. -#[uniffi::export] -pub fn outbox_max_attempts() -> u32 { - DEFAULT_MAX_ATTEMPTS -} - -#[derive(Debug, Clone, uniffi::Record)] -pub struct RotateOutcome { - pub notified: u32, - pub friends: u32, -} - -#[derive(Debug, Clone, uniffi::Record)] -pub struct InviteInfo { - pub pubkey_hex: String, - pub onion: String, - /// `onionwire:v2` (ML-KEM key present) vs a legacy v1 invite. - pub pq: bool, -} - -/// Observable lifecycle state of the node's onion service. -/// -/// Mirrors Arti's own service status, projected onto the four states a UI -/// actually acts on. It is the same distinction `hs::hs_is_ready` makes when it -/// decides whether the onion is reachable yet. -#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Enum)] -pub enum TorState { - /// Bootstrap or descriptor upload still in flight. Not reliably reachable. - Bootstrapping, - /// Onion service running and its descriptor published. - Published, - /// Reachable, but Arti reports the service degraded. Usable — worth saying - /// so, not identical to `Published`. - DegradedReachable, - /// Shut down: no onion service, no dials, store checkpointed. Every method - /// on the node now returns `WireError.Stopped`. - Stopped, -} - -impl From for TorState { - fn from(s: CoreTorState) -> Self { - match s { - CoreTorState::Bootstrapping => Self::Bootstrapping, - CoreTorState::Published => Self::Published, - CoreTorState::DegradedReachable => Self::DegradedReachable, - CoreTorState::Stopped => Self::Stopped, - } - } -} - -/// What a [`Wire::flush`] managed to do. -#[derive(Debug, Clone, Copy, uniffi::Record)] -pub struct FlushOutcome { - /// Rows the pass started a delivery for. `0` when the pass hit its time - /// budget before finishing — the rows are still queued, we just stopped - /// counting. - pub attempted: u32, - /// Rows delivered now. A message absent from `remaining` was sent. - pub delivered: u32, - /// Rows still queued or terminally failed afterwards. - pub remaining: u32, -} - -/// A running OnionWire node: identity + Arti client + hosted v3 onion service. -/// -/// Holds the node handle. [`Wire::shutdown`] takes it out and drops it, which -/// is what lets the last reference to the Tor client and the store go away — -/// there is no hidden global keeping Arti (or the sqlite connection) alive -/// after the UI is gone. -#[derive(uniffi::Object)] -pub struct Wire { - node: Mutex>>, - /// `$ONIONWIRE_HOME` exactly as [`open_wire`] was given it. The SDK resolves - /// the per-identity defaults a caller cannot know (the in-process chain - /// data directory) against it, so Kotlin never has to invent a path. - home: PathBuf, -} - -impl Wire { - /// The live node, or `Stopped` if this handle was shut down. A poisoned - /// mutex is reported the same way rather than panicking: a caller that sees - /// `Stopped` unlocks again, which is the correct recovery either way. - fn node(&self) -> WResult> { - let guard = self.node.lock().map_err(|_| WireError::Stopped { - message: "node handle lock poisoned by a panic; reopen the identity".to_string(), - })?; - guard - .as_ref() - .cloned() - .ok_or_else(|| WireError::stopped("this call")) - } -} - -/// Open (or create) the identity in `home` and start hosting an onion service. -/// -/// `home` must be app-private storage (`context.filesDir`), not external. -/// `passphrase` wraps the local message key; an empty passphrase fails closed. -/// -/// This resolves only once the onion service is published — on a cold network -/// that is minutes, not seconds. Call it off the main thread. -/// -/// The returned handle owns the node: it lives until [`Wire::shutdown`], or -/// until the handle itself is dropped (which the JVM does without running the -/// drain, so call `shutdown()` from teardown — see the foreground-service -/// caller). -#[uniffi::export(async_runtime = "tokio")] -pub async fn open_wire(home: String, passphrase: String) -> WResult> { - // Before anything that can build a TLS config: Arti's rustls backend dies - // with "Could not automatically determine the process-level CryptoProvider" - // if no provider is resolvable. See `install_crypto_provider`. - install_crypto_provider(); - let home = PathBuf::from(home); - let node = Node::start_with_passphrase(home.clone(), &passphrase) - .await - .map_err(WireError::new)?; - Ok(Arc::new(Wire { - node: Mutex::new(Some(node)), - home, - })) -} - -/// Decode an invite without adding the friend. Verifies the signature. -#[uniffi::export] -pub fn decode_invite(invite: String) -> WResult { - let p = qr::decode(&invite).map_err(WireError::new)?; - Ok(InviteInfo { - pubkey_hex: hex(&p.pubkey), - onion: p.onion, - pq: p.kem_pk.is_some(), - }) -} - -#[uniffi::export(async_runtime = "tokio")] -impl Wire { - /// Stop the node: give every queued outbox row one last bounded delivery - /// attempt, stop the onion service, abort the retry worker, checkpoint the - /// sqlite WAL, and drop the Tor client. - /// - /// The *node* teardown is idempotent: a second `Node::shutdown()` returns - /// `Ok` without repeating the work. This handle is spent by the first call, - /// so a second `Wire::shutdown()` — or two concurrent teardowns — returns - /// the typed `WireError.Stopped` instead of a silent `Ok`: a double - /// teardown is a caller bug worth surfacing, and `Stopped` is already the - /// answer every other method gives. It never panics. - /// - /// After it, every other method on this handle — including `send` — - /// returns `WireError.Stopped` instead of touching a dead client. - /// - /// Never called at all when the process is killed outright (Doze, the - /// background-process killer, a force-stop): that is the case [`flush`] - /// (Self::flush) and the sqlite outbox exist for. Once shut down, this - /// handle is spent — unlock again to get a new one. - pub async fn shutdown(&self) -> WResult<()> { - let node = self.node()?; - node.shutdown().await.map_err(WireError::new)?; - // Drop our handle to the node. With the onion service and the outbox - // worker aborted this is the last reference to the Tor client and the - // store, so Arti's runtime and the sqlite connection are released here. - let mut guard = self.node.lock().map_err(|_| WireError::Stopped { - message: "node handle lock poisoned by a panic".to_string(), - })?; - *guard = None; - Ok(()) - } - - /// Drain the outbox: one delivery attempt for every queued row, now, - /// ignoring its retry backoff, then checkpoint the WAL. - /// - /// Bounded by the SDK (30s): a dead peer's onion can hold a dial for ~20s - /// and this is called from UI/lifecycle threads. Rows that did not go out - /// stay queued; the retry worker keeps its normal schedule. Safe to call - /// repeatedly — use it on unlock, on foreground, and before `shutdown`. - pub async fn flush(&self) -> WResult { - let node = self.node()?; - let out = node.flush().await.map_err(WireError::new)?; - Ok(from_core_flush(out)) - } - - /// Where the onion service is right now. Cheap and read-only, no I/O: a - /// notification or a settings screen can call it directly. - pub fn tor_state(&self) -> TorState { - match self.node.lock() { - Ok(guard) => match guard.as_ref() { - Some(node) => node.tor_state().into(), - None => TorState::Stopped, - }, - // Poisoned: same answer as shut down — the node is unusable. - Err(_) => TorState::Stopped, - } - } - - /// Fingerprint of our own identity key. Stable forever for this install. - pub async fn fingerprint(&self) -> WResult { - self.node()?.fingerprint().map_err(WireError::new) - } - - /// Current onion locator. Changes on rotate; identity does not. - pub async fn onion(&self) -> WResult { - Ok(self.node()?.onion()) - } - - /// `onionwire:v1:…` invite string to hand to the other person out of band. - pub async fn invite(&self) -> WResult { - self.node()?.qr_payload().map_err(WireError::new) - } - - /// Roster, sorted by petname then fingerprint. - pub async fn friends(&self) -> WResult> { - let list = self.node()?.list_friends().map_err(WireError::new)?; - Ok(list - .into_iter() - .map(|f| FriendInfo { - pubkey_hex: hex(&f.pubkey), - fingerprint: f.fingerprint, - petname: f.petname, - onion: f.onion, - last_connect_ok: f.last_connect_ok, - pq: f.kem_pk.is_some(), - }) - .collect()) - } - - /// Add a friend from an invite, or update the locator if the key is known. - /// Same `k` never creates a second row. - pub async fn add_friend(&self, invite: String) -> WResult { - let node = self.node()?; - node.add_friend_from_qr(&invite).map_err(WireError::new)?; - let p = qr::decode(&invite).map_err(WireError::new)?; - let f = node.friend(&p.pubkey).map_err(WireError::new)?; - Ok(FriendInfo { - pubkey_hex: hex(&f.pubkey), - fingerprint: f.fingerprint, - petname: f.petname, - onion: f.onion, - last_connect_ok: f.last_connect_ok, - pq: f.kem_pk.is_some(), - }) - } - - /// Local label. Pass `None` to clear. Never goes on the wire. - pub async fn set_petname(&self, pubkey_hex: String, petname: Option) -> WResult<()> { - let pk = unhex(&pubkey_hex)?; - self.node()? - .set_petname(&pk, petname.as_deref()) - .map_err(WireError::new) - } - - /// Send one chat message. - /// - /// Returns [`SendState::Sent`] when the frame reached the peer's onion - /// service during this call, and [`SendState::Queued`] when it did not: the - /// message is then in the local outbox and a background worker retries it - /// with exponential backoff (30s doubling, capped at 30 min, 8 attempts) - /// until it lands or ends terminally failed. A queued send is local-only — - /// show it as pending, not delivered. - /// - /// A protocol error (signature mismatch, malformed or oversize frame) is - /// not retryable and still fails here; nothing is queued in that case. - pub async fn send(&self, pubkey_hex: String, body: String) -> WResult { - let pk = unhex(&pubkey_hex)?; - let status = self - .node()? - .send(&pk, body.as_bytes()) - .await - .map_err(WireError::new)?; - Ok(send_state(status)) - } - - /// Chat history for a friend, oldest first. Bodies are decrypted here; - /// they are stored encrypted at rest. Outgoing rows carry their delivery - /// state in [`ChatMessage::delivery`]. - pub async fn messages(&self, pubkey_hex: String) -> WResult> { - let pk = unhex(&pubkey_hex)?; - let rows = self.node()?.list_messages(&pk).map_err(WireError::new)?; - let mut out = Vec::with_capacity(rows.len()); - for m in rows { - let status = self - .node()? - .outbox_status_of_message(m.id) - .map_err(WireError::new)?; - out.push(chat_message(m, status)); - } - Ok(out) - } - - /// Outbox rows for one friend that the core has not delivered yet: the - /// `"queued"` / `"sending"` / `"failed"` rows behind - /// [`ChatMessage::delivery`], with the core's own attempt counter and next - /// attempt time attached. - /// - /// This is what lets a chat row say *why* it is still queued — `try 3/8, - /// retry 45s` — instead of a flat `"queued"`: [`OutboxRow::attempts`] and - /// [`OutboxRow::next_attempt_at`] are read from the store, never guessed by - /// the client. An empty result means nothing is outstanding for that friend. - pub async fn outbox(&self, pubkey_hex: String) -> WResult> { - let pk = unhex(&pubkey_hex)?; - let rows = self.node()?.outbox_pending(&pk).map_err(WireError::new)?; - Ok(rows.iter().map(outbox_row).collect()) - } - - /// Delete every message body. Identity and friends survive. - pub async fn wipe_messages(&self) -> WResult<()> { - self.node()?.wipe_messages().map_err(WireError::new) - } - - /// Publish a NEW onion service and hard-cut the old one, then push a signed - /// location update to every reachable friend. - /// - /// The identity key does not change. Friends who are offline cannot find - /// you until they rescan your invite — that is the documented v1 behaviour, - /// not a bug. Confirm with a typed phrase in the UI; never one tap. - pub async fn rotate_onion(&self) -> WResult { - let r = self.node()?.rotate().await.map_err(WireError::new)?; - Ok(RotateOutcome { - notified: r.notified as u32, - friends: r.friends as u32, - }) - } - - /// SDK version, for diagnostics. - pub async fn version(&self) -> String { - env!("CARGO_PKG_VERSION").to_string() - } - - // ---- Wallet / payment surface (v1 Monero features) ---- - - /// Current wallet balance as a display string, or `"off"` / `"err"`. - /// - /// Returns `"off"` when the wallet is not configured (no `ONIONWIRE_WALLET_RPC`), - /// `"err"` when the wallet RPC call failed, and `"balance X.X XMR"` on success. - /// A stopped node (shut-down handle) returns `"off"` — the wallet is not - /// accessible without a live node, and the UI treats "off" as "wallet not - /// available" rather than an error state. - pub async fn wallet_balance(&self) -> String { - match self.node() { - Ok(node) => node.wallet_balance().await, - Err(_) => "off".to_string(), - } - } - - /// Receive address for the wallet screen: a freshly created subaddress when - /// the wallet is configured, else the profile `xmr_addr` fallback. - /// - /// Returns the raw address (not a `monero:` URI) so the QR render path can - /// decide how to wrap it. Returns `WireError.Stopped` on a shut-down handle, - /// `WireError.Failed` on RPC/profile errors. - pub async fn wallet_receive_address(&self) -> WResult { - let node = self.node()?; - node.wallet_receive_address().await.map_err(WireError::new) - } - - /// Recent in/out transfers for the wallet screen, newest first, capped to `cap`. - /// - /// Returns an empty list when the wallet is not configured (no transfers to show). - /// `amount` is formatted XMR, not raw piconero. - pub async fn wallet_recent_transfers(&self, cap: u32) -> WResult> { - let node = self.node()?; - let rows = node - .wallet_recent_transfers(cap as usize) - .await - .map_err(WireError::new)?; - Ok(rows - .into_iter() - .map(|r| TransferRow { - txid: r.txid, - amount: pay::atomic_to_xmr_str(&r.amount), - address: r.address, - }) - .collect()) - } - - // ---- Wallet catalogue, the open wallet, and its secrets ---- - - /// Every wallet this install remembers, oldest first. - /// - /// A store read: it never dials the wallet RPC or the chain, so it works - /// with the wallet child stopped or never configured. "No wallets" is an - /// empty list, never an error. `WireError.Stopped` after `shutdown`; - /// `WireError.Failed` only when the store itself cannot be read. - /// - /// The Kotlin binding is `Wire.wallets()`. - pub async fn wallets(&self) -> WResult> { - let rows = self.node()?.list_wallets().map_err(WireError::new)?; - Ok(rows.iter().map(wallet_row).collect()) - } - - /// Point the wallet child at a catalogue wallet's file: afterwards the - /// balance, transfers, seed and keys this surface reports are that - /// wallet's. - /// - /// **It may restart a running wallet child.** A live child is stopped and - /// started again onto the new file, which is what makes the change take - /// effect immediately — and why this call is slow (a `.onion` source waits - /// for its SOCKS listener, an in-process chain daemon for its RPC). An idle - /// child is only re-pointed: nothing is spawned, and the change applies at - /// the next [`Wire::start_wallet_child`]. - /// - /// A `filename` the catalogue does not hold is **refused**: the catalogue is - /// the only directory this app keeps wallets in, and a spend-capable child - /// is never pointed at a path a caller invented. Get the name from - /// [`Wire::wallets`]. `WireError.Stopped` after `shutdown`. - pub async fn open_wallet(&self, filename: String) -> WResult<()> { - self.node()?.open_wallet(&filename).map_err(WireError::new) - } - - /// Open a saved wallet with a passphrase the user just typed, and remember - /// it (sealed) once the wallet daemon has accepted it. - /// - /// This is what ends a [`WalletChildStatus`] with - /// `needs_passphrase = true` — a wallet created before the passphrase was - /// stored, or created on another install. After it succeeds, every later - /// [`Wire::start_wallet_child`] opens the file on its own. - /// - /// Same refusals as [`Wire::open_wallet`]: a `filename` the catalogue does - /// not hold, an empty passphrase, or no configured wallet RPC at all are - /// `WireError.Failed` before anything is dialled. A passphrase the daemon - /// refuses is reported as such, and is **not** stored — the file stays - /// `needs_passphrase`. Runs on `spawn_blocking`: the RPC can wait for a - /// freshly spawned child to bind. `WireError.Stopped` after `shutdown`. - pub async fn open_wallet_with_passphrase( - &self, - filename: String, - passphrase: String, - ) -> WResult<()> { - let node = self.node()?; - let blocking = node.clone(); - tokio::task::spawn_blocking(move || { - blocking.open_wallet_with_passphrase(&filename, &passphrase) - }) - .await - .map_err(|e| WireError::new(format!("open wallet join: {e}")))? - .map_err(WireError::new) - } - - /// The wallet file the child is currently pointed at, or `None` when no - /// wallet-child settings were ever stored (a fresh install has no open - /// wallet). - /// - /// A picker marks the open row with - /// `row.wallet_filename == active`; every other row means "open it first to - /// see its seed or keys", because the seed and the private keys always come - /// from the file the child has **open**. The value can name a file that is - /// not in the catalogue (an install whose wallet predates it) — that is "no - /// open wallet row", not an error. - /// - /// It never dials and never spawns. `WireError.Stopped` after `shutdown`. - pub async fn active_wallet_filename(&self) -> WResult> { - self.node()? - .active_wallet_filename() - .map_err(WireError::new) - } - - /// The private view key and spend key of the wallet file the child has - /// **open** (`query_key`). This is a dial to the wallet child's loopback - /// RPC, so call it from an explicit user action, not from a refresh loop. - /// - /// `spend_key` is `None` for a view-only wallet: the RPC answers `-29` - /// ("Cannot retrieve spend key") and that is the wallet's own answer, not a - /// failure, so it is not surfaced as one. `WireError.Failed` when no wallet - /// is configured or the child is not answering; `WireError.Stopped` after - /// `shutdown`. - /// - /// The values are spend secrets: show them, never log them, never persist - /// them. `WalletKeys`'s `Debug` redacts both. - pub async fn wallet_keys(&self) -> WResult { - let keys = self.node()?.wallet_keys().await.map_err(WireError::new)?; - Ok(keys_record(keys)) - } - - // ---- This identity's own profile ---- - - /// This identity's own profile (nickname, bio, Monero address) as stored. - /// - /// A store read: never dials. It is the local copy — what friends show for - /// you only changes once [`Wire::push_self_profile`] reaches them. - /// `WireError.Stopped` after `shutdown`. - pub async fn self_profile(&self) -> WResult { - let p = self.node()?.self_profile().map_err(WireError::new)?; - Ok(self_profile_record(&p)) - } - - /// Replace this identity's own profile. - /// - /// Validated before it is written, so a rejected edit leaves the stored - /// profile untouched: a nickname over 64 characters, a bio over 512, or a - /// non-empty address that fails the Monero checksum (the same check `/pay` - /// and `/tip` use) is refused with `WireError.Failed`. An empty address is - /// allowed. - /// - /// It does not tell anyone. Friends still see the previous profile until - /// [`Wire::push_self_profile`] is sent to them. `WireError.Stopped` after - /// `shutdown`. - pub async fn set_self_profile( - &self, - display_name: String, - bio: String, - xmr_addr: String, - ) -> WResult<()> { - self.node()? - .set_self_profile(&display_name, &bio, &xmr_addr) - .map_err(WireError::new) - } - - /// Send this identity's signed profile to one friend, so the nickname and - /// address they show for you are current. - /// - /// One-shot and fail closed: a peer whose onion is down means this fails - /// and **nothing is queued** — no retry, no outbox row (profiles are not - /// chat). Send it again when they are reachable. - /// - /// `pubkey_hex` is the friend's identity pubkey, the encoding - /// [`FriendInfo::pubkey_hex`] carries; an unparseable hex is - /// `WireError.Failed` before anything is dialled. `WireError.Stopped` after - /// `shutdown`. - pub async fn push_self_profile(&self, pubkey_hex: String) -> WResult<()> { - let pk = unhex(&pubkey_hex)?; - self.node()? - .push_self_profile(&pk) - .await - .map_err(WireError::new) - } - - /// Send an invoice to a friend: sign an invoice for my receive address and send - /// the frame one-shot. Peer onion down → this fails; invoices are not queued. - /// - /// `amount_xmr` is a user-facing XMR amount (e.g. `"0.5"`) — validated and - /// converted to piconero internally. `memo` may be empty. The invoice uses the - /// wallet subaddress if available, else the profile `xmr_addr` fallback. - pub async fn send_invoice( - &self, - pubkey_hex: String, - amount_xmr: String, - memo: String, - ) -> WResult<()> { - let pk = unhex(&pubkey_hex)?; - let atomic = pay::xmr_to_atomic(&amount_xmr).map_err(WireError::new)?; - self.node()? - .pay_invoice(&pk, &atomic, &memo) - .await - .map_err(WireError::new) - } - - /// Send a tip to a friend: transfer XMR from my wallet, then send a signed - /// receipt and tip frame, both one-shot. Peer onion down → this fails after - /// the chain transfer; tips are not queued. - /// - /// `amount_xmr` is a user-facing XMR amount. `memo` may be empty. The - /// recipient's Monero address is read from their profile. - /// - /// Requires the wallet to be configured (`ONIONWIRE_WALLET_RPC`). Fails when - /// the wallet is not connected, the friend has no Monero address, or the - /// amount is invalid. - pub async fn send_tip( - &self, - pubkey_hex: String, - amount_xmr: String, - memo: String, - ) -> WResult<()> { - let pk = unhex(&pubkey_hex)?; - let atomic = pay::xmr_to_atomic(&amount_xmr).map_err(WireError::new)?; - self.node()? - .tip(&pk, &atomic, &memo) - .await - .map_err(WireError::new) - } - - /// Create a new spend-capable wallet. Returns the 25-word seed once so the - /// UI can show a backup screen. The user does not paste a key on this path. - /// Requires `ONIONWIRE_WALLET_RPC` pointed at a `--wallet-dir` RPC. - /// - /// The core also records the new wallet in its catalogue (`Node::wallet_create` - /// returns the stored row); the seed is what this surface carries. - pub async fn create_wallet(&self, password: String) -> WResult { - Ok(self - .node()? - .wallet_create(&password) - .await - .map_err(WireError::new)? - .seed) - } - - /// Re-read this wallet's 25-word seed so the UI can offer a "back up seed" - /// action after creation. Dials the wallet child's RPC (`query_key - /// mnemonic`), so it is cheap but not free, and it needs a wallet the child - /// has open. The result is a spend key: call this only from an explicit - /// user action, show it, and do not persist or log it. - /// - /// The Kotlin binding is `Wire.walletSeed()`. - pub async fn wallet_seed(&self) -> WResult { - self.node()?.wallet_seed().await.map_err(WireError::new) - } - - /// Import a wallet from an existing 25-word seed. This is the only path - /// that takes a user-supplied secret. Like a create, the core records the - /// imported wallet in its catalogue. - /// - /// This is the plain import: the request carries no seed offset. Use - /// [`Wire::import_wallet_with_offset`] when the words were mixed with a - /// seed-offset passphrase. - pub async fn import_wallet(&self, password: String, seed: String) -> WResult<()> { - self.node()? - .wallet_restore(&password, &seed, None) - .await - .map_err(WireError::new) - .map(|_| ()) - } - - /// Import a wallet from an existing 25-word seed plus its optional seed - /// offset passphrase (`restore_deterministic_wallet`'s `seed_offset`). - /// - /// The offset is **not** the wallet-file passphrase: it is a second spend - /// secret mixed into the seed at restore time, so the same words with a - /// different offset open a different wallet. It is never logged, never - /// stored and never sealed, and a wrong offset does not fail — the RPC - /// succeeds and the wallet is simply a different one. - /// - /// Blank or whitespace-only `seed_offset` behaves exactly like - /// [`Wire::import_wallet`]: the request carries no `seed_offset` field. - pub async fn import_wallet_with_offset( - &self, - password: String, - seed: String, - seed_offset: String, - ) -> WResult<()> { - let offset = seed_offset.trim(); - let offset = if offset.is_empty() { - None - } else { - Some(offset) - }; - self.node()? - .wallet_restore(&password, &seed, offset) - .await - .map_err(WireError::new) - .map(|_| ()) - } - - /// Start the app-owned wallet child (`monero-wallet-rpc`, plus `monerod` for - /// a local chain source and `arti proxy` for a `.onion` daemon) and point - /// this node's wallet at it, then probe it once and return what it reached. - /// - /// The spawn itself is synchronous inside the node: argv is built, the - /// process is spawned, and a `.onion` source waits up to 20s for the SOCKS - /// listener. An in-process Cuprate launch is the same shape and can take - /// much longer. That work runs on `spawn_blocking` so it does not stall the - /// UniFFI tokio worker (Android: a blocked worker is a Start tap that never - /// returns). - /// - /// Idempotent: a live child is reported, not respawned. Fails with - /// `WireError.Failed` when no chain source is configured - /// (`set_chain_source`), when a binary cannot be spawned, or when the SOCKS - /// listener never came up. `WireError.Stopped` after `shutdown`. - /// - /// The returned state is `connecting` at best on the first call — the wallet - /// RPC is not answering the instant the process exists. Report it as it is, - /// and call [`Wire::wallet_status`] (or start again) for the later states. - pub async fn start_wallet_child(&self) -> WResult { - let node = self.node()?; - let blocking = node.clone(); - tokio::task::spawn_blocking(move || blocking.start_wallet_child()) - .await - .map_err(|e| WireError::new(format!("start wallet child join: {e}")))? - .map_err(WireError::new)?; - let source = node.wallet_child_config().source; - Ok(child_status(node.wallet_child_refresh().await, &source)) - } - - /// Stop the wallet child and its daemon/SOCKS siblings. Idempotent: stopping - /// what is not running is `Ok(())`. The wallet falls back to the stored or - /// env `monero-wallet-rpc` config, if any. - pub fn stop_wallet_child(&self) -> WResult<()> { - self.node()?.stop_wallet_child().map_err(WireError::new) - } - - /// The last observable wallet-child state. Never dials, never spawns: - /// `state` is `off` / `connecting` / `syncing` / `ready` / `exited`, and - /// `ready` is only ever written by a probe that saw a synced chain. - /// - /// Synchronous on purpose — it is safe to call from a UI refresh loop. - pub fn wallet_status(&self) -> WResult { - let node = self.node()?; - let source = node.wallet_child_config().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 { - 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. - /// Returns the defaults (receive-only, binaries by name) when nothing was - /// ever set, so a settings screen can prefill from it safely. - pub fn chain_source(&self) -> WResult { - Ok(chain_config(&self.node()?.wallet_child_config())) - } - - /// Set the chain source and the binaries the child runs. Validated before - /// anything is written: a rejected config leaves the stored one untouched - /// and a running child untouched (the change applies on the next start). - /// - /// This is a stored setting, not a start: call [`Wire::start_wallet_child`] - /// after it. `wallet_rpc_bin` / `arti_bin` take absolute paths on Android - /// (`context.applicationInfo.nativeLibraryDir`); the core never resolves a - /// binary the caller named explicitly. - pub fn set_chain_source(&self, config: ChainConfig) -> WResult<()> { - self.node()? - .set_wallet_child_config(&child_config(config, &self.home)) - .map_err(WireError::new) - } - - /// Sign an invoice frame with this node's identity key. - /// - /// The ed25519 secret stays inside the node: this is the only way the SDK - /// signs a payment frame and there is no method that hands the key out. - /// `amount_atomic` is piconero (`xmr_to_atomic` converts a typed amount). - /// Signing does not touch the network — carry the result with - /// [`encode_invoice`] and send it as chat bytes, or use the one-shot - /// [`Wire::send_invoice`], which signs, sends and records the chat line. - pub async fn sign_invoice( - &self, - amount_atomic: String, - address: String, - memo: String, - ) -> WResult { - self.node()? - .sign_invoice(&amount_atomic, &address, &memo) - .map(invoice_record) - .map_err(WireError::new) - } - - /// Sign a receipt frame for a transfer that already happened. Signing only, - /// never a transfer: this does not move funds. - pub async fn sign_receipt( - &self, - txid: String, - amount_atomic: String, - address: String, - ) -> WResult { - self.node()? - .sign_receipt(&txid, &amount_atomic, &address) - .map(receipt_record) - .map_err(WireError::new) - } - - /// Sign a tip frame (receipt plus memo) for a transfer that already - /// happened. Signing only, never a transfer. - pub async fn sign_tip( - &self, - txid: String, - amount_atomic: String, - address: String, - memo: String, - ) -> WResult { - self.node()? - .sign_tip(&txid, &amount_atomic, &address, &memo) - .map(tip_record) - .map_err(WireError::new) - } - - /// Spend-authority warning shown before create. Not a tooltip. - pub fn spend_authority_warning(&self) -> String { - onionwire::wallet::SPEND_AUTHORITY_WARNING.to_string() - } -} - -fn from_core_flush(o: CoreFlushOutcome) -> FlushOutcome { - FlushOutcome { - attempted: o.attempted as u32, - delivered: o.delivered as u32, - remaining: o.remaining as u32, - } -} - -/// The core child settings a [`ChainConfig`] describes. -/// -/// `home` is the `$ONIONWIRE_HOME` the identity was opened with. An in-process -/// chain source with an empty `monerod_datadir` resolves to `home/chain` — the -/// per-identity directory the core documents for a local chain — so a Kotlin -/// caller never has to invent an absolute path. Every other kind uses exactly -/// what it was given (or the core's own default), unchanged. -fn cuprate_chain_dir(home: &Path, mainnet: bool, prune: bool) -> PathBuf { - let name = match (mainnet, prune) { - (true, true) => "mainnet-pruned", - (true, false) => "mainnet-full", - (false, _) => "testnet", - }; - home.join("chain").join(name) -} - -fn child_config(cfg: ChainConfig, home: &Path) -> ChildConfig { - let source = match cfg.kind { - ChainChoice::None => ChainSource::None, - ChainChoice::Local => ChainSource::Local { - monerod_bin: PathBuf::from(cfg.monerod_bin), - datadir: PathBuf::from(cfg.monerod_datadir), - prune: cfg.prune, - }, - ChainChoice::InProcessCuprate => { - let network = if cfg.mainnet { - ChainNetwork::Mainnet - } else { - ChainNetwork::Testnet - }; - let prune = cfg.mainnet && cfg.prune; - ChainSource::InProcessCuprate { - datadir: if cfg.monerod_datadir.trim().is_empty() { - cuprate_chain_dir(home, cfg.mainnet, prune) - } else { - PathBuf::from(cfg.monerod_datadir) - }, - network, - prune, - } - } - ChainChoice::Remote => ChainSource::Remote { - host: cfg.host, - port: cfg.port, - }, - }; - ChildConfig { - source, - wallet_rpc_bin: PathBuf::from(cfg.wallet_rpc_bin), - arti_bin: PathBuf::from(cfg.arti_bin), - wallet_filename: cfg.wallet_filename, - } -} - -fn chain_config(cfg: &ChildConfig) -> ChainConfig { - let (kind, host, port, monerod_bin, monerod_datadir, mainnet, prune) = match &cfg.source { - ChainSource::None => ( - ChainChoice::None, - String::new(), - 0, - String::new(), - String::new(), - false, - false, - ), - ChainSource::Local { - monerod_bin, - datadir, - prune, - } => ( - ChainChoice::Local, - String::new(), - 0, - monerod_bin.display().to_string(), - datadir.display().to_string(), - true, - *prune, - ), - ChainSource::InProcessCuprate { - datadir, - network, - prune, - } => ( - ChainChoice::InProcessCuprate, - String::new(), - 0, - String::new(), - datadir.display().to_string(), - matches!(network, ChainNetwork::Mainnet), - *prune, - ), - ChainSource::Remote { host, port } => ( - ChainChoice::Remote, - host.clone(), - *port, - String::new(), - String::new(), - false, - false, - ), - }; - ChainConfig { - kind, - monerod_bin, - monerod_datadir, - host, - port, - wallet_rpc_bin: cfg.wallet_rpc_bin.display().to_string(), - arti_bin: cfg.arti_bin.display().to_string(), - wallet_filename: cfg.wallet_filename.clone(), - mainnet, - prune, - } -} - -/// The core child snapshot as the SDK record. -/// -/// `source` is the configured chain source the snapshot came from: it is what -/// makes the node-scoped fields possible without the core exposing a second -/// liveness signal for the in-process daemon. -fn child_status( - status: onionwire::wallet_child::WalletChildStatus, - source: &ChainSource, -) -> WalletChildStatus { - let in_process = matches!(source, ChainSource::InProcessCuprate { .. }); - WalletChildStatus { - state: status.state.as_str().to_string(), - running: status.running, - wallet_open: status.wallet_open, - needs_passphrase: status.needs_passphrase, - configured: status.configured, - chain_source: status.chain_source, - chain_in_process: in_process, - node_available: onionwire::cuprate::available(), - node_state: if in_process { - node_state(status.state).to_string() - } else { - String::new() - }, - height: status.height, - target_height: status.target_height, - last_error: status.last_error, - } -} - -/// The node-scoped word for the in-process daemon, derived from the core's own -/// child state. A projection, not a second state machine: no input here is a -/// timer, an env var, or a file. -/// -/// For an in-process source the wallet child is a client of *this app's* node, -/// so the core's own sequence is the node's: it cannot answer before the -/// daemon's loopback RPC is up (`connecting`), it answers but is behind the tip -/// while the daemon syncs (`syncing`), and `ready` requires a synced chain. -/// -/// Limit, stated rather than papered over: the core exposes no separate -/// liveness signal for the in-process node (it is a value this app owns, not a -/// process with a pid), so a daemon that dies *after* its wallet child came up -/// cannot be reported as `exited` — the chain probe fails and the state stays -/// `syncing`. It is never reported `ready`, and `exited` still means what it -/// says: the `monero-wallet-rpc` child is gone. -fn node_state(state: WalletChildState) -> &'static str { - match state { - WalletChildState::Off => "off", - WalletChildState::Connecting => "starting", - WalletChildState::Syncing => "syncing", - WalletChildState::Ready => "ready", - WalletChildState::Exited => "exited", - } -} - -fn hex(bytes: &[u8]) -> String { - let mut s = String::with_capacity(bytes.len() * 2); - for b in bytes { - s.push_str(&format!("{b:02x}")); - } - s -} - -fn unhex(s: &str) -> WResult> { - if s.is_empty() || !s.len().is_multiple_of(2) || !s.bytes().all(|c| c.is_ascii_hexdigit()) { - return Err(WireError::new("pubkey_hex must be even-length hex")); - } - (0..s.len()) - .step_by(2) - .map(|i| { - u8::from_str_radix(&s[i..i + 2], 16).map_err(|e| WireError::new(format!("hex: {e}"))) - }) - .collect() -} - -/// `Node::send` only ever yields `Sent` or `Queued`; `Sending`/`Failed` exist -/// only on stored outbox rows. Everything that is not a completed send maps to -/// `Queued`, so a status this build does not know about is never reported as -/// delivered — the fail-safe direction for a caller that hides its retry UI. -fn send_state(status: OutboxStatus) -> SendState { - match status { - OutboxStatus::Sent => SendState::Sent, - _ => SendState::Queued, - } -} - -/// One stored chat row as the record a client renders. `id` is copied through -/// untouched: it is the `messages.id` an [`OutboxRow::message_id`] joins to. -fn chat_message(m: Message, status: Option) -> ChatMessage { - ChatMessage { - id: m.id, - direction: m.dir.clone(), - body: String::from_utf8_lossy(&m.plaintext).into_owned(), - delivery: delivery_of(&m.dir, status), - } -} - -/// Delivery string for one stored chat row. `None` for incoming rows. An -/// outgoing row with no outbox row was accepted on the first attempt, so it is -/// reported as `"sent"` rather than left blank. -fn delivery_of(dir: &str, status: Option) -> Option { - if dir != "out" { - return None; - } - Some(match status { - None | Some(OutboxStatus::Sent) => "sent".to_string(), - Some(other) => other.to_string(), - }) -} - -/// One core outbox row as the record a client renders. -/// -/// Field-for-field, so the client shows the store's numbers instead of a -/// timeout it invented: the row is keyed by `message_id` (the chat row to -/// patch), carries the store's own status string, and next-attempt as an -/// absolute unix second for the client to count down from. -fn outbox_row(entry: &OutboxEntry) -> OutboxRow { - OutboxRow { - message_id: entry.message_id, - status: entry.status.as_db_str().to_string(), - attempts: entry.attempts, - next_attempt_at: entry.next_attempt_at, - last_error: entry.last_error.clone(), - } -} - -/// `WalletRecord` → the picker row. `wallet_filename` is the file name only -/// (never a path): the core resolves it inside `$ONIONWIRE_HOME/wallet`. -fn wallet_row(w: &WalletRecord) -> WalletRow { - WalletRow { - id: w.id, - name: w.name.clone(), - wallet_filename: w.wallet_filename.clone(), - onion_locator: w.onion_locator.clone(), - identity_pubkey_hex: hex(&w.identity_pubkey), - created_at: w.created_at, - } -} - -/// The core's key record → the SDK's, with the secrets carried across verbatim -/// (this is a display path; nothing here logs or stores them). -fn keys_record(keys: CoreWalletKeys) -> WalletKeys { - WalletKeys { - view_key: keys.view_key, - spend_key: keys.spend_key, - } -} - -/// `FriendProfile` → the profile screen's record. `updated_at` is deliberately -/// not carried: the SDK surface has no use for it, and a client that wants -/// "did my push land" compares the fields it set. -fn self_profile_record(p: &FriendProfile) -> SelfProfile { - SelfProfile { - display_name: p.display_name.clone(), - bio: p.bio.clone(), - xmr_addr: p.xmr_addr.clone(), - } -} - -/// A Monero transfer row for the wallet screen. -/// -/// `amount` is formatted XMR (not raw piconero) — the SDK formats it from the -/// core's piconero string so the UI never parses atomic units. -#[derive(Debug, Clone, uniffi::Record)] -pub struct TransferRow { - pub txid: String, - pub amount: String, - pub address: String, -} - -/// One row of the saved-wallet catalogue, for the wallet picker. -/// -/// Mirrors the core's `WalletRecord`, with the identity pubkey as hex. `id` is -/// the `wallets.id` row id, `wallet_filename` is the file inside -/// `$ONIONWIRE_HOME/wallet` and is what [`Wire::open_wallet`] takes, and the -/// rows come back oldest-first so a list is stable between calls. -/// -/// `identity_pubkey_hex` is the identity this wallet belongs to and is **not** -/// unique; `onion_locator` is a locator that may be empty or stale. Never key a -/// selection, or the roster, on the locator. -#[derive(Debug, Clone, PartialEq, Eq, uniffi::Record)] -pub struct WalletRow { - pub id: i64, - /// The user's label for this wallet. `None` when it was never named, and - /// never an empty string. - pub name: Option, - pub wallet_filename: String, - pub onion_locator: String, - /// The owning identity's ed25519 pubkey, hex — the same encoding - /// [`FriendInfo::pubkey_hex`] carries. - pub identity_pubkey_hex: String, - /// Unix seconds, assigned by the store when the row was created. - pub created_at: i64, -} - -/// The private keys of the **open** wallet file, for a backup screen. -/// -/// Both values are spend secrets: show them only from an explicit user action, -/// never log them, and never persist them. `Debug` is hand-written to redact -/// them so a stray `{:?}` cannot leak a key into a log. -#[derive(Clone, PartialEq, Eq, uniffi::Record)] -pub struct WalletKeys { - /// The open wallet file's private view key. - pub view_key: String, - /// The open wallet file's private spend key, or `None` for a view-only - /// wallet. `None` is the wallet's own answer — it has no spend key — and - /// not a failure. - pub spend_key: Option, -} - -/// Hand-written so a stray `{:?}` cannot print a private key. -impl std::fmt::Debug for WalletKeys { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("WalletKeys") - .field("view_key", &"") - .field("spend_key", &self.spend_key.as_ref().map(|_| "")) - .finish() - } -} - -/// This identity's own profile, as the profile screen reads and edits it. -/// -/// It is what friends are shown for this identity once it has been pushed; -/// nothing here is secret (an empty `xmr_addr` is allowed, a non-empty one is -/// validated). -#[derive(Debug, Clone, PartialEq, Eq, uniffi::Record)] -pub struct SelfProfile { - pub display_name: String, - pub bio: String, - /// This identity's Monero address. May be empty. When non-empty the core - /// refuses to store it unless it passes the same address check `/pay` and - /// `/tip` use. - pub xmr_addr: String, -} - -/// Where the app-owned wallet child gets its chain from. Mirrors the core's -/// `ChainSource`: nothing is implied — `Remote` is a daemon the user supplied. -#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Enum)] -pub enum ChainChoice { - /// Receive-only: no child, no daemon, no spend. - None, - /// The app spawns `monerod` on this device. - Local, - /// The chain daemon runs **inside this app** (Cuprate). No `monerod` binary. - /// Testnet only, and pre-production software — see the core's - /// `ChainSource::InProcessCuprate`. `monerod_datadir` is the chain data - /// directory for it, and no binary path is needed. - InProcessCuprate, - /// A daemon address the user supplied (loopback, `.onion`, or clearnet). - Remote, -} - -/// The wallet-child settings, as the Kotlin side sets them. -/// -/// One record for all four kinds: the fields a kind does not use are ignored -/// by that kind (`None` needs no binaries, `Local` needs `monerod_bin` and -/// `monerod_datadir`, `InProcessCuprate` needs only `monerod_datadir` as its -/// chain directory, `Remote` needs `host` and `port`). Persisted in the -/// encrypted store, so it survives a restart without env vars. -#[derive(Debug, Clone, uniffi::Record)] -pub struct ChainConfig { - pub kind: ChainChoice, - /// `Local` only. Absolute path on Android (`nativeLibraryDir`); a bare name - /// resolves on `PATH` on desktop. - pub monerod_bin: String, - /// `Local` only. Data directory for the local daemon. - /// - /// `InProcessCuprate` also uses this field, as the chain data directory the - /// in-process daemon stores its (fjall) chain in. For that kind an empty - /// string means "use the per-identity default" (`$ONIONWIRE_HOME/chain`, - /// resolved by the SDK), so Kotlin never has to invent an absolute path; - /// `Local` still requires a real one. - pub monerod_datadir: String, - /// `Remote` only. Daemon host. - pub host: String, - /// `Remote` only. Daemon port. - pub port: u16, - /// `monero-wallet-rpc`. Absolute path on Android, else resolved on `PATH`. - pub wallet_rpc_bin: String, - /// `arti`, run as the SOCKS child for a `.onion` daemon only. - pub arti_bin: String, - /// Wallet file name inside `$ONIONWIRE_HOME/wallet`. - pub wallet_filename: String, - /// Cuprate / local `monerod`: mainnet when true, testnet when false. - /// Ignored for Remote and None. Old records without the field stay testnet. - pub mainnet: bool, - /// Cuprate / local `monerod`: prune the chain. Ignored for Remote and None. - /// Once a Cuprate store is pruned it cannot be un-pruned — we keep pruned - /// and full in separate datadirs. - pub prune: bool, -} - -/// One snapshot of the app-owned wallet child. -/// -/// Derived from the real child process plus the last probe, never from env-var -/// presence. `state` is one of `off`, `connecting`, `syncing`, `ready`, -/// `exited`. `chain_source` is the label of the configured source: -/// `receive-only`, `local node`, `in-process node`, `remote onion daemon`, or -/// `remote daemon`. -#[derive(Debug, Clone, uniffi::Record)] -pub struct WalletChildStatus { - /// `off` until the child is started and again after it is stopped; `exited` - /// when a started child has died; `connecting` while its wallet RPC has not - /// answered; `syncing` once it has but the chain is behind; `ready` when - /// both hold. `ready` is never reported for a dead child. - pub state: String, - /// A `monero-wallet-rpc` child is alive right now. - pub running: bool, - /// The wallet **file** the child is pointed at is open in that RPC. A live - /// child is not a usable wallet: `monero-wallet-rpc` starts with no wallet - /// open, and every read then answers `-13 No wallet file`. `false` for an - /// off/exited child, and while `needs_passphrase` holds. - pub wallet_open: bool, - /// A saved wallet is configured but not open, because this install holds no - /// passphrase that opens it (or the one it holds was refused). Show the - /// passphrase prompt and call [`Wire::open_wallet_with_passphrase`]; it is - /// not a start failure and the child is still running. - pub needs_passphrase: bool, - /// A chain source is configured (anything but receive-only). - pub configured: bool, - /// The chain-source label. - pub chain_source: String, - /// The configured source runs the chain daemon **inside this app** (Cuprate) - /// rather than spawning `monerod` or dialling a remote one. When true, - /// `state` — and `node_state` — describe this app's own node *and* its - /// wallet child: there is no separate daemon process to report on, and the - /// wallet child is a client of the in-process node, not a peer of one. - pub chain_in_process: bool, - /// This build can actually start the in-process daemon (`cuprate-daemon`). - /// `false` means the option is offered by the store but a start can only - /// fail — grey it out before the user commits, do not start and catch. - pub node_available: bool, - /// The in-process daemon's own state, for a status line that names the - /// node: `off` / `starting` / `syncing` / `ready` / `exited`. Empty for - /// every other chain source, so a Kotlin line shows no node segment for a - /// spawned `monerod`. `starting` is the core's `connecting` read from the - /// node's side (the daemon's loopback RPC has not answered yet); it is - /// never persisted, polled from a file, or inferred from a timeout. - pub node_state: String, - /// Blocks the chain daemon had at the last probe, as the wallet RPC (or the - /// daemon itself, over loopback) reported them. `0` means unknown: never - /// probed, the child is off/exited, or the probe failed — it is not the - /// same as caught up, and it is never a wallet-scan height. - pub height: u64, - /// Blocks the daemon was syncing towards. `0` means the daemon reported - /// none (also not the same as caught up). - pub target_height: u64, - /// The last failure, display-ready. Never carries the generated login. - pub last_error: Option, -} - -/// One signed invoice frame: "pay me `amount_atomic` piconero at `address`". -/// -/// Mirrors `pay::Invoice`. `sig` is the raw 64-byte ed25519 signature, not hex, -/// so the frame re-encodes byte-for-byte. Sign it with [`Wire::sign_invoice`] -/// (the identity key never leaves the node), carry it with [`encode_invoice`], -/// and check an inbound one against the sender's pubkey with [`verify_invoice`]. -#[derive(Debug, Clone, PartialEq, Eq, uniffi::Record)] -pub struct Invoice { - /// Piconero as a decimal string. `xmr_to_atomic("0.5")` is the form to - /// build this from a typed amount. - pub amount_atomic: String, - pub address: String, - /// May be empty; must not contain a newline. - pub memo: String, - /// Unix seconds the frame was signed at. - pub ts: i64, - pub sig: Vec, -} - -/// One signed receipt frame: "transaction `txid` paid `amount_atomic` to -/// `address`". Mirrors `pay::Receipt`; same signing rules as [`Invoice`]. -#[derive(Debug, Clone, PartialEq, Eq, uniffi::Record)] -pub struct Receipt { - pub txid: String, - pub amount_atomic: String, - pub address: String, - pub ts: i64, - pub sig: Vec, -} - -/// One signed tip frame: a receipt plus the memo the sender attached. Mirrors -/// `pay::Tip`; same signing rules as [`Invoice`]. -#[derive(Debug, Clone, PartialEq, Eq, uniffi::Record)] -pub struct Tip { - pub txid: String, - pub amount_atomic: String, - pub address: String, - pub memo: String, - pub ts: i64, - pub sig: Vec, -} - -fn invoice_record(inv: pay::Invoice) -> Invoice { - Invoice { - amount_atomic: inv.amount_atomic, - address: inv.address, - memo: inv.memo, - ts: inv.ts, - sig: inv.sig, - } -} - -fn invoice_core(rec: Invoice) -> pay::Invoice { - pay::Invoice { - amount_atomic: rec.amount_atomic, - address: rec.address, - memo: rec.memo, - ts: rec.ts, - sig: rec.sig, - } -} - -fn receipt_record(rcp: pay::Receipt) -> Receipt { - Receipt { - txid: rcp.txid, - amount_atomic: rcp.amount_atomic, - address: rcp.address, - ts: rcp.ts, - sig: rcp.sig, - } -} - -fn receipt_core(rec: Receipt) -> pay::Receipt { - pay::Receipt { - txid: rec.txid, - amount_atomic: rec.amount_atomic, - address: rec.address, - ts: rec.ts, - sig: rec.sig, - } -} - -fn tip_record(tip: pay::Tip) -> Tip { - Tip { - txid: tip.txid, - amount_atomic: tip.amount_atomic, - address: tip.address, - memo: tip.memo, - ts: tip.ts, - sig: tip.sig, - } -} - -fn tip_core(rec: Tip) -> pay::Tip { - pay::Tip { - txid: rec.txid, - amount_atomic: rec.amount_atomic, - address: rec.address, - memo: rec.memo, - ts: rec.ts, - sig: rec.sig, - } -} - -/// Encode an invoice as the wire frame the peer decodes with -/// [`decode_invoice`]. Pass the bytes to [`Wire::send`]. -#[uniffi::export] -pub fn encode_invoice(invoice: Invoice) -> Vec { - pay::encode_invoice(&invoice_core(invoice)) -} - -/// Decode an invoice frame. `None` for another frame kind, a truncated frame or -/// other malformed bytes — decoding never panics. -#[uniffi::export] -pub fn decode_invoice(frame: Vec) -> Option { - pay::decode_invoice(&frame).map(invoice_record) -} - -/// Verify an invoice against the sender's ed25519 identity pubkey (lowercase -/// hex — the same key [`FriendInfo::pubkey_hex`] carries). `false` for a bad -/// signature, an edited frame, or a malformed key. -#[uniffi::export] -pub fn verify_invoice(pubkey_hex: String, invoice: Invoice) -> bool { - match unhex(&pubkey_hex) { - Ok(pk) => pay::verify_invoice(&pk, &invoice_core(invoice)), - Err(_) => false, - } -} - -/// Encode a receipt as the wire frame the peer decodes with -/// [`decode_receipt`]. -#[uniffi::export] -pub fn encode_receipt(receipt: Receipt) -> Vec { - pay::encode_receipt(&receipt_core(receipt)) -} - -/// Decode a receipt frame. `None` for another frame kind or malformed bytes. -#[uniffi::export] -pub fn decode_receipt(frame: Vec) -> Option { - pay::decode_receipt(&frame).map(receipt_record) -} - -/// Verify a receipt against the sender's ed25519 identity pubkey (hex). -#[uniffi::export] -pub fn verify_receipt(pubkey_hex: String, receipt: Receipt) -> bool { - match unhex(&pubkey_hex) { - Ok(pk) => pay::verify_receipt(&pk, &receipt_core(receipt)), - Err(_) => false, - } -} - -/// Encode a tip as the wire frame the peer decodes with [`decode_tip`]. -#[uniffi::export] -pub fn encode_tip(tip: Tip) -> Vec { - pay::encode_tip(&tip_core(tip)) -} - -/// Decode a tip frame. `None` for another frame kind or malformed bytes. -#[uniffi::export] -pub fn decode_tip(frame: Vec) -> Option { - pay::decode_tip(&frame).map(tip_record) -} - -/// Verify a tip against the sender's ed25519 identity pubkey (hex). -#[uniffi::export] -pub fn verify_tip(pubkey_hex: String, tip: Tip) -> bool { - match unhex(&pubkey_hex) { - Ok(pk) => pay::verify_tip(&pk, &tip_core(tip)), - Err(_) => false, - } -} - -/// Convert a user-facing XMR amount string to a piconero string. -/// -/// Accepts `"0.5"`, `"1"`, `"0.001"` etc. Returns the piconero string on -/// success so the caller can pass it to the payment send methods. Fails on -/// empty, non-numeric, zero, or out-of-range input. -#[uniffi::export] -pub fn xmr_to_atomic(amount_xmr: String) -> WResult { - pay::xmr_to_atomic(&amount_xmr).map_err(WireError::new) -} - -/// Format a piconero string as a human-readable XMR string. -/// -/// The core stores amounts as piconero strings; this is what the wallet screen -/// renders. `"0"` → `"0"`, `"1000000000000"` → `"1"`, `"150000000000"` → `"0.15"`. -#[uniffi::export] -pub fn atomic_to_xmr_str(amount_atomic: String) -> String { - pay::atomic_to_xmr_str(&amount_atomic) -} - -/// Check whether a string is a valid Monero address. -/// -/// Validates checksum and prefix byte. Used by the UI to reject typos before -/// sending a payment. Both standard and integrated addresses are accepted. -#[uniffi::export] -pub fn check_address(address: String) -> WResult<()> { - pay::check_address(&address).map_err(WireError::new) -} - -#[cfg(test)] -mod tests { - //! No Tor here on purpose: these exercise the *lifecycle* contract of the - //! handle, which is what a shut-down node must guarantee. A `Wire` with no - //! node is exactly the state `shutdown()` leaves behind. - use super::*; - use onionwire::outbox::OutboxStatus; - use onionwire::{NewWallet, Store}; - use std::path::PathBuf; - use std::sync::atomic::{AtomicUsize, Ordering}; - - fn stopped_wire() -> Wire { - Wire { - node: Mutex::new(None), - home: PathBuf::from("/tmp/onionwire-sdk-stopped"), - } - } - - fn block_on(f: F) -> F::Output { - // No `macros` feature on tokio in this crate, so build the runtime. - tokio::runtime::Builder::new_current_thread() - .build() - .expect("runtime") - .block_on(f) - } - - #[test] - fn a_v2_invite_round_trips_through_decode_invite() { - let onion = "abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion"; - let invite = onionwire::qr::encode(&[7u8; 32], onion, &[1u8; 32], &[9u8; 1184]) - .expect("encode v2"); - let info = decode_invite(invite).expect("decode v2"); - assert_eq!(info.onion, onion); - assert_eq!(info.pubkey_hex.len(), 64); - assert!(info.pq, "a v2 invite carries the ML-KEM key"); - } - - #[test] - fn tor_state_of_a_stopped_handle_is_stopped() { - assert_eq!(stopped_wire().tor_state(), TorState::Stopped); - } - - #[test] - fn calls_after_shutdown_are_typed_errors_not_panics() { - let wire = stopped_wire(); - - let err = block_on(wire.flush()).expect_err("flush after shutdown must fail"); - assert!( - matches!(err, WireError::Stopped { .. }), - "flush returned {err:?}, want WireError::Stopped" - ); - - let err = block_on(wire.send("00".repeat(32), "hi".to_string())) - .expect_err("send after shutdown must fail"); - assert!( - matches!(err, WireError::Stopped { .. }), - "send returned {err:?}, want WireError::Stopped" - ); - - let err = block_on(wire.friends()).expect_err("friends after shutdown must fail"); - assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}"); - - let err = block_on(wire.shutdown()).expect_err("second shutdown must not re-run"); - assert!( - matches!(err, WireError::Stopped { .. }), - "second shutdown returned {err:?}" - ); - } - - #[test] - fn tor_state_maps_every_core_state() { - assert_eq!( - TorState::from(CoreTorState::Bootstrapping), - TorState::Bootstrapping - ); - assert_eq!(TorState::from(CoreTorState::Published), TorState::Published); - assert_eq!( - TorState::from(CoreTorState::DegradedReachable), - TorState::DegradedReachable - ); - assert_eq!(TorState::from(CoreTorState::Stopped), TorState::Stopped); - } - - #[test] - fn sent_is_sent_everything_else_is_queued() { - assert_eq!(send_state(OutboxStatus::Sent), SendState::Sent); - assert_eq!(send_state(OutboxStatus::Queued), SendState::Queued); - // `Node::send` never returns these today, but they exist on stored - // rows. Unknown states map to `Queued` — the safe direction: never - // report a send as delivered unless the core says `Sent`. - assert_eq!(send_state(OutboxStatus::Sending), SendState::Queued); - assert_eq!( - send_state(OutboxStatus::Failed("no route".into())), - SendState::Queued - ); - } - - #[test] - fn delivery_is_reported_for_outgoing_rows_only() { - assert_eq!(delivery_of("in", Some(OutboxStatus::Queued)), None); - // Outgoing row with no outbox row: delivered on the first attempt. - assert_eq!(delivery_of("out", None).as_deref(), Some("sent")); - assert_eq!( - delivery_of("out", Some(OutboxStatus::Sent)).as_deref(), - Some("sent") - ); - assert_eq!( - delivery_of("out", Some(OutboxStatus::Queued)).as_deref(), - Some("queued") - ); - assert_eq!( - delivery_of("out", Some(OutboxStatus::Sending)).as_deref(), - Some("sending") - ); - assert_eq!( - delivery_of("out", Some(OutboxStatus::Failed("no route".into()))).as_deref(), - Some("failed: no route") - ); - } - - /// One core outbox row with only the fields a record carries filled in - /// interestingly. `id`, `friend_pk`, `body` and `created_at` do not cross - /// UniFFI, so their values are irrelevant. - fn entry(status: OutboxStatus, attempts: u32, last_error: Option<&str>) -> OutboxEntry { - OutboxEntry { - id: 3, - friend_pk: vec![0xaa; 32], - message_id: 42, - body: b"hello".to_vec(), - payload: None, - attempts, - next_attempt_at: 1_700_000_045, - created_at: 1_700_000_000, - status, - last_error: last_error.map(str::to_string), - } - } - - #[test] - fn outbox_row_carries_the_join_key_the_attempt_count_and_the_next_attempt_time() { - let row = outbox_row(&entry( - OutboxStatus::Queued, - 3, - Some("peer onion unreachable"), - )); - assert_eq!(row.message_id, 42); - assert_eq!(row.status, "queued"); - assert_eq!(row.attempts, 3); - assert_eq!(row.next_attempt_at, 1_700_000_045); - assert_eq!(row.last_error.as_deref(), Some("peer onion unreachable")); - } - - #[test] - fn outbox_row_keeps_the_stores_own_status_encoding() { - // These four strings are the `outbox.status` CHECK constraint in - // `src/store.rs`; a client switches on them verbatim. - for (status, want) in [ - (OutboxStatus::Queued, "queued"), - (OutboxStatus::Sending, "sending"), - (OutboxStatus::Sent, "sent"), - ( - OutboxStatus::Failed("peer onion unreachable".into()), - "failed", - ), - ] { - assert_eq!(outbox_row(&entry(status, 0, None)).status, want); - } - } - - #[test] - fn a_failed_outbox_row_carries_the_cores_reason_verbatim() { - let row = outbox_row(&entry( - OutboxStatus::Failed("peer onion unreachable".into()), - 8, - Some("peer onion unreachable"), - )); - assert_eq!(row.status, "failed"); - assert_eq!(row.attempts, 8); - assert_eq!(row.last_error.as_deref(), Some("peer onion unreachable")); - } - - #[test] - fn outbox_max_attempts_is_the_denominator_a_client_renders_against() { - // The Android chat row renders `try n/8`. Pin the number so the SDK and - // the core's retry budget cannot drift apart silently. - assert_eq!(outbox_max_attempts(), 8); - } - - /// An empty dir for a store-backed test. `tempfile` is not a dependency of - /// this crate and a store only needs somewhere private to live. - fn temp_home() -> PathBuf { - static NEXT: AtomicUsize = AtomicUsize::new(0); - let dir = std::env::temp_dir().join(format!( - "onionwire-sdk-join-{}-{}", - std::process::id(), - NEXT.fetch_add(1, Ordering::Relaxed) - )); - let _ = std::fs::remove_dir_all(&dir); - dir - } - - /// The property the Android client joins on: a chat row and the outbox row - /// behind it report the same `messages.id`. Reads both sides out of a real - /// store through the same helpers `Wire::messages` / `Wire::outbox` use, so - /// a client can match on the id instead of counting rows. - #[test] - fn a_chat_row_joins_to_its_outbox_row_by_message_id() { - let home = temp_home(); - let store = Store::open_at_with_passphrase(&home, "join-key-pass").unwrap(); - let friend = [0x11u8; 32]; - store.upsert_friend(&friend, "peer.onion", None).unwrap(); - let row_id = store - .append_message_id(&friend, "out", b"still queued") - .unwrap(); - store - .enqueue_outbox( - &friend, - row_id, - 3, - 1_700_000_045, - "peer onion unreachable", - 1_700_000_000, - ) - .unwrap(); - - // Same two reads `Wire::messages` / `Wire::outbox` do. - let mut messages = Vec::new(); - for m in store.list_messages(&friend).unwrap() { - let status = store.outbox_status_of_message(m.id).unwrap(); - messages.push(chat_message(m, status)); - } - let rows: Vec = store - .pending_outbox(&friend) - .unwrap() - .iter() - .map(outbox_row) - .collect(); - - assert_eq!(messages.len(), 1); - assert_eq!(rows.len(), 1); - // The outbox side really is the stored row (not a defaulted id) … - assert_eq!(rows[0].message_id, row_id); - // … and the id the client gets on the message is that same row id. - assert_eq!(messages[0].id, rows[0].message_id); - // Both sides describe the same row, queued with its attempt count. - assert_eq!(messages[0].delivery.as_deref(), Some("queued")); - assert_eq!(rows[0].attempts, 3); - - std::fs::remove_dir_all(&home).ok(); - } - - #[test] - fn wallet_balance_on_stopped_handle_returns_off() { - // A stopped/shut-down handle has no node, so the wallet is inaccessible. - // The UI treats "off" as "wallet not available" — same as "not configured". - assert_eq!(block_on(stopped_wire().wallet_balance()), "off"); - } - - #[test] - fn wallet_receive_address_on_stopped_handle_is_stopped_error() { - let err = block_on(stopped_wire().wallet_receive_address()).expect_err("must fail"); - assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}"); - } - - #[test] - fn wallet_recent_transfers_on_stopped_handle_is_stopped_error() { - let err = block_on(stopped_wire().wallet_recent_transfers(8)).expect_err("must fail"); - assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}"); - } - - #[test] - fn xmr_to_atomic_rejects_zero() { - assert!(xmr_to_atomic("0".to_string()).is_err()); - } - - #[test] - fn xmr_to_atomic_accepts_one_xmr() { - assert_eq!(xmr_to_atomic("1".to_string()).unwrap(), "1000000000000"); - } - - #[test] - fn xmr_to_atomic_accepts_fractional_xmr() { - assert_eq!(xmr_to_atomic("0.5".to_string()).unwrap(), "500000000000"); - } - - #[test] - fn atomic_to_xmr_str_formats_correctly() { - assert_eq!(atomic_to_xmr_str("1000000000000".to_string()), "1"); - assert_eq!(atomic_to_xmr_str("500000000000".to_string()), "0.5"); - assert_eq!(atomic_to_xmr_str("0".to_string()), "0"); - } - - #[test] - fn check_address_accepts_valid_address() { - // Standard mainnet address from tests/pay.rs (same spend/view keys). - assert!(check_address( - "4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYTRj5UzqtReoS44qo9mtmXCqY45DJ852K5Jv2684Rge" - .to_string() - ) - .is_ok()); - } - - #[test] - fn check_address_rejects_invalid_address() { - assert!(check_address("not-an-address".to_string()).is_err()); - } - - // ---- pay.rs surface: Invoice / Receipt / Tip frames ---- - - /// A throwaway identity for the signing half, without Arti or a store: - /// `session::Keys::generate` is the core's own generator and hands out both - /// the secret half the signer needs and the public half a verifier needs. - fn test_keys() -> onionwire::session::Keys { - onionwire::session::Keys::generate() - } - - /// Same mainnet address the address tests use. - const ADDR: &str = "4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYTRj5UzqtReoS44qo9mtmXCqY45DJ852K5Jv2684Rge"; - - fn signed_invoice(k: &onionwire::session::Keys) -> pay::Invoice { - pay::sign_invoice(&k.identity_sk, "500000000000", ADDR, "lunch", 1_700_000_000) - .expect("sign_invoice") - } - - fn signed_receipt(k: &onionwire::session::Keys) -> pay::Receipt { - pay::sign_receipt(&k.identity_sk, "ab12", "500000000000", ADDR, 1_700_000_000) - .expect("sign_receipt") - } - - fn signed_tip(k: &onionwire::session::Keys) -> pay::Tip { - pay::sign_tip( - &k.identity_sk, - "ab12", - "500000000000", - ADDR, - "lunch", - 1_700_000_000, - ) - .expect("sign_tip") - } - - #[test] - fn invoice_record_round_trips_through_encode_and_decode() { - let k = test_keys(); - let core = signed_invoice(&k); - let rec = invoice_record(core.clone()); - - // The record carries the core's fields, not defaults. - assert_eq!(rec.amount_atomic, "500000000000"); - assert_eq!(rec.address, ADDR); - assert_eq!(rec.memo, "lunch"); - assert_eq!(rec.ts, 1_700_000_000); - assert_eq!(rec.sig, core.sig); - - // Encoding the record is byte-identical to encoding the core frame … - let pt = encode_invoice(rec.clone()); - assert_eq!(pt, pay::encode_invoice(&core)); - // … and the frame decodes back to the same record. - assert_eq!(decode_invoice(pt).as_ref(), Some(&rec)); - } - - #[test] - fn receipt_record_round_trips_through_encode_and_decode() { - let k = test_keys(); - let core = signed_receipt(&k); - let rec = receipt_record(core.clone()); - - assert_eq!(rec.txid, "ab12"); - assert_eq!(rec.amount_atomic, "500000000000"); - assert_eq!(rec.address, ADDR); - assert_eq!(rec.ts, 1_700_000_000); - - let pt = encode_receipt(rec.clone()); - assert_eq!(pt, pay::encode_receipt(&core)); - assert_eq!(decode_receipt(pt).as_ref(), Some(&rec)); - } - - #[test] - fn tip_record_round_trips_through_encode_and_decode() { - let k = test_keys(); - let core = signed_tip(&k); - let rec = tip_record(core.clone()); - - assert_eq!(rec.txid, "ab12"); - assert_eq!(rec.memo, "lunch"); - - let pt = encode_tip(rec.clone()); - assert_eq!(pt, pay::encode_tip(&core)); - assert_eq!(decode_tip(pt).as_ref(), Some(&rec)); - } - - #[test] - fn a_frame_verifies_against_the_signers_pubkey_only() { - let k = test_keys(); - let other = test_keys(); - let rec = invoice_record(signed_invoice(&k)); - - assert!(verify_invoice(hex(&k.identity_pk), rec.clone())); - assert!(!verify_invoice(hex(&other.identity_pk), rec.clone())); - // A malformed key is a failed verification, not a panic. - assert!(!verify_invoice("zz".to_string(), rec)); - } - - #[test] - fn receipt_and_tip_verify_against_the_signers_pubkey_only() { - let k = test_keys(); - let other = test_keys(); - let pk = hex(&k.identity_pk); - let wrong = hex(&other.identity_pk); - - let rcp = receipt_record(signed_receipt(&k)); - assert!(verify_receipt(pk.clone(), rcp.clone())); - assert!(!verify_receipt(wrong.clone(), rcp)); - - let tip = tip_record(signed_tip(&k)); - assert!(verify_tip(pk, tip.clone())); - assert!(!verify_tip(wrong, tip)); - } - - #[test] - fn verification_rejects_a_frame_whose_amount_was_edited() { - let k = test_keys(); - let pk = hex(&k.identity_pk); - - let mut inv = invoice_record(signed_invoice(&k)); - inv.amount_atomic = "900000000000".to_string(); - assert!(!verify_invoice(pk.clone(), inv)); - - let mut tip = tip_record(signed_tip(&k)); - tip.address = ADDR.replace("4AdUnd", "4AdUne"); - assert!(!verify_tip(pk, tip)); - } - - #[test] - fn decode_rejects_a_foreign_or_truncated_frame() { - let k = test_keys(); - assert_eq!(decode_invoice(b"nonsense".to_vec()), None); - // A tip frame is not an invoice frame. - assert_eq!(decode_invoice(encode_tip(tip_record(signed_tip(&k)))), None); - // The prefix without its fields is not a frame either. - let mut truncated = encode_receipt(receipt_record(signed_receipt(&k))); - truncated.truncate(10); - assert_eq!(decode_receipt(truncated), None); - } - - #[test] - fn payment_signing_after_shutdown_is_a_typed_error() { - let wire = stopped_wire(); - for err in [ - block_on(wire.sign_invoice("500000000000".into(), ADDR.into(), String::new())) - .unwrap_err(), - block_on(wire.sign_receipt("ab12".into(), "500000000000".into(), ADDR.into())) - .unwrap_err(), - block_on(wire.sign_tip( - "ab12".into(), - "500000000000".into(), - ADDR.into(), - String::new(), - )) - .unwrap_err(), - ] { - assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}"); - } - } - - /// The `$ONIONWIRE_HOME` a caller opened the identity with. `Wire` keeps it - /// internally; these tests drive the same two pure helpers - /// `set_chain_source` / `chain_source` go through. - fn sdk_home() -> PathBuf { - PathBuf::from("/data/user/0/dev.sirius.onionwire/files") - } - - /// A request as Kotlin builds one: only the fields the chosen kind uses are - /// set. - fn request(kind: ChainChoice, datadir: &str) -> ChainConfig { - ChainConfig { - kind, - monerod_bin: String::new(), - monerod_datadir: datadir.to_string(), - host: String::new(), - port: 0, - wallet_rpc_bin: "/data/app/nativeLibraryDir/libmonerowalletrpc.so".to_string(), - arti_bin: "/data/app/nativeLibraryDir/libarti.so".to_string(), - wallet_filename: "wallet".to_string(), - mainnet: false, - prune: false, - } - } - - /// Kotlin must not have to invent a chain data directory: an empty - /// `monerod_datadir` on the in-process source resolves to the per-identity - /// `chain` directory the core documents (`$ONIONWIRE_HOME/chain`), and no - /// binary path is involved at all. - #[test] - fn an_empty_in_process_datadir_resolves_under_the_wire_home() { - let child = child_config(request(ChainChoice::InProcessCuprate, ""), &sdk_home()); - assert_eq!( - child.source, - ChainSource::InProcessCuprate { - datadir: sdk_home().join("chain").join("testnet"), - network: ChainNetwork::Testnet, - prune: false, - } - ); - assert_eq!(child.source_label(), "in-process testnet"); - } - - #[test] - fn child_config_mainnet_pruned_uses_its_own_datadir() { - let mut req = request(ChainChoice::InProcessCuprate, ""); - req.mainnet = true; - req.prune = true; - let child = child_config(req, &sdk_home()); - assert_eq!( - child.source, - ChainSource::InProcessCuprate { - datadir: sdk_home().join("chain").join("mainnet-pruned"), - network: ChainNetwork::Mainnet, - prune: true, - } - ); - assert_eq!(child.source_label(), "in-process mainnet pruned"); - let back = chain_config(&child); - assert!(back.mainnet); - assert!(back.prune); - } - - #[test] - fn child_config_mainnet_full_uses_its_own_datadir() { - let mut req = request(ChainChoice::InProcessCuprate, ""); - req.mainnet = true; - req.prune = false; - let child = child_config(req, &sdk_home()); - assert_eq!( - child.source, - ChainSource::InProcessCuprate { - datadir: sdk_home().join("chain").join("mainnet-full"), - network: ChainNetwork::Mainnet, - prune: false, - } - ); - assert_eq!(child.source_label(), "in-process mainnet full"); - } - - #[test] - fn an_explicit_in_process_datadir_is_taken_as_given() { - let given = "/data/user/0/dev.sirius.onionwire/files/chain-heavy"; - let child = child_config(request(ChainChoice::InProcessCuprate, given), &sdk_home()); - assert_eq!( - child.source, - ChainSource::InProcessCuprate { - datadir: PathBuf::from(given), - network: ChainNetwork::Testnet, - prune: false, - } - ); - } - - /// Every kind survives the round trip a settings screen does (`ChainConfig` - /// -> core `ChildConfig` -> `ChainConfig`), so a prefill shows what was - /// stored rather than a default. - #[test] - fn every_chain_choice_round_trips_through_the_sdk_mapping() { - for kind in [ - ChainChoice::None, - ChainChoice::Local, - ChainChoice::InProcessCuprate, - ChainChoice::Remote, - ] { - let mut req = request(kind, ""); - match kind { - ChainChoice::Local => { - req.monerod_bin = "/data/app/nativeLibraryDir/libmonerod.so".to_string(); - req.monerod_datadir = sdk_home().join("chain").display().to_string(); - } - ChainChoice::Remote => { - req.host = "peer.onion".to_string(); - req.port = 18081; - } - ChainChoice::None | ChainChoice::InProcessCuprate => {} - } - let back = chain_config(&child_config(req.clone(), &sdk_home())); - assert_eq!(back.kind, kind, "kind lost for {kind:?}"); - assert_eq!(back.wallet_rpc_bin, req.wallet_rpc_bin); - assert_eq!(back.arti_bin, req.arti_bin); - assert_eq!(back.wallet_filename, req.wallet_filename); - match kind { - ChainChoice::InProcessCuprate => { - assert_eq!( - back.monerod_datadir, - sdk_home().join("chain").join("testnet").display().to_string() - ); - assert!( - back.monerod_bin.is_empty(), - "no binary for an in-process node" - ); - } - ChainChoice::Local => { - assert_eq!(back.monerod_bin, req.monerod_bin); - assert_eq!(back.monerod_datadir, req.monerod_datadir); - } - ChainChoice::Remote => { - assert_eq!(back.host, "peer.onion"); - assert_eq!(back.port, 18081); - } - ChainChoice::None => { - assert_eq!(back.monerod_datadir, ""); - assert_eq!(back.host, ""); - } - } - } - } - - fn core_status(state: WalletChildState) -> onionwire::wallet_child::WalletChildStatus { - onionwire::wallet_child::WalletChildStatus { - state, - running: true, - wallet_open: true, - needs_passphrase: false, - configured: true, - chain_source: "in-process node".to_string(), - height: 0, - target_height: 0, - last_error: None, - } - } - - /// `wallet_status` speaks about the app's own node for the in-process - /// source: the five core states map to node-scoped words, and no state - /// becomes `ready` that the core did not report as ready. - #[test] - fn node_state_names_the_apps_own_chain_for_the_in_process_source() { - let source = ChainSource::InProcessCuprate { - datadir: sdk_home().join("chain").join("testnet"), - network: ChainNetwork::Testnet, - prune: false, - }; - let cases = [ - (WalletChildState::Off, "off"), - (WalletChildState::Connecting, "starting"), - (WalletChildState::Syncing, "syncing"), - (WalletChildState::Ready, "ready"), - (WalletChildState::Exited, "exited"), - ]; - for (state, want) in cases { - let status = child_status(core_status(state), &source); - assert_eq!(status.node_state, want, "state {state:?}"); - assert!(status.chain_in_process, "state {state:?}"); - // The core's own word is still carried verbatim, for a caller that - // renders `state` instead. - assert_eq!(status.state, state.as_str()); - } - } - - /// A source that is not the in-process node reports no node segment, so a - /// Kotlin status line cannot show a node word for a spawned `monerod` or a - /// remote daemon — and `state` still passes straight through. - #[test] - fn node_state_is_empty_for_every_other_chain_source() { - for source in [ - ChainSource::None, - ChainSource::Local { - monerod_bin: PathBuf::from("monerod"), - datadir: PathBuf::from("/chain"), - prune: false, - }, - ChainSource::Remote { - host: "peer.onion".to_string(), - port: 18081, - }, - ] { - let status = child_status(core_status(WalletChildState::Ready), &source); - assert!( - !status.chain_in_process, - "{} is not in-process", - source.label() - ); - assert_eq!( - status.node_state, - "", - "{} must have no node state", - source.label() - ); - assert_eq!(status.state, "ready"); - } - } - - /// Whether *this* build can start the node is a build fact the picker greys - /// the option out with before a start is attempted. - #[test] - fn node_available_reports_whether_this_build_has_the_daemon() { - let status = child_status(core_status(WalletChildState::Off), &ChainSource::None); - assert_eq!(status.node_available, onionwire::cuprate::available()); - } - - /// The chain's own progress reaches Kotlin: a snapshot that carries the - /// daemon's height and target copies both numbers onto the record, so an - /// Android status line can show `1160/3090939` without a second probe. - #[test] - fn the_daemons_height_and_target_reach_the_sdk_record() { - let mut core = core_status(WalletChildState::Connecting); - core.height = 1160; - core.target_height = 3_090_939; - let status = child_status(core, &ChainSource::None); - assert_eq!(status.height, 1160); - assert_eq!(status.target_height, 3_090_939); - // The core's own word still passes straight through: the numbers are an - // addition, not a second state machine. - assert_eq!(status.state, "connecting"); - } - - /// A snapshot with nothing to report keeps `0/0`: unknown is not caught up, - /// and no percentage is invented on the way out. - #[test] - fn an_unprobed_child_reports_an_unknown_chain_progress() { - let status = child_status(core_status(WalletChildState::Off), &ChainSource::None); - assert_eq!(status.height, 0); - assert_eq!(status.target_height, 0); - } - - /// The two states a client has to tell apart, mapped from the core: a child - /// whose wallet file is open, and one that is live but waiting for its - /// passphrase (a wallet created before the passphrase was stored). - #[test] - fn a_locked_wallet_is_reported_as_needing_a_passphrase_not_as_off() { - let locked = onionwire::wallet_child::WalletChildStatus { - state: WalletChildState::Connecting, - running: true, - wallet_open: false, - needs_passphrase: true, - configured: true, - chain_source: "remote daemon".to_string(), - height: 0, - target_height: 0, - last_error: Some("wallet file onionwire-1 is not open".to_string()), - }; - let got = child_status(locked, &ChainSource::None); - assert!( - got.running, - "the child is up, it is the wallet that is not open" - ); - assert!(!got.wallet_open, "{got:?}"); - assert!(got.needs_passphrase, "{got:?}"); - assert_eq!(got.state, "connecting"); - - let open = onionwire::wallet_child::WalletChildStatus { - wallet_open: true, - needs_passphrase: false, - last_error: None, - ..core_status(WalletChildState::Ready) - }; - let got = child_status(open, &ChainSource::None); - assert!(got.wallet_open, "{got:?}"); - assert!(!got.needs_passphrase, "{got:?}"); - } - - /// 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, - wallet_open: false, - needs_passphrase: 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, - wallet_open: false, - needs_passphrase: 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.wallet_open, want.wallet_open); - assert_eq!(got.needs_passphrase, want.needs_passphrase); - 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:?}"); - } - - // ---- wallet catalogue, the open wallet, its keys, and the self profile ---- - - #[test] - fn wallets_on_a_stopped_handle_is_stopped_error() { - let err = block_on(stopped_wire().wallets()).expect_err("must fail"); - assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}"); - } - - #[test] - fn open_wallet_on_a_stopped_handle_is_stopped_error() { - let err = - block_on(stopped_wire().open_wallet("onionwire".to_string())).expect_err("must fail"); - assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}"); - } - - #[test] - fn active_wallet_filename_on_a_stopped_handle_is_stopped_error() { - let err = block_on(stopped_wire().active_wallet_filename()).expect_err("must fail"); - assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}"); - } - - #[test] - fn wallet_keys_on_a_stopped_handle_is_stopped_error() { - let err = block_on(stopped_wire().wallet_keys()).expect_err("must fail"); - assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}"); - } - - #[test] - fn self_profile_on_a_stopped_handle_is_stopped_error() { - let err = block_on(stopped_wire().self_profile()).expect_err("must fail"); - assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}"); - } - - #[test] - fn set_self_profile_on_a_stopped_handle_is_stopped_error() { - let err = block_on(stopped_wire().set_self_profile( - "nick".to_string(), - String::new(), - String::new(), - )) - .expect_err("must fail"); - assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}"); - } - - #[test] - fn push_self_profile_on_a_stopped_handle_is_stopped_error() { - // Valid 32-byte hex, so the hex parse cannot be the thing that failed: - // the handle is. - let err = - block_on(stopped_wire().push_self_profile("11".repeat(32))).expect_err("must fail"); - assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}"); - } - - #[test] - fn push_self_profile_rejects_a_pubkey_that_is_not_hex_before_any_work() { - let err = - block_on(stopped_wire().push_self_profile("nope".to_string())).expect_err("must fail"); - // The hex check runs first, so this is `Failed`, not `Stopped`. - assert!(matches!(err, WireError::Failed { .. }), "got {err:?}"); - } - - /// The picker row is the catalogue row, row for row: same id, same file - /// name, same label, and the pubkey as hex. A Kotlin picker keys on - /// `wallet_filename` for [`Wire::open_wallet`], so it has to be exact. - #[test] - fn wallet_rows_carry_the_catalogue_verbatim() { - let home = temp_home(); - let store = Store::open_at_with_passphrase(&home, "wallet-catalogue-pass").unwrap(); - let named = store - .create_wallet(&NewWallet { - name: Some("savings".to_string()), - identity_pubkey: [0xab; 32], - onion_locator: "peer.onion".to_string(), - wallet_filename: "onionwire-1".to_string(), - }) - .unwrap(); - let unnamed = store - .create_wallet(&NewWallet { - name: None, - identity_pubkey: [0xab; 32], - onion_locator: String::new(), - wallet_filename: "onionwire-2".to_string(), - }) - .unwrap(); - - let rows: Vec = store - .list_wallets() - .unwrap() - .iter() - .map(wallet_row) - .collect(); - - assert_eq!(rows.len(), 2, "both wallets are listed"); - assert_eq!(rows[0].id, named.id); - assert_eq!(rows[0].name.as_deref(), Some("savings")); - assert_eq!(rows[0].wallet_filename, "onionwire-1"); - assert_eq!(rows[0].onion_locator, "peer.onion"); - assert_eq!(rows[0].identity_pubkey_hex, "ab".repeat(32)); - assert_eq!(rows[0].created_at, named.created_at); - // A wallet created without a label is `None`, never an empty string. - assert_eq!(rows[1].id, unnamed.id); - assert_eq!(rows[1].name, None); - // The locator is a locator: it may be empty, and it is not an identity. - assert_eq!(rows[1].onion_locator, ""); - - std::fs::remove_dir_all(&home).ok(); - } - - #[test] - fn keys_mapping_carries_both_halves_and_the_view_only_answer() { - let both = keys_record(CoreWalletKeys { - view_key: "view-material".to_string(), - spend_key: Some("spend-material".to_string()), - }); - assert_eq!(both.view_key, "view-material"); - assert_eq!(both.spend_key.as_deref(), Some("spend-material")); - - let view_only = keys_record(CoreWalletKeys { - view_key: "view-material".to_string(), - spend_key: None, - }); - assert_eq!(view_only.view_key, "view-material"); - assert_eq!(view_only.spend_key, None); - } - - /// These two are spend secrets: the record the Kotlin side receives must not - /// print them through `Debug`, or a `{:?}` in a crash log leaks a key. - #[test] - fn wallet_keys_debug_never_prints_a_private_key() { - let keys = keys_record(CoreWalletKeys { - view_key: "VIEWKEYMATERIAL".to_string(), - spend_key: Some("SPENDKEYMATERIAL".to_string()), - }); - let printed = format!("{keys:?}"); - assert!( - !printed.contains("VIEWKEYMATERIAL"), - "view key leaked: {printed}" - ); - assert!( - !printed.contains("SPENDKEYMATERIAL"), - "spend key leaked: {printed}" - ); - assert!(printed.contains("redacted"), "got {printed}"); - } - - #[test] - fn self_profile_mapping_carries_the_three_editable_fields() { - let core = FriendProfile { - display_name: "nick".to_string(), - bio: "bio".to_string(), - xmr_addr: String::new(), - updated_at: 1_700_000_000, - }; - let got = self_profile_record(&core); - assert_eq!(got.display_name, "nick"); - assert_eq!(got.bio, "bio"); - assert_eq!(got.xmr_addr, ""); - } -} diff --git a/crates/onionwire-sdk/tests/init_provider.rs b/crates/onionwire-sdk/tests/init_provider.rs deleted file mode 100644 index 85d8a79..0000000 --- a/crates/onionwire-sdk/tests/init_provider.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! `open_wire` must not depend on how the consumer's feature graph resolves a -//! rustls provider — it installs the process default itself, first. -//! -//! This is the belt-and-braces half of the fix for the on-device "Failed to -//! start / Could not automatically determine the process-level CryptoProvider" -//! screen; the primary fix is the `rustls` `ring` feature in `Cargo.toml`, -//! covered by `tests/provider_resolution.rs`. Kept in its own test binary on -//! purpose: installing a provider here would mask that test if they shared a -//! process. - -#[test] -fn sdk_installs_the_process_default_provider() { - assert!( - rustls::crypto::CryptoProvider::get_default().is_none(), - "this test must start with no provider installed" - ); - - onionwire_sdk::install_crypto_provider(); - - assert!( - rustls::crypto::CryptoProvider::get_default().is_some(), - "install_crypto_provider() left the process without a default provider" - ); - - // Second call: idempotent, not a panic and not an error. - onionwire_sdk::install_crypto_provider(); - - // The call Arti makes that blew up on device. - let _ = rustls::ClientConfig::builder(); -} diff --git a/crates/onionwire-sdk/tests/provider_resolution.rs b/crates/onionwire-sdk/tests/provider_resolution.rs deleted file mode 100644 index 0b490cb..0000000 --- a/crates/onionwire-sdk/tests/provider_resolution.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! Regression test for the on-device failure: the APK built, installed and -//! opened, but pressing **Open** on the unlock screen died one call deep inside -//! Arti's rustls backend with -//! -//! ```text -//! Could not automatically determine the process-level CryptoProvider from -//! Rustls crate features. -//! Call CryptoProvider::install_default() before this point to select a -//! provider manually, or make sure exactly one of the 'aws-lc-rs' and 'ring' -//! features is enabled. -//! ``` -//! -//! rustls 0.23 chooses its provider from its own `ring` / `aws-lc-rs` **crate -//! features**, not from which crypto crates happen to be linked. Arti reaches -//! rustls through `tor-rtcompat` with `default-features = false`, so neither -//! provider feature is on and rustls is compiled with *no* provider at all: -//! `ring` showing up in `cargo tree` (pulled in by `snow`, for Noise) proves -//! nothing. Everything compiles, the APK ships, and the process-default lookup -//! fails at runtime. -//! -//! This test is the invariant Arti relies on: the process default must be -//! resolvable **without** anyone calling `install_default()` first. -//! -//! Deliberately the only test in this file — a second test that installs a -//! provider would race with it inside the same test binary and could mask the -//! regression. - -/// Building a `rustls` config the way Arti does, straight from the process -/// default, must not panic. -#[test] -fn rustls_default_provider_resolves_without_manual_install() { - assert!( - rustls::crypto::CryptoProvider::get_default().is_none(), - "this test must start with no provider installed" - ); - - // Pre-fix this panics with the device's exact message. - let _ = rustls::ClientConfig::builder(); - - assert!( - rustls::crypto::CryptoProvider::get_default().is_some(), - "rustls resolved no CryptoProvider — the crate feature that selects a \ - provider is not enabled in this workspace" - ); -} diff --git a/crates/onionwire-sdk/uniffi.toml b/crates/onionwire-sdk/uniffi.toml deleted file mode 100644 index 7ff06a3..0000000 --- a/crates/onionwire-sdk/uniffi.toml +++ /dev/null @@ -1,9 +0,0 @@ -# UniFFI Kotlin bindings configuration. -# -# `disable_java_cleaner`: the JVM cleaner path pulls in androidx.annotation and -# branches on API 34. JNA's own Cleaner works on every API level we support, so -# we take the single code path and drop the extra dependency. -[bindings.kotlin] -package_name = "uniffi.onionwire_sdk" -disable_java_cleaner = true -kotlin_target_version = "2.2.21" diff --git a/docs/ARTI_UPGRADE.md b/docs/ARTI_UPGRADE.md deleted file mode 100644 index 7045e62..0000000 --- a/docs/ARTI_UPGRADE.md +++ /dev/null @@ -1,163 +0,0 @@ -# Upgrading the Arti / Tor crates - -The in-process Tor stack is the largest attack surface in OnionWire. Arti's -onion services are still **experimental** and OnionWire does not fall back to a -C-tor subprocess, so an upstream fix only reaches users when we bump these -crates, rebuild, and cut a release. - -## What is pinned - -Direct dependencies that come from the Arti repository, exactly as -`Cargo.toml` has them: - -| crate | requirement | features in `Cargo.toml` | -|---|---|---| -| `arti-client` | `0.49` | `default-features = false`; `tokio`, `onion-service-client`, `onion-service-service`, `compression` | -| `tor-cell` | `0.49` | — | -| `tor-hsservice` | `0.49` | — | -| `tor-rtcompat` | `0.49` | `tokio` | -| `safelog` | `0.10` | — | - -`snow`, `rusqlite`, `ratatui`, and the rest are unrelated to Arti and are not -part of a Tor upgrade. `safelog` lives in the Arti repository and moves in -lockstep with the `tor-*` set: a stale direct `safelog` pin puts two copies in -the graph, and `HsId::display_redacted` then resolves against the wrong trait -(`error[E0599]: no method named display_redacted`). The SDK workspace -(`crates/onionwire-sdk`) has its own `arti-client` pin and lockfile; bump it -too. - -Two crate features re-expose Arti's TLS backends, which Arti marks -**non-additive** — exactly one may be selected per build graph: - -* `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 of the crates above together in lockstep. -Bump them as **one set**. A mixed set (e.g. `arti-client` 0.47 with -`tor-hsservice` 0.49) is not a configuration anyone tests upstream, and cargo -will usually refuse or silently pick one `tor-*` version and mismatched -`tor-*` internals fail at runtime. - -## Toolchain floor - -**rustc 1.98+.** `Cargo.toml` sets `edition = "2024"` and `rust-version = "1.98"`. -Arti 0.49 itself requires only 1.92; the higher floor is the default -`cuprate-daemon` feature (`tapes` calls `VecDeque::pop_front_if`, stable since -1.93). CI builds inside `rust:1.98-bookworm` -(`RUST_IMAGE` in `.forgejo/workflows/ci.yml` and `release.yml`). - -A bump may raise the floor. Take the actual MSRV from the upstream release -notes / the crate's own `rust-version`, then raise it in the same PR: - -* `rust-version` in `Cargo.toml`, -* `RUST_IMAGE` in `.forgejo/workflows/ci.yml` **and** `.forgejo/workflows/release.yml`, -* the "Rust 1.98+" line in `README.md`. - -## How this gets noticed - -`.forgejo/workflows/arti-watch.yml` runs daily (and on demand) and asks -crates.io for the newest stable version of each crate above. If the -major.minor moved past the pin, it files one Forgejo issue titled -`Arti upstream: → `. It is deduped on that title across open -and closed issues, so re-running it never files a second issue and never -comments. It changes nothing: no `Cargo.toml`, no lockfile, no commit. - -Test the alert path without waiting for upstream (it compares real crates.io -data against a pretend pin): - -``` -# Actions → arti-watch → Run workflow, simulate_pin = arti-client=0.45 -python3 scripts/arti-watch.py --dry-run --cargo-toml Cargo.toml --simulate-pin arti-client=0.45 -``` - -**What the watcher does not cover.** It does not subscribe to Tor Project -security announcements — a fix that ships without a crates.io version bump is -invisible to it. It will not catch a yanked crate, and it will not catch a -vulnerability in a version that has not changed. Watch - and yourself, and -treat a Tor security advisory as an instruction to bump **now**, ahead of any -issue the watcher files. - -## Procedure - -1. Read the upstream release notes (Arti tags: ) - and the CHANGELOG for breaking API changes. Check the new MSRV. -2. Branch from `main`; bump every Arti-repository pin in `[dependencies]` of - `Cargo.toml` together (`arti-client`, `tor-cell`, `tor-hsservice`, - `tor-rtcompat`, and `safelog`), the matching `arti-client` pin in - `crates/onionwire-sdk/Cargo.toml`, and `rust-version` if the floor moved. -3. Refresh the lockfile (CI builds with `--locked` and `Cargo.lock` is - committed): - ``` - cargo update -p arti-client -p tor-cell -p tor-hsservice -p tor-rtcompat -p safelog - git diff --stat Cargo.lock - ``` - Expect the whole `tor-*` family to move in the diff. A single `tor-*` crate - moving alone is a sign the set is not actually lockstep — stop and look. - Then refresh the SDK workspace's separate lockfile: - ``` - ( cd crates/onionwire-sdk && cargo update -p arti-client ) - ``` -4. Build and run the offline suite: - ``` - cargo test --locked - cargo clippy --locked --all-targets -- -D warnings - ``` -5. Re-check the workarounds in `src/hs.rs`. They exist because Arti's publish - path is slow and its circuit timeouts misbehave on hidden-service circuits, - and an upstream fix or behaviour change can make any of them wrong: - - | constant | why | guard | - |---|---|---| - | `PUBLISH_WAIT` (360s) | a 180s wait cut a working HsDir upload while status was still `Bootstrapping`; Arti's per-HsDir `OVERALL_UPLOAD_TIMEOUT` is 5 min | `tests/hs.rs::publish_wait_covers_hsdir_retries` | - | `CBT_MIN_TIMEOUT_MS` / `CBT_INITIAL_TIMEOUT_MS` (≥ 10s) | learned circuit-build timeouts can drop to ~1s and kill 4-hop vanguard HsDir circuits | `tests/hs.rs::cbt_min_timeout_floor_is_at_least_10s`, `cbt_initial_timeout_matches_the_floor` | - | `PREEMPTIVE_PREDICTED_PORTS` (empty) | Arti's default predicted 80/443 exit circuits starve IPT + HsDir builds; OnionWire never exits | `tests/hs.rs::no_preemptive_exit_ports` | - | `hs_is_ready` probe semantics | combined status stays `Bootstrapping` after descriptors are already fetchable | `tests/hs.rs::bootstrapping_is_not_ready_until_a_probe_connects` | - - Do not paper over a slow publish by raising `PUBLISH_WAIT` — first make sure - the rend handler is spawned *before* the probe wait, or the probe cannot - succeed at all. -6. Run the live two-node test on a networked machine. This is the only test that - proves the hidden service actually publishes and that a second node can - reach it: - ``` - cargo test --locked --test tor_hs -- --ignored --nocapture - ``` - It needs minutes of real Tor network. `two_node_byte_pipe_restart_and_dormant` - covers: onion publish (first-run `hs status: Bootstrapping` spam is HsDir - descriptor upload, not a hang), probe-connect against a live HS, a byte pipe - in both directions, restart, and the dormant/offline path. -7. Confirm the fail-closed path by hand if the publish wait changed at all: - with the publish wait still 360s, if Arti cannot publish the onion the - process must exit (no C-tor fallback). Chat to a *reachable-HS but down peer* - is queued locally (`src/outbox.rs`) and retried; file transfer and payment - frames still fail immediately. There is no **server-side** outbox. -8. Rebuild the Android target. The root crate defaults to `rustls` now, so this - is less about exercising a non-default feature than about proving the default - still cross-compiles where OpenSSL does not exist: - ``` - scripts/build-android-local.sh - ``` -9. Verify the ciphertext claim still holds after the bump: send a message - between the two nodes, then - ``` - grep -r "" - ``` - must find nothing. The bodies live in sqlite as ciphertext, and nothing about - the plaintext should appear in Arti's state directory. -10. Open a PR against `main` describing: crates bumped, MSRV, the live-test - output, and anything upstream changed that touches `src/hs.rs`. Do not push - `main`. Releases are **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 - -Revert the version bump and the lockfile stanza together, re-run step 3's -`cargo update` only if the revert leaves the lockfile inconsistent, and re-run -`cargo test --locked` plus the live two-node test. Never leave `Cargo.toml` and -`Cargo.lock` out of step: CI builds with `--locked` and will fail, which is the -intent. diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md deleted file mode 100644 index bec89a8..0000000 --- a/docs/PROTOCOL.md +++ /dev/null @@ -1,950 +0,0 @@ -# OnionWire protocol (v1) - -This is the wire protocol. A second implementation should be able to -interoperate from this document without reading the Rust. - -It is **not** an IETF RFC. It describes what this repository speaks today -(frame versions 1 and 2, invite schemes `onionwire:v2` (emit) and -`onionwire:v1` (decode only)). There has been no public third-party audit. -Arti onion services are experimental upstream. - -Related: [threat model](THREAT_MODEL.md), [audit notes](SECURITY_AUDIT.md). - -## What this is not - -OnionWire is not Tox, not Tox-over-Tor, not XMPP, and not “a messenger plus a -SOCKS proxy.” - -| | Tox (including ToT) | OnionWire v1 | -|---|---|---| -| Discovery | DHT + bootstrap nodes | Out-of-band invite only | -| After lookup | Direct IP or TCP relay (SOCKS if you forced it) | v3 onion ↔ v3 onion | -| Address | Tox ID lives in the DHT | ed25519 pubkey is identity; onion is a locator | -| Offline send | Expected (relays / retry) | Queued locally, retried peer-to-peer (no relay) | -| Mixed clearnet | ToT can still talk to non-Tor Tox | No clearnet peers | - -There is no directory, no name server, no introduction point of our own, and no -UDP at the application layer. - -## Roles and keys - -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 - — rotate it with `F8`, which hard-cuts every stored session. Rotating the - onion (`F4`) does **not** rotate it. -- **KEM key** — ML-KEM-768 (FIPS 203) keypair. The 1184-byte encapsulation key - travels in a v2 invite as `kem=`; the 64-byte decapsulation seed lives in the - SQLCipher store beside `identity_sk`. `F8` rotates it together with the - prekey, with the same hard cut (stored ratchet state is dropped and every - friend re-pastes the invite). -- **Onion** — Tor v3 address. Locator only. Disposable. - -A friend is `{identity_pk, current_onion, current_prekey_pk, kem_pk?}`. Pasting -the same identity `k` updates the locator, prekey and KEM key on that row. It -never creates a second person. `kem_pk` is absent only for a friend added from -a legacy `onionwire:v1` invite; such a friend is **classical** (see -[No downgrade](#no-downgrade)). - -Petnames, chat history, and the optional Monero wallet RPC are local. They are -not on the wire. - -## Transport - -1. Each peer publishes a Tor v3 onion service (in-process Arti in this tree). -2. Application port is **80**. -3. The sender opens a Tor circuit to `(friend.onion, 80)`, runs the handshake, - sends **one** application frame, and drops the circuit. -4. File transfer is N independent sessions (one handshake per chunk). There is - no multiplexed long-lived stream in v1. - -If the onion is down, a **chat** send is persisted to the local outbox and -retried by a background worker with exponential backoff (30s, doubling, capped -at 30 min; 8 attempts, then terminal `Failed`). There is no server and no -store-and-forward relay: each attempt is a fresh handshake straight to -`(friend.onion, 80)`, exactly as above. Retries fire on a timer, on -unlock/foreground, and whenever that peer is heard from (successful handshake or -a connect to that onion). A protocol failure — signature mismatch, unknown -frame, oversize — is not a transport failure and is never queued. - -File transfer and payment frames stay fail-closed: they are one-shot and are -**not** queued. The locator-push path retries for 180 seconds and then gives up. - -Incoming rendezvous accepts are token-bucket limited: 30 per 60s, burst 10. -Excess is dropped before handshake. That is availability, not anonymity. - -## Framing - -Every Noise handshake message and every ciphertext is wrapped: - -``` -uint8 version = 1 (normal) | 2 (PQ handshake prelude) -uint32 length = big-endian body length -uint8 body[length] -``` - -- `version = 1` is Noise msg 1, msg 2, an identity proof, or one application - ciphertext. It is unchanged from v1 of this document. -- `version = 2` is the **PQ handshake prelude**. Its body is `uint16 ct_len` - (big-endian) followed by exactly `ct_len` bytes of ML-KEM-768 ciphertext. - `ct_len` MUST be 1088. The prelude may only be the first frame of a session; - the initiator sends exactly one, then Noise msg 1 with `version = 1`. - `read_frame` (used after the opening frame) rejects `version = 2`. -- `length` MUST be ≤ 65535. Check the length **before** allocating the body. -- Other `version` values are a hard fail (close the stream). -- Length that does not match the bytes on the wire is a hard fail. - -`length` still reveals the exact ciphertext size. Chat hides it by padding the -plaintext to a bucket before encryption (see [Length buckets](#length-buckets)). -Other frame types are not padded. - -## Length buckets - -Normative for chat. A chat line is padded to one fixed ladder **before** the -ratchet encrypts it, so the padding is inside ChaCha20-Poly1305, inside the -Noise session, and authenticated by both. An observer sees a ciphertext whose -length is one of the ladder values (plus constant overhead), never the body -length. - -Ladder — padded-plaintext sizes in bytes: - -``` -256, 512, 1024, 2048, 4096, 8192, 16384, 32768 -``` - -Ratchet plaintext encoding: - -``` -uint16 pad_len big-endian -uint8 body[..] the chat line -uint8 fill[pad_len] random bytes, contents ignored -``` - -- The padded plaintext MUST be exactly the smallest ladder value that is at - least `2 + body_len`. `pad_len = bucket - 2 - body_len`. -- Empty and short bodies both pad to 256; a 254-byte body fits the 256 bucket - with `pad_len = 0`. -- `fill` is fresh random bytes. Its contents carry no meaning. -- A body larger than 32766 bytes does not fit the ladder and MUST fail closed - (it is a protocol error, never queued). - -Receiver rules: - -- The total decrypted length is **not** required to be a ladder value. Only the - header is normative, so a peer with a different ladder still interoperates. -- `pad_len` is the only authority for the body length. A receiver MUST NOT trim - trailing zeros, strip a repeated fill byte, or otherwise infer the boundary - from content: a body that legitimately ends in the same byte as the fill - round-trips unchanged. -- A plaintext shorter than 2 bytes, or one whose `pad_len` exceeds - `len - 2`, MUST be rejected as a hard failure before anything is appended, - rendered, or persisted. The ratchet state is not advanced. -- Unpadded frames are not accepted as if they were a bucket: if the first two - bytes do not describe a consistent `pad_len`, the frame fails closed. -- Padding is a plaintext-layer change and is independent of the `rat ` frame - version: a classical (`0x01`) and a hybrid (`0x02`) frame carry the same - padded plaintext. See [Ratchet (chat layer)](#ratchet-chat-layer) for the - header each version adds. - -The ladder floor stays at **256** even though a hybrid frame's floor is over -2.6 KB. The ladder schedules the *plaintext*, and a hybrid step's size is -dominated by its 2312-byte header — the 256 bucket is a rounding error there, -so raising the floor would not conceal the header and would only inflate -classical (`0x01`) chat, which is still the epoch-0 and legacy-friend path. A -second, version-specific ladder would double the normative surface for no -privacy gain; the bucket boundaries remain observable within each size class -either way. - -Minimum observable size depends on the `rat ` header version: - -- Classical (`0x01`): `rat ` 4 + version 1 + header 40 + nonce 12 + bucket 256 - + tag 16 = **329-byte `rat ` frame**; the Noise transport adds its 16-byte - tag and the framing header adds 5 bytes, so the smallest classical chat frame - on the wire is **350 bytes**. -- Hybrid (`0x02`): `rat ` 4 + version 1 + header 2312 + nonce 12 + bucket 256 - + tag 16 = **2601-byte `rat ` frame**, i.e. **2622 bytes on the wire**. The - 2272 extra header bytes are the sender's ML-KEM-768 ratchet key and the - ciphertext to the receiver's; the 256-byte bucket applies unchanged inside - them. - -Both floors hold whatever the body length. The 32768 bucket yields a -32862-byte classical frame and a 35113-byte hybrid frame, both under the 65535 -Noise body cap. - -The ML-KEM-768 ciphertext appears in two places: the one-shot handshake prelude -(`version = 2`, 1095 bytes once per session), and every `rat ` header after the -first hybrid ratchet step (`kem_pub[1184] || kem_ct[1088]`). Epoch 0 of a chat -is always classical, so the first `rat ` frame of a friend relationship uses -the 40-byte header. - -`fil ` chunks are deliberately **not** padded. They are raw file bytes paced -through the accept token bucket, and padding them would either cut the usable -chunk size or spend the 65535 frame cap on fill; the chunk size stays as -specified under `fil ` — file chunk. - -This hides length, not timing: one Noise session per message, retry cadence and -circuit timing are unchanged and remain accepted costs (see -`docs/THREAT_MODEL.md`). - -## Handshake - -Noise pattern: `Noise_IK_25519_ChaChaPoly_BLAKE2s` - -Prologue (both sides, before the first Noise handshake message): - -- **Classical** (no PQ prelude, friend row has no `kem_pk`): `onionwire-v1` - (12 ASCII bytes, no NUL). -- **Hybrid** (a PQ prelude was sent/received): the exact byte layout - - ``` - "onionwire-v2" || 0x00 || ct || 0x00 || ss_kem - ``` - - where `onionwire-v2` is 12 ASCII bytes, `ct` is the 1088-byte ML-KEM-768 - ciphertext from the prelude, and `ss_kem` is the 32-byte shared secret. - Initiator: `(ct, ss_kem) = ML-KEM-768.Encapsulate(friend.kem_pk)`. - Responder: `ss_kem = ML-KEM-768.Decapsulate(own_dk, ct)`. Both therefore - commit to the ciphertext and to the PQ secret: a modified `ct` changes the - prologue (and decapsulates to implicit-rejection garbage), so the Noise - handshake fails before msg 2. - -Handshake payloads are empty. A non-empty decrypted handshake payload is a -hard fail. - -### Sequence - -Initiator knows the responder’s identity pubkey (pinned), x25519 prekey and -(if `kem_pk` is present) ML-KEM key from the invite (or roster). - -0. **PQ prelude** — only when the responder’s roster row has `kem_pk`: - initiator → responder, one `version = 2` frame carrying the ML-KEM - ciphertext. If the row has no `kem_pk`, no prelude is sent and the prologue - is `onionwire-v1`. -1. **IK msg 1** — initiator → responder (framed, `version = 1`). Responder’s - Noise static is the invite `spk`. -2. Responder looks up the remote static in the roster **by prekey**. - Unknown prekey → close. This is how the answerer learns who is calling. - It then compares the friend row with how the session opened (see - [No downgrade](#no-downgrade)) and only then sends msg 2. -3. **IK msg 2** — responder → initiator (framed). -4. Both sides enter transport mode. Handshake hash `h` is 32 bytes (BLAKE2s). -5. **Identity proof, initiator first** — transport-encrypt a 96-byte proof, - send as one frame. -6. **Identity proof, responder** — same, one frame. - -Proof encoding (96 bytes): - -``` -bytes[32] identity_pk // ed25519 -bytes[64] ed25519_sign(identity_sk, h) -``` - -Verify: - -- proof length is exactly 96 -- `identity_pk` equals the **pinned** identity (initiator: invite/roster `k`; - responder: roster row found via prekey) -- `ed25519_verify(identity_pk, h, sig)` succeeds - -Any mismatch is a fingerprint failure. Do not send application data. Do not -retry with a different key. - -After proofs, the initiator sends **one** transport frame of application -ciphertext and closes. The responder decrypts that one frame and closes. - -Compromise of the long-term x25519 prekey does not decrypt past transport -(IK + ephemeral). It does allow future impersonation at the Noise layer until -the peer notices the identity proof failing — so the proof is not optional. -With a PQ prelude, the transport secrets also mix `ss_kem`; a later -cryptographically relevant quantum adversary that recorded the session still -needs ML-KEM-768 broken to recover the Noise transport keys. - -### No downgrade - -The rule comes from the roster row, never from what arrives on the wire: - -- friend row has `kem_pk` → **always** send the prelude; the responder requires - one. A `version = 1` opening from that peer is rejected with `prelude - required` before msg 2, the identity proofs, and any application frame. -- friend row has no `kem_pk` (added from a legacy v1 invite) → classical - session with the `onionwire-v1` prologue. The UI labels the friend as lacking - PQ protection. -- A prelude is not accepted for a friend row with no `kem_pk`: the responder - rejects it with `unexpected prelude` before msg 2, so the wire cannot upgrade - a classical row. `kem_pk` only enters a row from a signed v2 invite. - -A v1-only build dialling a v2 install cannot parse `version = 2` as an opening -frame and hard-fails, and a v2 build will not send a prelude to a v1 peer. -That mixed-fleet break is accepted; there is no fallback path. - -## Application plaintext - -After decrypt, classify the plaintext: - -| Prefix (4 bytes) | Kind | If unknown / invalid | -|---|---|---| -| `rat ` | Double Ratchet chat frame (see Ratchet) | drop | -| `loc ` | locator update | drop | -| `prf ` | profile | drop | -| `inv ` | Monero invoice | drop | -| `rcp ` | Monero receipt claim | drop | -| `tip ` | Monero tip (receipt + memo) | drop | -| `png ` | ping (reserved; classify and drop) | drop | -| `fil ` | file chunk | drop | -| `[a-z][a-z][a-z] ` | unknown typed frame | **drop** (not chat) | -| anything else | chat | store as a chat line | - -`rat ` is classified before the `[a-z]{3} ` catch-all, so a peer that does not -implement the ratchet drops a chat frame instead of rendering ciphertext as a -chat line. Older builds that stored `rat `-prefixed bytes as chat are obsolete; -upgrade both sides. - -A peer that does not implement a typed prefix MUST still drop -`[a-z]{3}…` rather than render it as chat. - -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.) - -Hex on the wire is lowercase on encode; decode accepts either case. No `0x` -prefix. - -### Application-frame signatures - -`loc`, `prf`, `inv`, `rcp`, and `tip` each carry an ed25519 signature over the -**fields**, not the 4-byte typed prefix. Encode MUST sign the domain-separated -form (type tag, then each field, `0x00` separators). Verify MUST accept that -form and, for mixed-version peers, the legacy untagged LF-joined layout. -Anything else fails closed. Do not emit the legacy layout. - -The invite string is separate and uses `onionwire-invite-v2` (see Invite). - -Legacy acceptance is one switch, `LEGACY_SIGS`, default **on**. Every fallback -listed below reads it; with it off, verification accepts only the emitted -(tagged) form. It is a local capability constant, not a wire field: it is never -sent, and a peer cannot negotiate it. - -| frame | emitted | accepted inbound | -| --- | --- | --- | -| invite | `onionwire-invite-v2`, `0x00`-separated over `k`, `o`, `spk`, `kem` | same; `onionwire:v1` over `onionwire-invite-v1` `0x00`-separated `k`,`o`,`spk`, or over `k \|\| o \|\| spk` (legacy only) | -| `loc ` | `"onionwire-loc-v1"` `0x00` `onion` `0x00` `ts` | same; `onion \|\| LF \|\| ts` (legacy only) | -| `prf ` | `"onionwire-prf-v1"` `0x00` `name` `0x00` `bio` `0x00` `xmr_addr` `0x00` `ts` | same; the four fields joined by LF (not yet gated — see below) | -| `inv ` | `"onionwire-inv-v1"` `0x00` `amount_atomic` `0x00` `address` `0x00` `memo` `0x00` `ts` | same; the four fields joined by LF (legacy only) | -| `rcp ` | `"onionwire-rcp-v1"` `0x00` `txid` `0x00` `amount_atomic` `0x00` `address` `0x00` `ts` | same; the four fields joined by LF (legacy only) | -| `tip ` | `"onionwire-tip-v1"` `0x00` `txid` `0x00` `amount_atomic` `0x00` `address` `0x00` `memo` `0x00` `ts` | same; the five fields joined by LF (legacy only) | - -The tag suffixes do say `-v1`; that is the tag's own version, not the invite -string version. - -`prf ` is the one frame whose legacy fallback is not yet gated: it is accepted -unconditionally in this revision and moving it under `LEGACY_SIGS` is a -separate change. - -**Mixed-fleet consequence.** Older builds verify only the untagged bytes, so -they reject every tagged signature from a new sender — including `tip `, which -older builds emitted and verified untagged. That direction needs the peer -updated before tips flow. The reverse works while `LEGACY_SIGS` is on: a new -build verifies an old sender's untagged `loc`/`prf`/`inv`/`rcp`/`tip` and an -`onionwire:v1` invite. Turning the switch off is a fleet-wide cutover, not a -per-peer choice. - -### `loc ` — locator update - -Sent when the sender rotated their onion and the receiver is reachable. - -``` -loc \n\n -``` - -- `onion` — v3 onion (56 base32 `a-z2-7` chars + `.onion`) -- `ts` — unix seconds, decimal ASCII -- `sig_hex` — 64-byte ed25519, 128 hex chars -- the `loc ` prefix is **not** signed - -**Current signature (encode this):** - -``` -ed25519_sign(identity_sk, - "onionwire-loc-v1" || 0x00 || onion || 0x00 || ascii(ts)) -``` - -**Legacy accept:** a signature over `onion || LF || ascii(ts)` is still -accepted on verify while `LEGACY_SIGS` is on, so old loc frames verify. New loc -frames MUST use the domain-separated form. Do not emit legacy. - -Apply only if **all** of: - -- the Noise session’s peer identity is already in the roster -- signature verifies under that identity -- `ts` is strictly greater than the stored `onion_updated_at` - -Otherwise drop. Unknown pubkeys are not inserted from `loc`. There is no -directory: if you rotated while they were offline, they cannot find you until -they paste a new invite. - -### `prf ` — profile - -``` -prf \n\n\n\n -``` - -Limits: name ≤ 64 bytes, bio ≤ 512 bytes. No newlines in those fields. -`xmr_addr` may be empty; if non-empty it MUST be a checksummed Monero address -(see invoices). The `prf ` prefix is **not** signed. - -**Current signature (encode this):** - -``` -ed25519_sign(identity_sk, - "onionwire-prf-v1" || 0x00 || name || 0x00 || bio || 0x00 || xmr_addr || 0x00 || ascii(ts)) -``` - -**Legacy accept:** a signature over the four fields joined by LF is still -accepted on verify. New profile frames MUST use the domain-separated form. -Do not emit legacy. This fallback is not yet read through `LEGACY_SIGS`. - -Apply only for an existing friend, valid signature, newer `ts`. Not a public -profile. Not a directory. - -### `inv ` — invoice (we want to receive) - -``` -inv \n
\n\n\n -``` - -`amount_atomic` is decimal piconero (integer string, > 0). `address` is a -Monero mainnet/stagenet standard, subaddress, or integrated address with a -valid Keccak checksum. The `inv ` prefix is **not** signed. - -**Current signature (encode this):** - -``` -ed25519_sign(identity_sk, - "onionwire-inv-v1" || 0x00 || amount_atomic || 0x00 || address || 0x00 || memo || 0x00 || ascii(ts)) -``` - -**Legacy accept:** a signature over the four fields joined by LF is still -accepted on verify while `LEGACY_SIGS` is on. New invoices MUST use the -domain-separated form. Do not emit legacy. - -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 \n\n
\n\n -``` - -The `rcp ` prefix is **not** signed. - -**Current signature (encode this):** - -``` -ed25519_sign(identity_sk, - "onionwire-rcp-v1" || 0x00 || txid || 0x00 || amount_atomic || 0x00 || address || 0x00 || ascii(ts)) -``` - -**Legacy accept:** a signature over the four fields joined by LF is still -accepted on verify while `LEGACY_SIGS` is on. New receipts MUST use the -domain-separated form. Do not emit legacy. - -Signature proves which friend sent the claim. It does **not** prove money -moved. Local `verified=1` only if a user-hosted `monero-wallet-rpc` returns -one transfer row with the same non-empty `txid`, `amount`, and `address` -(conjunction, not OR). RPC down or an unsynced daemon → stay unverified. -Wallet RPC is loopback HTTP Digest; it is not this protocol. - -### `tip ` — tip (we paid, with memo) - -Sent after a chain transfer, together with `rcp `. One-shot. - -``` -tip \n\n
\n\n\n -``` - -The `tip ` prefix is **not** signed. - -**Current signature (encode this):** - -``` -ed25519_sign(identity_sk, - "onionwire-tip-v1" || 0x00 || txid || 0x00 || amount_atomic || 0x00 || - address || 0x00 || memo || 0x00 || ascii(ts)) -``` - -**Legacy accept:** a signature over the five fields joined by LF is still -accepted on verify while `LEGACY_SIGS` is on. New tips MUST use the -domain-separated form. Do not emit legacy. - -`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 - -Cap: 1 MiB reconstructed file. No resume. One Noise session per chunk. - -The sender is responsible for fitting the receiver's documented rendezvous -budget (30 accepts / 60s, burst 10). Chunks MUST be paced so the average -interval between send attempts stays at least 3s. A sender MAY retry an -individual chunk a bounded number of times (this tree: 3). Exhausting retries -fails the transfer. No outbox, no resume, no continuation under a new -`xfer_id`. - -``` -fil \n\n\n/\n -``` - -- `xfer_id` — 16 random bytes (32 hex) -- `filename` — 1–128 bytes, no `/`, NUL, newline, `.`, or `..`; no C0/C1 controls or bidi/format marks (U+202A–U+202E, U+2066–U+2069, U+200E, U+200F, U+200B, U+200C) -- `sha256` — SHA-256 of the **entire** file (64 hex), repeated on every chunk -- `idx` is 0-based; `total` ≥ 1; `idx < total` -- last line is raw chunk bytes (not hex), length chosen so the framed Noise - ciphertext stays ≤ 65535 (account for a 16-byte Poly1305 tag plus ASCII header) - -Chunks MUST arrive in order for a given `xfer_id`. A bad chunk or hash -mismatch deletes the partial. Empty files are one chunk. Successful receive -is a chat line `[file] name (N bytes)`, never the raw frame. - -### Chat - -A chat send is ratcheted: the wire form of a chat message is a `rat ` frame -(see “Ratchet (chat layer)”), and the plaintext inside that frame is the chat -line below, padded to a length bucket first (see -[Length buckets](#length-buckets)). A bare chat frame with no typed prefix is -still accepted inbound as a chat line (older peers), but MUST NOT be emitted. - -UTF-8 is not enforced for chat text: invalid bytes become U+FFFD (the -implementation does not drop the row). Control and bidi formatting -characters are stripped at ingest and at render: C0 0x00–0x1F except -tab and newline, DEL (0x7F), C1 U+0080–U+009F, U+202A–U+202E, -U+2066–U+2069, U+200E, U+200F, U+200B, U+200C. U+200D (ZWJ) is kept -so emoji sequences stay intact. `fil ` filenames must not contain -those characters (tab and newline included). Displayed as a line. -A chat line is at most 32766 bytes (the largest bucket minus the 2-byte -`pad_len` header); a longer body is a protocol error, not a queued message. See -[Length buckets](#length-buckets). - -## Ratchet (chat layer) - -Chat is the only application payload that is ratcheted. A chat send is -Double-Ratchet encrypted first, and the resulting `rat ` frame is the -application plaintext that a normal one-shot Noise session carries (handshake, -one application frame, close — see Transport). Nothing else changes about the -session. - -The ratchet header is **inside** the Noise transport message, never in clear on -the wire. A plaintext header (`dh_pub || N || PN`) would hand an observer -per-message counters and ratchet-key changes for no benefit — the Noise session -already hides the frame, so the header is authenticated as AEAD associated data -instead. - -### Frame - -``` -"rat " 4 bytes (0x72 0x61 0x74 0x20) -version 1 byte 0x01 (classical) or 0x02 (hybrid) --- version 0x01: classical header, 40 bytes -header 40 bytes dh_pub[32] || N uint32 BE || PN uint32 BE -nonce 12 bytes random, per message -ciphertext n+16 ChaCha20-Poly1305 ciphertext || tag - --- version 0x02: hybrid header, 2312 bytes -header 2312 bytes dh_pub[32] || N uint32 BE || PN uint32 BE - || kem_pub[1184] || kem_ct[1088] -nonce 12 bytes random, per message -ciphertext n+16 ChaCha20-Poly1305 ciphertext || tag -``` - -- `dh_pub` — the sender's current X25519 ratchet public key (32 bytes). -- `N` — the index of this message in the sender's current sending chain, - counting from 0. -- `PN` — how many messages the sender sent in its *previous* sending chain. -- `kem_pub` — the sender's current ML-KEM-768 ratchet encapsulation key - (1184 bytes). -- `kem_ct` — an ML-KEM-768 ciphertext (1088 bytes) that the sender - encapsulated to the *receiver's current* ratchet KEM key. It is repeated on - every frame of a chain a hybrid step established, so a lost first frame does - not wedge the chain. -- Associated data is the whole header for the version in use, exactly as - serialized above. A tampered `dh_pub`, `N`, `PN`, `kem_pub` or `kem_ct` - therefore fails closed. -- The ChaCha20-Poly1305 key is the message key from `KDF_CK`. The 12-byte nonce - is random per message, not a chain counter. -- A chat frame's minimum size depends on the header version, not the body: an - empty chat line still pads to the 256-byte bucket. Version `0x01` is 329 - bytes (5 + 40 + 12 + 256 + 16); version `0x02` is 2601 bytes - (5 + 2312 + 12 + 256 + 16). A hybrid message therefore carries 2272 more - header bytes than a classical one. See [Length buckets](#length-buckets). -- On the wire those become 350 bytes for `0x01` (329 + the Noise 16-byte tag + - the 5-byte framing header) and 2622 bytes for `0x02`. The 350-byte floor is - the classical case only. -- A `rat ` frame with no padding at all cannot occur for chat; the bare frame - overhead (empty ciphertext plaintext) is 73 bytes for `0x01` - (5 + 40 + 12 + 16) and 2345 bytes for `0x02` (5 + 2312 + 12 + 16). -- A receiver MUST reject a frame without the `rat ` prefix, a version other than - `0x01`/`0x02`, or a frame shorter than its version's minimum. -- The frame must fit the Noise body cap (65535 bytes, including the 16-byte - Poly1305 tag), so a `rat ` frame is at most 65519 bytes. A maximal hybrid - plaintext is therefore 63174 bytes, still far above the chat line limit. -- A `rat ` frame is one Noise body: the `fil ` chunk-pacing rules do not apply, - and the receive token bucket counts rendezvous accepts, not bytes, so the - larger hybrid header changes neither. - -Because the header rides inside Noise, an observer sees one opaque ciphertext -per message: no message counts, no ratchet keys, and nothing that marks a first -message of a chain versus a later one. - -### KDFs - -Signal's constructions, with a second domain for hybrid steps: - -``` -KDF_RK(root, dh_out): # v1: epoch 0, classical friends - okm = HKDF-SHA256(salt = root, ikm = dh_out, - info = "onionwire-ratchet-v1-kdfrk", L = 64) - new_root = okm[0..32] - chain_key = okm[32..64] - -KDF_RK_hybrid(root, dh_out, ss_kem): # v2: every hybrid ratchet step - okm = HKDF-SHA256(salt = root, ikm = dh_out || ss_kem, - info = "onionwire-ratchet-v2-kdfrk", L = 64) - new_root = okm[0..32] - chain_key = okm[32..64] - -KDF_CK(chain_key): - message_key = HMAC-SHA256(chain_key, 0x01) - next_chain_key = HMAC-SHA256(chain_key, 0x02) -``` - -`HKDF` is RFC 5869 with SHA-256, `HMAC` is SHA-256. The two `KDF_RK` forms -differ in **both** input shape and info string on purpose: `ikm` is 32 bytes for -v1 and `dh_out || ss_kem` (64 bytes) for v2, and the domain strings are -distinct. There is no way to derive a v2 chain without a real `ss_kem`, and a -classical derivation can never be mistaken for a hybrid one. - -Each side of an epoch derives its chains from one shared input with `KDF_RK` -called **twice**: - -``` -epoch_chains(root, shared) -> (new_root, ck_lo, ck_hi): # v1 - (root1, ck_lo) = KDF_RK(root, shared) - (root2, ck_hi) = KDF_RK(root1, shared) - new_root = root2 - -epoch_chains_hybrid(root, dh_out, ss_kem) -> (new_root, ck_lo, ck_hi): # v2 - (root1, ck_lo) = KDF_RK_hybrid(root, dh_out, ss_kem) - (root2, ck_hi) = KDF_RK_hybrid(root1, dh_out, ss_kem) - new_root = root2 -``` - -`lo` is the lexicographically lower of the pair's two ratchet public keys and -`hi` the higher, comparing the 32 raw bytes. The chain a peer sends on is -`ck_lo` if `sender_pub <= receiver_pub`, else `ck_hi`; the receiving chain is the -other one. The epoch's chains are a pure function of the *unordered* pair, and -the second `KDF_RK` call's root is the epoch's new root. - -### Bootstrap - -The bootstrap epoch is derived, never exchanged: the Noise handshake is frozen -and carries no payload, so there is no wire field to hand over an initial -ratchet public key. Both peers instead derive it from key material they already -have from the invite/roster (identity pubkey and signed prekey): - -``` -shared = X25519(my_prekey_sk, peer_prekey_pk) // 32 bytes -hk = HKDF-SHA256(salt = "onionwire-ratchet-v1-bootstrap", - ikm = shared) -root_key = hk.expand("root", 32) -my_secret = hk.expand("ratchet-key" || my_identity_pk, 32) -peer_secret = hk.expand("ratchet-key" || peer_identity_pk, 32) - -my_ratchet = keypair(my_secret) // x25519 secret/public + ML-KEM-768 -peer_ratchet = keypair(peer_secret) // derived by both sides, same values - -state = bootstrap(root_key, my_ratchet, - peer_ratchet.x25519_pub, - peer_ratchet.kem_pub if the friend row carries kem_pk else None) -``` - -`HKDF.expand` above is the RFC 5869 expand step (no second extract). The two -identity public keys are public (invite/roster), so either peer computes its own -secrets and the peer's, and both agree with no new wire field. The ML-KEM half of -each initial ratchet keypair is derived from that keypair's X25519 secret, so the -peer's KEM ratchet public key needs no wire field either: - -``` -kem_seed = HKDF-SHA256(salt = "ratchet-kem", ikm = x25519_secret).expand("seed", 64) -kem_pub = ML-KEM-768 encapsulation key from kem_seed -``` - -Then: - -``` -shared = DH(my_secret, remote_pub) -(new_root, ck_lo, ck_hi) = epoch_chains(root_key, shared) // v1: epoch 0 is classical -send_ck = chain_for(my_pub, remote_pub) // ck_lo or ck_hi -recv_ck = chain_for(remote_pub, my_pub) -send_n = recv_n = 0, PN = 0, established = false -``` - -Fresh entropy enters at the first DH ratchet step; the bootstrap epoch itself is -prekey-bound (see [THREAT_MODEL.md](THREAT_MODEL.md)). - -### Hybrid ratchet steps, and why epoch 0 stays classical - -Every ratchet keypair is now `{x25519, ML-KEM-768}`. On a step the peer that -rotates encapsulates to the receiver's **current** ratchet KEM key and puts -`kem_pub` (its new key) and `kem_ct` (that ciphertext) in the header. The -receiver decapsulates with the key it already holds, so both sides feed -`KDF_RK_hybrid` the same `(X25519 DH, ss_kem)` pair and derive the same chains. -No extra round trip is added: the KEM material rides on the rotation frame -itself, and is repeated on every later frame of that chain so a lost first frame -is harmless. - -**Epoch 0 cannot be per-session, so it stays classical.** Epoch 0's root is -derived from the two long-lived signed prekeys precisely so that neither side -needs a wire field and both converge even when both send first. The hybrid Noise -session does carry an `ss_kem` (see Transport), but each chat message is its own -one-shot Noise session: a fresh encapsulation, therefore a different `ss_kem` for -every dial, and *different* sessions for the two peers' first sends. Binding the -epoch-0 root to that secret would make the root a function of which session -carried which message, so: - -- two peers sending first would derive different epoch-0 roots and could not - read each other at all, and -- even a single direction would break at the second message, because message 2 - would arrive on a different Noise session with a different `ss_kem` while the - receiver still holds the root from message 1. - -There is no way to keep both "no wire field, both-send-first convergence" and a -per-session secret in epoch 0 without replacing the one-shot session model, which -is out of scope. Epoch 0 is therefore derived exactly as before, with the v1 -`KDF_RK`, and the KEM secret enters at the **first rotation after -`established`**. The first rotation is hybrid even for the bootstrap tie-break -rotation: that is what closes the window two round trips in. - -Consequences, stated exactly: - -- Every frame sent before the first hybrid step (the whole of epoch 0, in both - directions, plus any outbox row encoded on it) is protected by X25519 only. A - harvest-now adversary who later breaks X25519 can read those frames. This is - the residual window and it does not shrink with more messages, only with the - first rotation. -- Every frame on a chain established by a hybrid step additionally requires the - ML-KEM-768 secret. Breaking X25519 alone does not open it. -- A frame that carries a new `dh_pub` but no KEM section is **rejected** - (`hybrid step required`); a KEM section on a non-KEM friend is rejected too. - There is no classical fallback once a session has KEM material. - -**Convergence when both peers send first.** Either peer may send immediately on -the bootstrap epoch, so two peers can each build a sending chain before either -has received anything. Because the epoch's two chains come from the unordered -pair, both derive both directions and each sends on its own, with no -initiator/responder role. The only tie-break needed is for the *first* rotation: -the peer whose ratchet public key is lexicographically lower rotates — but only -after it has received a bootstrap-epoch frame (see `established` below); the -other adopts that new key as a normal DH step and only then rotates. From the -second epoch on, every rotation is a reply to an adopted key, so no tie-break is -needed and the ratchet alternates. - -**Why it stays in lockstep.** A DH ratchet step happens only on a frame whose -`dh_pub` has not been adopted yet, and the side that steps is the side that -receives. A peer cannot rotate twice without having received the other side's -rotation first, so at most one rotation is ever in flight, and both peers feed -`KDF_RK` the same `(root, dh)` pairs in the same causal order. - -### Receiving - -On a decrypted `rat ` frame (the outer Noise session has already been verified, -so the peer identity is pinned): - -1. Parse; reject a bad prefix or version, and a frame shorter than its - version's minimum (73 bytes for `0x01`, 2345 for `0x02`). -2. If `(dh_pub, N)` is in the skipped-key store: open with that key, **delete it** - from the store, deliver. A replay of the same frame then fails closed because - the key is gone. -3. Else if `dh_pub` equals the adopted remote ratchet public key, this is the - current receiving chain: - - `N < recv_n` → reject (message key already used). - - `N - recv_n > MAX_SKIP` → reject. - - Derive message keys for `recv_n .. N` into the skipped store, derive the - key for `N`, open, set `recv_n = N + 1`. - - On the *first* frame received in this state (`established == false`): set - `established`, and if `my_pub < remote_pub`, rotate the sending chain — - fresh `{x25519, ml-kem}` keypair; for a hybrid friend encapsulate to - `remote_kem_pub` and derive with `epoch_chains_hybrid(root, DH(new_secret, - remote_pub), ss)`, for a classical friend `epoch_chains(root, DH(...))`; - new sending chain for `new_pub → remote_pub`; `PN = old send_n`; - `send_n = 0`. The receiving chain is untouched. -4. Else it is a ratchet key not adopted yet: run a full DH ratchet step. A - session that holds `remote_kem_pub` rejects a frame with no KEM section, and - a session without KEM material rejects a frame that has one. - -### DH ratchet step - -On a frame whose `dh_pub` differs from the adopted remote public key: - -1. **Retire the current receiving chain.** `PN` is how many messages the peer - sent in it, so: - - `PN < recv_n` → reject (used message key). - - `PN - recv_n > MAX_SKIP` → reject. - - Derive `recv_n .. PN` into the skipped store, tagged with the retired - remote public key, so stragglers of the old chain still decrypt. -2. **Receiving half of the step**, on the pair `(my current secret, frame.dh_pub)`: - `shared = DH(my_secret, frame.dh_pub)`. For a hybrid step also - `ss_kem = ML-KEM.Decaps(my_current_ratchet_kem_secret, frame.kem_ct)`, then - `(root_a, ck_lo, ck_hi) = epoch_chains_hybrid(root, shared, ss_kem)`; - otherwise `(root_a, ck_lo, ck_hi) = epoch_chains(root, shared)`. - `recv_ck = chain_for(frame.dh_pub, my_pub)`, then open the frame with this - chain exactly as in step 3 above (it must be within `MAX_SKIP` of index 0). -3. **Sending half:** generate a fresh ratchet keypair `{x25519, ml-kem}`. For a - hybrid step encapsulate to `frame.kem_pub` (`(kem_ct, ss_kem) = - ML-KEM.Encaps(frame.kem_pub)`), derive - `(root, ck_lo, ck_hi) = epoch_chains_hybrid(root_a, DH(new_secret, - frame.dh_pub), ss_kem)` and keep `kem_ct` in the state so every frame of the - new sending chain carries it; otherwise `epoch_chains(root_a, DH(...))`. - `send_ck = chain_for(new_pub, frame.dh_pub)`, `remote_pub = frame.dh_pub`, - `remote_kem_pub = frame.kem_pub`, `PN = old send_n`, `send_n = 0`, - `established = true`, `recv_hybrid = frame has a KEM section`. -4. The frame is opened with the *new* receiving chain's message key. If the AEAD - open fails, nothing is applied: the state must be byte-identical to before - the frame. (A tampered `kem_ct` yields a different `ss_kem` through ML-KEM's - implicit rejection, and the AEAD then fails; a tampered `kem_pub` is inside - the AAD, so it fails the same way.) - -The next frame this side sends therefore carries the new `dh_pub`, which is what -lets the peer step too. - -### Bounds and replay - -- `MAX_SKIP = 2000`. Checked on both jumps: `N - recv_n` on the current chain - and `PN - recv_n` while retiring one. `jump == 2000` is accepted, - `jump == 2001` is rejected (`MaxSkipExceeded`) and leaves the state untouched. -- `MAX_SKIPPED_KEYS = 2000` stored message keys. When the store is at the cap, - inserting a new key evicts the **oldest-inserted** entry first — insertion - order, not `N` order. -- A skipped key is removed the moment it decrypts a frame, so a replayed frame - fails closed (`UsedMessageKey` or an AEAD failure). -- Every bound is validated before any state mutation. A rejected or tampered - frame must leave the state byte-identical. - -### State at rest - -`ratchet_sessions` in the SQLCipher store: one row per friend -(`friend_id` primary key, `FOREIGN KEY` → `friends.id` `ON DELETE CASCADE`, -`state BLOB NOT NULL`, `updated_at`). The blob is version byte `0x02` followed by -the implementation's serialized ratchet state: - -``` -0 version 0x02 -1..211 fixed prefix: root, local secret/public, remote public, - send_ck/send_n, recv_ck/recv_n, PN, established, flags, - skipped-count -then remote ratchet KEM public key (1184 bytes) if flag 0x01 -then pending KEM ciphertext (1088 bytes) if flag 0x02 - (flag 0x04 marks a receiving chain established hybrid) -then skipped keys, dh_pub[32] || n u32 BE || message key[32] -``` - -The state is device-local: it is **never** transmitted, and its layout is not -part of this wire protocol. The store is encrypted as a whole, so the blob is -ciphertext on disk. - -**Hard cut.** Version `0x01` is the pre-hybrid layout, which had no KEM ratchet -key and no pending ciphertext. It is **dropped, not migrated**: on load, a v1 -blob is deleted and the session re-bootstraps from the two prekeys, exactly the -way an `F8` prekey rotation drops state. Nothing is half-read, and epoch 0 comes -back identical because its derivation did not change. A *corrupt* v2 blob or one -written by a **newer** version is reported as an error instead — those are not an -old format, and silently resetting them would be a downgrade. The same cut -applies to any peer whose prekey or KEM key changes. - -### Not ratcheted - -`loc `, `prf `, `inv `, `rcp `, `tip `, `png ` and `fil ` frames — and every -file chunk — keep the one-shot Noise shape: one handshake per application frame, -no ratchet, no persistent session. Only chat is ratcheted. - -### Prekey change resets the epoch - -A peer whose prekey changes invalidates the bootstrap epoch on both sides, and -the stale state is dropped locally, so the next chat frame starts a fresh -bootstrap epoch. Frames sent under the dropped epoch are not readable -afterwards. There is no key-confirmation exchange and no in-band reset command; -the new invite is the signal. - -## Invite (out of band) - -Not a QR graphic. A single ASCII string, max 4096 characters: - -``` -onionwire:v2:k=<64 hex>:o=:spk=<64 hex>:kem=:sig=<128 hex> -``` - -Field order in the string is not significant; duplicate or unknown fields are -rejected. `k` is the identity pubkey, `spk` the x25519 prekey, `o` the current -locator, and `kem` the ML-KEM-768 encapsulation key (1184 bytes) encoded as -unpadded base64url (1579 characters). A v2 invite is about 1.9 KB, still well -under the 4096-character cap. - -**Current signature (encode this):** - -``` -ed25519_sign(identity_sk, - "onionwire-invite-v2" || 0x00 || k_ascii || 0x00 || o_ascii || 0x00 || - spk_ascii || 0x00 || kem_ascii) -``` - -`k_ascii` / `spk_ascii` are the hex strings as they appear in the invite -(lowercase); `kem_ascii` is the base64url field value after `kem=`. Because the -signature covers `kem_ascii`, removing the field or substituting a different -key fails verification — that is the anti-strip/anti-substitution property. - -**Legacy accept (`onionwire:v1`):** a v1 invite has no `kem` field. Decode -accepts it while `LEGACY_SIGS` is on and yields a friend with no `kem_pk`, i.e. -a classical peer; with the switch off a v1 invite fails closed. A v1 -signature is accepted in either historical form: the tagged -`"onionwire-invite-v1" || 0x00 || k || 0x00 || o || 0x00 || spk` or the raw -concatenation `k || o || spk` (no tag, no separators), so old invites keep -verifying. `onionwire:v2` MUST have `kem=` and MUST verify over the v2 domain; -a v2 body relabelled v1 does not verify. - -Encode MUST emit `onionwire:v2` only. Unknown `k`: prompt. Same `k`: update -locator, prekey and KEM key on that row (never a second friend), and drop the -stored ratchet state if either key changed. - -## What v1 will not grow into - -No DHT, no directory server, no hosted/server-side outbox, no XMPP/Prosody, no -C-tor fallback, no multi-device, no A/V, no STUN/ICE/WebRTC, no system DNS for -friends. - -A **local-only** chat retry queue is in v1. It is not a mailbox and it never -leaves the device. “No outbox” in this document means **no server-side** -store-and-forward. - -Those are how Tox-over-Tor leaks (UDP DHT, mixed clearnet, “just one direct -path”). They are out of scope, not postponed. - -## Versioning - -- Frame `version` 1 (normal), frame `version` 2 (PQ prelude), invite - `onionwire:v2` (emit) and invite `onionwire:v1` (decode only) are this - document. -- A new handshake prologue or a new invite scheme is a breaking change. The - hybrid prologue and the prelude are exactly that: v1 peers cannot talk to a - friend that has a `kem_pk`. -- New typed prefixes (`xyz `) are backward compatible if old peers drop them. -- The `rat ` frame has its own version byte (`0x01` classical, `0x02` hybrid). - A different ratchet frame layout or a different KDF is a breaking change for - chat only: peers that disagree cannot read each other's chat, and every other - frame keeps working. A `0x02` frame from a peer whose roster row says - `classical`, or a `0x01` step from a hybrid peer, is rejected. diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index cadbea5..0000000 --- a/docs/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# OnionWire docs - -Read these in order if you are evaluating the protocol without the Rust: - -1. **[PROTOCOL.md](PROTOCOL.md)** — wire format, handshake, invite, frames. - This is the document a second implementation would use. -2. **[THREAT_MODEL.md](THREAT_MODEL.md)** — what v1 claims, and what it - refuses to claim. -3. **[SECURITY_AUDIT.md](SECURITY_AUDIT.md)** — in-house review notes and - which findings are still open. **Not** a public third-party audit. - -Operator / product docs: - -- **[../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), - the reproducible build recipe, and the signing key. -- **[VERIFY.md](VERIFY.md)** — checking a download: the dependency graph, the - wallet's real exposure, rebuilding a release and comparing bytes, and what - none of that proves. -- **[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). - -Decision records and spike reports (history — not living operator docs): - -- [arti-socks-feasibility.md](arti-socks-feasibility.md) -- [option-a-recommendation.md](option-a-recommendation.md) -- [cuprate-launch-spike.md](cuprate-launch-spike.md) -- [cuprate-android-spike.md](cuprate-android-spike.md) -- [payment-integration-plan.md](payment-integration-plan.md) diff --git a/docs/RELEASING.md b/docs/RELEASING.md deleted file mode 100644 index de6fe43..0000000 --- a/docs/RELEASING.md +++ /dev/null @@ -1,280 +0,0 @@ -# Releasing OnionWire - -How a maintainer cuts a release. This is **not** automatic: a merge to `main` -does not publish, and a tag push does not publish. Two dispatches, `dry_run` -first, Android APK joins the same tag. - -Short version: [`README.md`](../README.md#releases-maintainers). - -## Policy: manual, batched releases - -A merge does **not** publish anything. Neither does a tag push. - -A release happens when a **batch of work has reached a stopping point**, chosen -by hand: - -- CI is green on `main` (the `ci` workflow passed for the last push), and -- the feature set you mean to ship has landed — not a half-merged stack, - not a branch you are about to rewrite, and -- you are ready to answer user reports against the version you are about to - stamp. - -Everything else about the pipeline is unchanged: both architectures, one -tagged release, `.sha256` for every asset, the fail-closed "delete the tag we -created if the build or publish fails", and the dry-run path. - -## Procedure - -1. **Confirm the stopping point.** `main` is the commit you want to release, - its CI run is green, and nothing you intend to include is still in an open - PR. The release workflow packages whatever `main`'s head is when the tag is - created. -2. **Dry-run it.** Actions → **release** → *Run workflow*, `dry_run=true`. - That builds and checksums both Linux binaries with no tag and no publish, - so it proves the pipeline without stamping a version. (A dry run does not - build the Android APK — there is no tag, so nothing wakes - `android-release`.) -3. **Cut the release.** Actions → **release** → *Run workflow* with - `dry_run=false` (the default) and the bump you want. The version must not - already be tagged. -4. **Watch it.** The run name is `release`; `scripts/watch-release-run.sh` - reports job status (it reads `action_run`/`action_run_job` on the Pi's - database, so it works for dispatched runs as well as any other). -5. **Attach the Android assets.** Dispatch `android-release` with the tag the - core run just created — see [Android](#android-apk--aar-on-the-same-tag). - The Linux binaries land first; the APK build is the long pole. -6. **Check the assets.** Open the release page (or - `GET /api/v1/repos/sirius/onionwire/releases/tags/`) and require a - non-zero `size` for every asset. A Linux release is **eleven** assets: - - | asset | what it is | - |---|---| - | `onionwire-` ×2 | the two Linux binaries | - | `onionwire-.sha256` ×2 | their checksums | - | `onionwire-.minisig` ×2 | the binary signatures | - | `onionwire-.sha256.minisig` ×2 | the checksum signatures | - | `build-info-.txt` ×2 | the recipe record (commit, epoch, toolchain, image digest) | - | `onionwire-signing.pub` | the public half of the signing key | - - plus the APK + `.sha256` and the AAR + `.sha256` attached by `android-release`. - A green run is not proof — the Pi runner hairpins through Cloudflare and has - uploaded 0-byte assets before. - -7. **Spot-check reproducibility.** On any machine with docker and a clone: - - ```bash - scripts/verify-reproducible.sh - ``` - - It has to print `RESULT: MATCH`. A `MISMATCH` means the published binary is - not what this tag builds to — release-blocking, not cosmetic. Diagnose with - the `build-info-.txt` on the release before assuming compromise: - a different commit or a moved image digest explains most mismatches. - -## Inputs - -| Input | Default | Meaning | -|---|---|---| -| `dry_run` | `false` | Build + checksum only. No tag, no publish. | -| `bump` | `minor` | `patch` / `minor` / `major` off the newest `v*.*.*` tag. | -| `version` | — | Explicit `X.Y.Z` or `vX.Y.Z`; overrides `bump`. | -| `tag` | — | Rebuild / re-publish an existing tag instead of minting a new one. | - -Contradictory input is rejected, never guessed at: - -- `tag` **and** `version` together → the run fails in the `version` job. -- `version` that is not `MAJOR.MINOR.PATCH` (optionally `v`-prefixed) → fails. -- `bump` outside `patch|minor|major` → fails. - -## What the run does - -`version` job (Pi runner): - -1. Resolves the tag: the `tag` input, else the `version` input, else `bump` - applied to the newest `v*.*.*` tag (`v0.1.0` when the repo has no tags). -2. When minting a new version, creates the tag over the Forgejo API. If the - tag already exists on a different commit, the run **refuses to move it** - and fails. `201` means created; `409` means it was created concurrently and - this run joins it. - -`aarch64` (Pi runner) and `x86_64` (amd64 runner) jobs run -`scripts/reproducible-build.sh` inside the **digest-pinned** builder image -(`RUST_IMAGE` in the workflow). That script owns the whole build: `--locked`, -fixed in-container paths, `SOURCE_DATE_EPOCH` from the released commit, the -`--remap-path-prefix` set, `strip --strip-all`, the `.sha256`, and the -`build-info-.txt` record. The job then only refuses a half-made dist and -uploads it — the target volume is created per run and removed afterwards, so the -published binary cannot come out of a cache a verifier does not have. - -The `SOURCE_DATE_EPOCH` step reads the committer time of -`needs.version.outputs.sha`. It is deliberately not "now": a rebuild of this tag -in six months has to hand the compiler the same epoch CI handed it. - -`publish` job (Pi runner) downloads both artifacts, stages them into `dist/`, -signs every asset with `scripts/sign-release.sh` inside the same digest-pinned -builder image, and only then calls `scripts/publish-release.sh` to create-or-update -the release with all four Linux assets plus the committed public key. Signing runs -in a container fed by a **named volume + `docker cp`**, not a bind mount of the -workspace: on this runner `$GITHUB_WORKSPACE` is a path inside the job container, -while docker resolves a `-v` source on the host — a bind mount therefore arrives -empty and the sign script is missing (run 768). Signing is also staged *after* -`dist/` is populated, so the files it signs exist; a run with no -`MINISIGN_SECRET_KEY` still stops before anything is uploaded. If this job fails -and the tag was created by *this* run, the final step deletes the incomplete -release and the tag. A failed `aarch64` or `x86_64` job always fails `publish`, so -nothing is published half-built. - -## Android (APK + AAR) on the same tag - -A release is **two dispatches**. After the core run has created the tag and -published the Linux binaries: - -1. Actions → **android-release** → *Run workflow*, `tag=vX.Y.Z` (the tag the - core just created; leave `dry_run` false). -2. Check the release again — the APK + AAR + `.sha256` are attached to the - **same** tag. If the release did not exist yet it is created; if it exists - it is joined (`publish-release.sh` is create-or-update). - -`android-release.yml` has no automatic trigger, and that is deliberate. Both -candidate decoupled triggers were tried on this instance and neither fires: - -- **A tag created by `release.yml` does not wake `push: tags: ['v*.*.*']`.** - Tried both ways — the tag created through `POST /tags`, and the tag created - by a real `git push` from the version job. Neither produced an - `android-release` run: pushes made with the CI's token are Actions-user - events, and Forgejo deliberately does not dispatch those back into Actions - (`services/actions/notifier_helper.go`: a doer that `IsActions()` is ignored). - Historically, *hand-pushed* tags did fire tag-filtered workflows, which is why - the trigger looked plausible. -- **`workflow_call` is unavailable.** Reusable workflows only appear in the - Forgejo docs from v12 onward; this instance reports - `10.0.3+gitea-1.22.0` (`GET /api/v1/version`), so a caller job with - `uses: ./.forgejo/workflows/android-release.yml` would never run. The - `workflow_call` block is left declared for the day the instance is upgraded. - -The Android build runs on the **amd64** runner (the Pi is aarch64 and cannot -produce an APK), then a second job on the Pi attaches the assets. It is the -long pole of a release — the Linux binaries land first. - -### Android CI (not a release) - -`android-ci.yml` runs the same gradle targets on the same amd64 runner, so an -android-only PR is no longer merged on an empty check list. It signs with the -**debug** key (`ONIONWIRE_REQUIRE_RELEASE_KEY=false`, no keystore) and -publishes nothing — `apksigner` in that job reports the debug cert, which is -expected there and never in `android-release`. It shares -`android-release.yml`'s concurrency group and volumes, so the PR build is warm -(~9 min) instead of re-downloading a gigabyte of SDK/NDK. - -The two triggers are deliberately **not** the same, because the APK embeds the -root crate as `libonionwire_sdk.so` and a full build costs ~11 minutes: - -- **`pull_request`** — `android/**`, `crates/onionwire-sdk/**`, `Cargo.toml`, - `Cargo.lock`, `scripts/build-android-local.sh`. Client and binding-surface - changes get the pre-merge signal. -- **`push: [main]`** — the above plus `src/**` and `crates/**`. Every merge of - a Rust change still runs the full build, including the in-APK checks that - earn their keep (the `target_max_memory` marker gate, the `.so` listing, the - sha256 round-trip). Nothing reaches a release untested; a Rust-only PR finds - out at merge rather than before it. - -Both `ci.yml` and `android-ci.yml` open with a **staleness gate**: they compare -`GITHUB_SHA` against the remote branch tip and skip the build if a newer commit -landed while the run sat in the concurrency queue. `cancel-in-progress` is -deliberately `false` on both (cancelling a queued run would let two cargo jobs -share the Pi's target volume, which produces `Permission denied (os error 13)` -on `/target/debug/deps`), so the gate is what removes superseded work. A -`git ls-remote` failure runs the job rather than skipping it. - -The `ci / fuzz` job is **not** in `ci.yml` any more — it is -`.forgejo/workflows/fuzz.yml`, `schedule`-only at 03:30 UTC plus -`workflow_dispatch`. A job cannot narrow a workflow-level path filter, so -`fuzz/**` sat beside `src/**` in `ci.yml`'s list and the job ran on nearly -every push (80 of 84 recorded runs touched nothing in `fuzz/`), each paying a -nightly toolchain install and `cargo install cargo-fuzz` for 15 seconds of -fuzzing. Fuzz output is not attached to any PR; check the `fuzz` workflow's -run history for it. - -## Rebuilding an existing tag - -- **Both** Linux binaries: dispatch `release` with `tag=vX.Y.Z`. The tag's own - commit is built, its existing assets are replaced, and no new tag is created. -- **Android only**: dispatch `android-release` with `tag=vX.Y.Z`. -- The local `FORGEJO_TOKEN= scripts/build-release-local.sh vX.Y.Z` - fallback does the x86_64 build without CI. - -Never move or delete a published `v*.*.*` tag by hand, and never create one by -hand: a hand-pushed tag starts nothing (`release.yml` has no tag-push trigger), -and `release.yml` will refuse to move a tag that exists on another commit. - -## Reproducibility and signing - -Two properties a download can be checked against, and one prerequisite that no -one else can do for you. - -### The recipe - -`scripts/reproducible-build.sh` is the single definition of a release build. -Everything that can move the output bytes is pinned inside it: - -- the **builder image, by digest**. `rust:1.98-bookworm` floats, and a rustc - patch release changes codegen. The digest must be identical in three files — - `RUST_IMAGE` in `.forgejo/workflows/release.yml`, and `BUILDER_IMAGE` in both - `scripts/verify-reproducible.sh` and `scripts/build-release-local.sh`. Bump all - three in **one** commit, and expect the hashes to change: that is a toolchain - change, not a compromise. -- **fixed absolute paths**, because rustc's `--remap-path-prefix` cannot reach - absolute paths compiled in by a C toolchain, and this crate always has one: - `rusqlite`'s `bundled-sqlcipher-vendored-openssl` compiles OpenSSL from source - and OpenSSL bakes its build paths into the artifact. -- **`SOURCE_DATE_EPOCH`** from the released commit's committer date. -- **`--locked`**, and `RUSTFLAGS` is replaced rather than extended so an ambient - profile setting cannot silently change the bytes. - -### The signing key (one-time, yours to hold) - -```bash -minisign -G -W -p scripts/onionwire-signing.pub -s onionwire-signing.key -``` - -`-W` keeps the secret key unencrypted, because CI cannot answer a prompt and a -passphrase stored beside the key protects nothing. Then commit the `.pub`, add -the `.key` file's **contents** as the Actions secret `MINISIGN_SECRET_KEY`, and -delete the `.key` from your machine. - -**Until that secret exists, releases fail.** The signing step runs *before* -publish and exits non-zero without a key, so nothing unsigned reaches the -release page. That is deliberate: an unsigned release is indistinguishable from -a signed one to anyone who is not checking, which makes it worse than no release. - -`scripts/sign-release.sh` also verifies each signature it just made against the -committed public key before returning, so a broken key fails at signing rather -than after the assets are public. - -### The local fallback - -`scripts/build-release-local.sh` runs the same pinned container and the same -recipe, and requires `MINISIGN_SECRET_KEY` too. It is a fallback for a dead -runner, not a way to ship something the verifier cannot reproduce — a host -`cargo build` would produce a binary whose hash no one could match. - -## Version policy - -`MAJOR.MINOR.PATCH` on the tag (`v`-prefixed). The default bump is `minor`: a -batched release is usually a feature set, and `patch`-incrementing it would -mislabel it. Use `patch` for a fix-only batch, `major` for a breaking wire or -store change. The tag is the version users see; `Cargo.toml` is **not** edited -by the workflow — keep it in sync by hand if the crate version matters to you. -The Android `versionCode` is derived by the Android workflow from -`major*10000 + minor*100 + patch`. - -## What the workflows do not gate on - -- **No "CI must be green" check inside the release job.** The operator checks - that by hand before dispatching. A release dispatched while CI is red will - build and publish anyway. -- No changelog generation: `scripts/release-body.md` is the template, with - `@TAG@` substituted. -- No approval gate, no environment protection, no automatic rollback beyond - the fail-closed tag delete described above. -- No notification on success: read the run and the release page. diff --git a/docs/SECURITY_AUDIT.md b/docs/SECURITY_AUDIT.md deleted file mode 100644 index cab9d75..0000000 --- a/docs/SECURITY_AUDIT.md +++ /dev/null @@ -1,40 +0,0 @@ -# OnionWire security notes - -**This is not a public third-party audit.** It is an in-house review of -commit `2b42864` plus a status check against the current tree. Do not cite it -as “audited.” OnionWire has not had a public external security assessment. - -Protocol: [PROTOCOL.md](PROTOCOL.md). Claims: [THREAT_MODEL.md](THREAT_MODEL.md). - -Original pass: rust-dev, no live hidden service / live wallet. Ignored tests -(`rotate_hs`, `tor_hs`, `two_node`) were not run. - -## Finding status (vs current tree) - -| Id | Original | Now | -|---|---|---| -| F1 receipt `verified` on OR-match | High — txid **or** addr+amount | **Fixed.** `transfers_match` requires txid ∧ amount ∧ address, all non-empty. | -| F2 chat AEAD empty AAD | Medium — row swap | **Fixed.** AAD `owmsg1 \|\| friend_id_le64 \|\| dir \|\| 0x00 \|\| row_id_le64`. | -| F3 invite concat signature | Medium — field shift | **Fixed on encode.** Domain tag `onionwire-invite-v1` + `0x00` separators. Decode still **accepts** legacy concat so old invites work. | -| F4 Monero address shape-only | Medium | **Fixed.** Base58 + Keccak checksum + network prefixes. | -| F5 wallet RPC no auth | Medium | **Fixed.** HTTP Digest required; open RPC refused; 1 MiB read cap; `.onion` RPC URLs refused. | -| F6 `/wipe` skipped payments | Low | **Fixed.** `/wipe` also `DELETE FROM payments` + WAL checkpoint. Still not forensic. | -| F7 HS logs unredacted onion | Low | **Fixed.** stderr uses a redacted label. `dangerously_trust_everyone` remains on Arti storage only. | -| F8 threat model vs F1–F3 | Low | **Fixed** in [THREAT_MODEL.md](THREAT_MODEL.md) when the code landed. | - -## Still true / not a “finding we forgot” - -- At rest the whole store is SQLCipher (Argon2id key over a 16-byte `store_salt`), so the identity secret key, roster (pubkeys + locators) and chat bodies are ciphertext on disk; chat bodies add a row-bound AEAD layer on top. That is not a defense against a live compromise or an attacker who has the passphrase — see [THREAT_MODEL.md](THREAT_MODEL.md). -- Arti onion services are experimental. Fail closed; no C-tor fallback. -- No public third-party audit. This file is not one. -- Invite decode still accepts the legacy concat signature (compatibility). -- Rate limit is availability, not traffic-analysis defense. -- One-shot sessions: no channel binding across file chunks beyond “same Noise peer.” -- The in-process Cuprate chain daemon is opt-in and **unvalidated on mainnet**. - -## Verified correct (original pass, still the protocol) - -Noise is `Noise_IK_25519_ChaChaPoly_BLAKE2s`, prologue `onionwire-v1`, 96-byte -identity proofs, loc/prf/inv/rcp signed under the session identity, unknown -`[a-z]{3} ` prefixes dropped, frames length-checked before allocate. See -[PROTOCOL.md](PROTOCOL.md). diff --git a/docs/THREAT_MODEL.md b/docs/THREAT_MODEL.md index 14ac1e1..26285f8 100644 --- a/docs/THREAT_MODEL.md +++ b/docs/THREAT_MODEL.md @@ -1,10 +1,6 @@ # OnionWire threat model (v1) OnionWire is a two-party chat over Tor onion services. There is no chat server. -Identity is an ed25519 pubkey; the onion is a locator only (`F4` rotates the -locator, nothing else). Wire format: [PROTOCOL.md](PROTOCOL.md). Wallet: -[WALLET.md](WALLET.md). In-house review notes: [SECURITY_AUDIT.md](SECURITY_AUDIT.md) -— **not** a public third-party audit. Do not cite that file as “audited.” ## Tor relays are not a chat server @@ -12,425 +8,20 @@ Each install hosts its own v3 onion and dials friends’ onions through in-proce ## Location updates are not a missing-person finder -A signed `loc` frame (`onion`, `ts`, `sig`) rewrites a friend’s locator **only if** that friend is already in the roster, the signature verifies against the pinned pubkey, and `ts` is newer. There is no directory, DHT, or introduction server. If you rotated while they were offline, they cannot find you until they F3-paste your new invite. OnionWire will not hunt for a missing person. +A signed `loc` frame (`onion`, `ts`, `sig`) rewrites a friend’s locator **only if** that friend is already in the roster, the signature verifies against the pinned pubkey, and `ts` is newer. There is no directory, DHT, or introduction server. If you rotated while they were offline, they cannot find you until they rescan your QR. OnionWire will not hunt for a missing person. ## Rotating the onion does not revoke a friend -`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. +`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 QR/rescan 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 +## v1 stores plaintext locally -`F8` rotates the long-lived signed prekey **and the ML-KEM-768 install key**. The identity key and the onion are unchanged, but the prekey is our Noise static **and** the seed of the bootstrap ratchet epoch, and the KEM key is what peers encapsulate to, so once either moves nothing is reachable any more: a friend's dial uses the prekey and `kem=` they pinned from your invite, and their stored epoch is derived from the old prekey. There is no push path for either key — they only travel 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). - -## Post-quantum transport does not make messaging post-quantum - -Every Noise session to a v2 friend carries an ML-KEM-768 secret. The -initiator sends a `version = 2` prelude with `ct = Encapsulate(friend.kem_pk)` -before Noise msg 1, and both sides mix `(ct, ss_kem)` into the Noise prologue -(`"onionwire-v2" || 0x00 || ct || 0x00 || ss_kem`). A recorded handshake -therefore exposes an X25519 DH and an ML-KEM-768 encapsulation; a future -cryptographically relevant quantum adversary has to break ML-KEM-768 as well as -X25519 to recover the Noise transport keys. That removes the -harvest-now-decrypt-later exposure of the **one-shot transport**. - -What this does **not** buy: - -- **The chat ratchet stays classical.** Chat messages are `rat ` frames - (Double Ratchet, `docs/PROTOCOL.md`). The **bootstrap epoch is derived only - from the two long-lived X25519 prekeys** (HKDF over their DH, with the - identity pubkeys mixed in), so an adversary who records a `rat ` chain and - later obtains both prekeys can reconstruct epoch 0 even though the Noise - session that carried it was hybrid. Later epoch chains use fresh X25519 DH - steps, which are equally quantum-vulnerable. PQ ratchet steps are a separate - follow-up, not part of this transport work. -- **Identity and invite signatures are ed25519**, still classical. The KEM key - is authenticated by a v1-style ed25519 invite signature; an adversary who can - forge it can also swap `kem=`. Hybrid transport protects confidentiality, not - the long-term authentication root. -- **Legacy friends get nothing.** A friend added from an `onionwire:v1` invite - has no `kem_pk`; sessions to them are the old classical `onionwire-v1` - prologue, and the UI labels that friend as lacking PQ protection. The choice - is derived from the roster row, never from the wire: a `kem_pk` friend - rejects a prelude-less session with `prelude required` before any application - frame, so an active attacker cannot downgrade it. -- **Mixed-version fleets break.** A v1-only build cannot open a session with a - v2 friend; that is accepted rather than adding a fallback path. - -## Your store is encrypted - -The sqlite store is SQLCipher (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`). -A 32-byte key is derived from the store passphrase with Argon2id — m = -65_536 KiB (64 MiB), t = 3, p = 1, out = 32 — over a per-install 16-byte salt -in `store_salt`, and handed to SQLCipher as a **raw** key (`PRAGMA key = -"x'…'"`) — no second KDF pass over it. The identity backup and the -message-key wrap in `store_meta` use the same profile. Parameters are -versioned with the data: a backup blob names its profile in the header and -`store_meta.kdf_profile` names the store's, and an unknown profile id is a -clear error, never a silent fallback. Data written with the earlier -19_456 KiB / t=2 / p=1 profile still opens: a legacy store is rekeyed and its -message key re-wrapped with the current profile on the first successful -unlock, and a legacy backup file opens as-is (re-exporting it writes the -current profile). -The key is the first statement after open, so the file header, schema, identity -secret key, friend public keys, locators, profiles, payment rows and the -per-friend ratchet session blobs (`ratchet_sessions`) are all ciphertext on -disk. There is no `identity_sk`-on-disk problem to work around -because `identity_sk` is inside the encrypted file. 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 installs have a plaintext db. The first open with the right passphrase -upgrades it in place (`ATTACH … KEY` + `sqlcipher_export` after a WAL -checkpoint), and swaps the file in only after the new file opens, passes -`integrity_check` and unwraps `store_meta`. A wrong passphrase leaves the -plaintext file untouched. The `store_salt` file is not secret (a salt never is). - -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 wrapped with Argon2id from -the same passphrase (`store_meta`). Whole-db encryption does not stop someone who -can write the file from moving one row's ciphertext into another row; the AAD -does, and it stays. Unlock is fail-closed: wrong or empty passphrase does not -open chat. Empty-AAD v0.2 blobs are rewrapped once on unlock; `list_messages` -never falls back to empty AAD. - -At-rest encryption is not a defense against a live compromise: while OnionWire -runs, the passphrase, the db key and decrypted bodies are in process memory, and -SQLCipher's page cache holds decrypted pages. It also does not stop an attacker -who has your passphrase. `/wipe` deletes chat and payments history (overwrite -message bodies, `VACUUM`, WAL checkpoint); roster and identity stay. It is not a -forensic erase — SSD wear-leveling can keep copies. `/wipe-all` deletes the data -dir (new identity); same disk caveat. +The message log, identity secret key, and friend public keys sit on disk unencrypted (aside from whatever the OS/FDE provides). A seized laptop yields the chat history and who you talk to. `/wipe` overwrites message bodies and vacuums; `/wipe-all` deletes the data dir. sqlcipher is out of v1. ## Fail closed -Peer onion down → a **chat** send is queued locally and retried (see “Local outbox (chat retry queue)”); file transfer and payment frames still fail immediately. Fingerprint mismatch vs the pinned key → hard fail, no send, never queued. Arti HS experimental: if it cannot publish, OnionWire stops; it does not fall back to C-tor. - -## Local outbox (chat retry queue) is local, and it re-dials on a schedule - -A chat send to an unreachable onion is written to an `outbox` row next to its `messages` row and retried in the background. There is no server-side queue: a queued message is never handed to a third party, and it dies with the device. Two consequences are real and are accepted: - -- **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. -- **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. - -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 -frame, close, one circuit per message. Chat stacks a Double Ratchet *inside* -that frame (`rat `, [PROTOCOL.md](PROTOCOL.md)), with per-friend state persisted -in the encrypted store (`ratchet_sessions`). The ratchet changes what a stolen -chat line is worth; it does not re-open any lock: no relay, no server-side -queue, one frame per Noise session, and the ratchet state never leaves the -device. - -**Gains.** - -- *Per-chain forward secrecy.* Every message key is `HMAC-SHA256(chain_key, - 0x01)` over a chain key that is replaced by `HMAC-SHA256(chain_key, 0x02)` - after each message, so state recovered after a chain has moved on does not - decrypt the messages already sent on it — outside the skipped-key window - below. -- *Post-compromise security after a DH ratchet step.* An attacker holding a - snapshot of one side's state cannot read the conversation past the next DH - ratchet step: that step feeds a fresh X25519 output — and, from the first - rotation, a fresh ML-KEM-768 secret — into the root, and the snapshot stops - producing chain keys. The window is not zero — it lasts until the next step — - but no attacker can prevent it closing. -- *Quantum-resistant chains from the first rotation.* Every ratchet step mixes a - fresh ML-KEM-768 secret into `KDF_RK` alongside the X25519 output - (`dh_out || ss_kem`, info `onionwire-ratchet-v2-kdfrk`). A harvest-now - adversary who records a hybrid chain and later breaks X25519 still needs the - ML-KEM-768 secret to walk that chain, which breaking X25519 does not give. - Ratchet keypairs are generated as `{x25519, ml-kem}` with the KEM seed derived - from the X25519 secret, so the KEM half adds no state to protect. -- *The ratchet header is not on the wire.* `dh_pub`, `N`, `PN` and, on hybrid - chains, `kem_pub`/`kem_ct` ride inside the Noise ciphertext (authenticated as - AEAD associated data), so message counts and ratchet-key changes are not - observable, and a tampered header fails closed. A missing KEM section on a - step is a hard `hybrid step required` rejection, never a classical fallback. - -**Honest limits.** - -- *Skipped-key window.* Up to `MAX_SKIP` (2000) message keys of one chain, or up - to `MAX_SKIPPED_KEYS` (2000) entries across a friend, stay decryptable to - whoever holds the state until they are used (deleted on use) or evicted - oldest-first. A snapshot also carries the current sending and receiving chain - keys, which read the current chain until it advances. This is the price of - out-of-order delivery, and it is per friend. -- *Epoch 0 is classical — this is the remaining harvest-now window.* The - bootstrap root and both initial ratchet secrets are HKDF outputs of the - X25519 DH between the two long-lived signed prekeys, and the identity pubkeys - that separate them are public. A per-session KEM secret cannot be folded into - epoch 0: each chat message is its own one-shot Noise session, so `ss_kem` - differs per dial and per peer, and a root bound to it would make the two peers - (or even message 1 and message 2) derive different chains. Epoch 0 is - therefore derived with the classical `KDF_RK`, and the ML-KEM secret enters at - the **first rotation** — two round trips in, at the latest. - What that leaves exposed, precisely: - - The epoch-0 *chain keys* are not post-quantum. A future X25519 break - reconstructs the prekey DH, hence the epoch-0 root and every message key on - that chain. This covers everything sent before the first hybrid step, - including any frame that was encoded on epoch 0 and left in the outbox. - - It does **not** by itself open a recorded v2 transcript, because a v2 friend - wraps every `rat ` frame in the hybrid Noise session (ML-KEM-768 prelude). - The epoch-0 chain keys are a second layer; breaking X25519 alone still leaves - that outer layer closed. The exposure becomes real the moment the rat frame - itself is accessible — a state snapshot taken at epoch 0, an old client that - logged it, or a peer running the classical transport. - - For a **classical (v1) friend** there is no PQ layer anywhere: transport and - every ratchet step are X25519-only, so the whole conversation is - harvest-now-decrypt-later exposed. Hybrid ratchet steps require `kem_pk` on - the roster row, which a legacy invite does not carry. - - From the first hybrid step on, a state snapshot plus a future X25519 break is - not enough: the chain also needs the ML-KEM-768 secret, and the next rotation - replaces it. We do **not** claim full post-quantum forward secrecy, because - epoch 0 is outside that guarantee. - The bootstrap epoch is still the reason state is dropped when a peer's prekey - changes, and an attacker holding both prekey statics can reconstruct epoch 0 - directly (no break needed). A recorded message is not opened by the prekeys - alone while the one-shot Noise session an ML-KEM friend used remains intact. -- *No deniability and no non-repudiation claim.* Chat frames are not signed and - both parties derive the same chain keys, so nothing here would let a third - party decide which of the two authored a chat line. Identity is proven per - Noise session (the 96-byte proof), not per message. -- *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. 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 - history. `/wipe` clears chat, payments and outbox rows but **keeps** the - ratchet state (roster and identity stay), so chat resumes on the same epoch; - `/wipe-all` removes the data dir with it. -- *Length is bucketed; timing is not.* One Noise session per message, and chat - plaintext is padded inside the ratchet ciphertext to a fixed ladder (256 B to - 32 KiB — `docs/PROTOCOL.md`, “Length buckets”), so an observer sees only the - bucket and not the body length. That is all it hides: message timing, retry - cadence, the one-shot-per-message circuits, and the timing of the handshake - are unchanged, and no cover traffic or jitter is generated. The frame header - is not padded: a classical `rat ` frame is 350 bytes at its smallest, while a - hybrid step's 2312-byte ML-KEM header makes its smallest frame 2622 bytes on - the wire. That is a size class, not a message count, and it does not leak the - body length inside the bucket. Non-chat frames (`loc `, `prf `, `inv `, - `rcp `, `tip `, `fil `) are not padded and still reveal their own sizes. -- *The ratchet does not re-open the "no server-side outbox" lock.* The state is - device-local, one row per friend in the encrypted store, and nothing about it - is transmitted. The local retry queue's two accepted consequences (device - seizure, retry cadence) are unchanged. - -## Profile is friend-visible, not a directory - -A signed `prf` frame is shown to people who already have a session with you. Apply only for existing friends. There is still no name lookup, DHT, or public profile server. Anyone who already has a Noise session can see the profile you send them; that is not confidentiality against that friend. - -## Payments are opt-in; spend is a local authority - -Chat does not need a wallet. Payment frames (`inv`, `rcp`, `tip`) are signed -claims over Noise: a signature proves which friend sent the claim, not that -money moved. `verified=1` only after a conjunctive match — one `get_transfers` -row with the same non-empty `txid`, `amount`, and `address`. RPC down, error, or -no exact row → stay `verified=0`. Subaddress reuse is the user’s wallet policy. - -**Default: no spend.** No seed and no spend key on the device. Receive can use -the profile `xmr_addr`, or a view-only wallet (`create_address` / -`get_transfers` only). `/tip` is off (`ONIONWIRE_WALLET_NO_SPEND`, or a -watch-only wallet detected over RPC via `query_key spend_key` → `-29`). - -**Spend is opt-in**, at wallet create or restore, not a hidden default. A -seed-backed spend-capable wallet makes OnionWire a **local spend authority** -for that file: anyone with the wallet passphrase or the wallet-RPC credentials -can move the balance, and `/tip` is a supported way for a chat peer to get paid. -Those credentials are sealed with the store data key (SQLCipher plus a per-row -AEAD), and so is the **wallet-file passphrase**: it is kept in the same sealed -row, because `monero-wallet-rpc` holds a wallet only for the life of one process -and reopening the file needs it. That is a deliberate decision with a real -consequence — **whoever can unlock the store can spend**: the store passphrase -(or its Keystore wrapper) is now sufficient, and there is no second secret -standing between a seized unlocked device and the wallet's balance. Nothing else -changes: `/tip` still refuses on a view-only wallet before any dial, the -spend-authority warning is still unavoidable at create/restore, the passphrase is -never logged, never in an error string and never on a process argv, and `/wipe` -keeps the wallet file and its passphrase exactly as it kept the file before. -The spend-authority warning is unavoidable at that create/restore step. Loopback -binding is not an authorization boundary. Back up the seed; do not leave a -spend-capable wallet on a device you do not trust; a separate hot wallet with a -small balance is the sane spend shape, not savings. - -The app talks to `monero-wallet-rpc` over **loopback HTTP Digest** only -(`--rpc-login` required; open RPC refused). That process may be one the user -already runs, or one the app spawns. Wallet RPC is never dialed over clearnet or -over `.onion` — a remote wallet RPC would move spend authority off the box -through a channel the messenger’s `--password` gate does not cover. - -**The seed-offset passphrase is a second spend secret, and it is not stored.** -An import may be given Monero's optional `seed_offset`: a phrase mixed into the -25 words at restore time, so the same words with a different offset open a -different wallet (plausible deniability). It is typed once, travels only in the -JSON-RPC body (never argv, never logged, never an error string), is never sealed -and never persisted — storing it would defeat the point. It is also not a second -gate on an already-imported wallet: whoever can unlock the store can still spend -the opened file, because the wallet file's own passphrase *is* sealed (previous -paragraph). A wrong offset is silent — the RPC succeeds and the wallet is -simply a different one — so the app cannot warn about it, and after such an -import a later seed backup is the *derived* mnemonic, which opens the wallet -without the offset. - -### Chain source is the user’s choice - -Scan, receipt verification, and spend need a Monero daemon. The user picks one; -the app does not pick a public remote node for them. - -1. **Spawn a local `monerod`** (pruned is the on-device target). Chain traffic - stays on the device. The user accepts disk (tens of GB for a pruned mainnet - node), first-sync time, and — on Android — process kills: the daemon is not - always running. A pruned node is not an archive. Seed restore of deep history - can degrade; once the wallet has scanned, its own cache is the history. - Unsynced or not running is an honest “not ready” / unverified state, not a - fake success. - -2. **An in-process daemon** (Cuprate, behind the `cuprate-daemon` feature, on in - the Linux TUI/release binary; a `--no-default-features` build does not - include it). P2P, consensus and RandomX run in the OnionWire process; nothing is - spawned and nothing leaves the device except the chain P2P traffic itself. - What that changes: there is **no daemon operator** to trust — your own process - is the daemon, so the "operator sees your addresses" question does not exist. - The spend key, the chain, and the messenger are then all on one device. - What it does not change: the **device is now the trust root for chain data**. - Chain state is only as trustworthy as the binary running it, and a - compromised device corrupts the chain view along with everything else. - Honest limits, stated here rather than in a footnote: - - Cuprate is **pre-production**. Its own user book says *"do NOT use cuprated - for any serious purposes"*, and its `monerod` RPC parity is incomplete - (Cuprate issue #278). This is why the source is an opt-in build feature and - a stored user choice, never a default. - - Mainnet is **unvalidated**. The TUI can store a mainnet choice (`F6` 1/2); - every in-process surface still says `testnet only — mainnet is unvalidated`. - Cross-compiled is not device-proven. - - Cuprate's own `arti` feature is off (its Tor stack is `arti-client` 0.44, - which cannot unify with this crate's 0.49), so the in-process daemon's P2P - traffic is **clearnet**: your ISP sees that this device talks to Monero - peers. No Tor is on the chain path — Tor is the messenger's transport here, - not the chain's. - - Inbound P2P is off and the restricted RPC listener is disabled; the - unrestricted RPC binds loopback only, and it is the address the wallet - child dials. `--trusted-daemon` is still never passed. - - The chain database is a separate embedded store (fjall) under the chain - data directory, not the SQLCipher store the messenger writes — different - file, different exposure: it is not encrypted by that store's key. - -3. **A daemon address they supply.** The wallet child points `--daemon-address` - at that host. Trust follows the address: - - **Loopback** — same privacy as (1); the user owns `monerod`. - - **`.onion`** — chain traffic over Tor through a localhost SOCKS5 listener - the app provides for the wallet child (not the messenger’s Arti - `connect()`, and not a C-tor fallback for chat). That listener is the - bundled `arti` **binary** run as a child (`arti proxy -p `) — a - second, separate Tor client with its own state and cache dirs, because - `arti-client` 0.49 exposes no SOCKS listener API. It is TCP loopback only - (`arti proxy -p` binds `127.0.0.1`/`::1`; arti 2.6.0 / `tor-config` 0.49 - have no Unix-socket listen target — arti#1965), and the port is usable by - any local process at the user's privilege level: it is an app-private port, - not an access-controlled one. The app gates the spawn on the unlocked store - and waits ≤20s for the listener to accept before starting the wallet child, - so a dead proxy fails visibly instead of hanging. The SOCKS child stops - with the wallet child. Tor hides the transport. - The daemon operator still sees the wallet’s addresses during sync. The - host is the trust boundary. - - **Clearnet** — only if the user typed it. Not a default, not implied. - The ISP sees Monero-node traffic; the daemon operator sees addresses. Show - that trust shift before using the address. - -Remote daemons are untrusted (`--trusted-daemon` off). Setup, view-only vs -spend, and RPC credentials: [WALLET.md](WALLET.md). - -## The recovery phrase and the private keys are displayable on demand - -Both clients can show the **open** wallet's recovery phrase (`query_key -mnemonic`) and its private view and spend keys (`query_key view_key` / -`spend_key`), from an explicit user action. That is new exposure the threat model -did not previously enumerate: the phone screen — and the Linux TUI window — is -now one of the places a spending secret can be read from. - -- The values come from the wallet file the child has **open**. There is no path - that reads another saved wallet's secret without opening it first, and none - that reads a wallet file directly: the RPC is the only source. -- They are never logged, never written to the store or any other file, and never - placed in an error string; the records that carry them (`WalletKeys`) redact - themselves under `Debug`. They exist in process memory only while a screen - shows them. -- They are shown only from an explicit user action, never on a refresh path. -- What this does **not** stop: a shoulder-surfer, a screen recorder, a - screenshot, or a malicious app with screen-capture permission. Whoever reads - the screen gets the keys; a view-only wallet leaks only the view key - (`spend_key` is `None`), but a spend-capable one leaks everything the file can - spend. -- The spend-authority warning above still applies and is now easier to reach: - the seed that makes a wallet spend-capable can be photographed off the device. - Treat any screen that shows a seed or a private key the way you treat the - wallet file itself. - -## Backup file is the identity - -`/backup` writes the identity and Noise static secrets. Treat the file like `onionwire.db`. Restore overwrites self keys and does **not** rewrite the friends table. - -## Rate limit is availability, not anonymity - -Incoming rendezvous accepts are token-bucket limited (30/60s, burst 10). Excess is dropped without handshake. That is a DoS/availability control. It does not hide that you run an onion, and it is not a traffic-analysis defense. The constants are unchanged. Clients absorb the cost: file senders pace and retry chunks to fit this budget. The accept loop does not distinguish a friend from a flood. - -## Network (UDP / clearnet) - -The application does not open UDP sockets and does not resolve friends via -system DNS. Peer dials are Arti `connect((onion, 80))` only. - -Wallet **RPC** (HTTP Digest to `monero-wallet-rpc`) is loopback TCP only -(numeric `127.0.0.1` / `::1` preferred; `localhost` still does `getaddrinfo`). -That socket is the app talking to the wallet process, not to the chain. - -**Chain** traffic is the wallet child’s connection to a Monero daemon. It is -off unless the user opted into a wallet and chose a chain source: spawned local -`monerod` (loopback), or a daemon address they entered. A `.onion` daemon is -reached through a localhost SOCKS5 proxy used only by that wallet child: the -bundled `arti` binary run as `arti proxy -p `, whose `--proxy` target is -`127.0.0.1` and whose `.onion` name travels inside the SOCKS request (Monero's -SOCKS5 client sends the domain-name form, so no local DNS runs on it). The -messenger's in-process Arti client is never handed to the wallet child. A -clearnet daemon address is an explicit user choice — a clearnet socket they -asked for — not the messenger path and not a hidden default. - -Do not add STUN/ICE/WebRTC, a DHT, SOCKS/C-tor fallback for **peer dials**, or -“direct TCP when the onion is slow.” Those are the Tox-over-Tor leak class. A -SOCKS listener used only by the wallet child to reach a user-chosen `.onion` -daemon is not that class. - -## Peer text is untrusted display data - -Chat bodies and `fil ` names come from a Noise peer, not from the local user. -They are display data, not terminal commands. A friend (or anyone who stole -that session) can put ESC/CSI/OSC, C1 controls, or bidi overrides in a -payload. OnionWire strips those at ingest (so sqlite history is clean) and -again at TUI render (so rows written before this rule stay inert). Filenames -that contain the same characters are rejected, not rewritten. This is a -UI-redressing / terminal-injection boundary, not a confidentiality control: -the peer already knows the plaintext they sent. +Peer onion down → send fails. Fingerprint mismatch vs the pinned key → hard fail, no send. Arti HS experimental: if it cannot publish, OnionWire stops; it does not fall back to C-tor. ## Out of v1 -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”. - +Prosody, XMPP, s2s, MAM, carbons, outbox, multi-device, DHT / name server, sqlcipher. diff --git a/docs/TUI.md b/docs/TUI.md deleted file mode 100644 index bcd8e7a..0000000 --- a/docs/TUI.md +++ /dev/null @@ -1,288 +0,0 @@ -# OnionWire TUI - -Operator map of the Linux terminal UI. Bindings live in `src/tui.rs` -(`function_key_for`, `parse_cmd`, per-screen `match` arms). This is not a -screenshot dump. - -Run `onionwire` in a real terminal. `ONIONWIRE_ASCII` or `NO_COLOR` switches -ASCII chrome. - -## Screens - -`enum Screen` in `src/tui.rs`: - -| Screen | How you get there | What it is | -|---|---|---| -| `Main` | boot | Roster, chat, composer | -| `Share` | `F2` | Invite string (`onionwire:v1:…`) | -| `Paste` | `F3` | Paste a friend's invite | -| `Approve` | paste of unknown `k` | `y` accept / `n` reject | -| `Rotate` | `F4` | Type `ROTATE` to change the onion locator | -| `RotatePrekey` | `F8` | Type `ROTATE` to hard-cut the Noise static | -| `Wipe` | `/wipe` or `/wipe-all` | Type `WIPE` or `WIPEALL` | -| `Profile` | `/profile` | Edit name, bio, optional Monero address | -| `ConfirmKeys` / `Passphrase` | `/backup`, `/restore` | Type `BACKUP`/`RESTORE`, then passphrase | -| `Wallet` | `F6` | Receive QR, balance, transfers | -| `WalletSelect` | `F6` `w` | Saved wallets, pick one or create one | -| `WalletSetup` | `F6` `c` / `i`, or `/wallet create` / `import` | Spend warning, seed, optional seed-offset passphrase, import | -| `WalletSetupConfig` | `F7` | Node & wallet setup: RPC endpoint, chain source, start/stop, live node state | -| `PeerPayments` | `p` on Main (roster or chat) | Peer-scoped `/pay` / `/tip` history | -| `Quit` | `Ctrl-Q` | Type `CLEAR` or `QUIT` | - -Help (`?`) is an overlay, not a screen. `/who` / `F5` is an overlay on Main. - -Function keys that fire from Main are: - -| Key | `FunctionKey` | Action | -|---|---|---| -| `F2` | Share | Invite | -| `F3` | Paste | Paste invite | -| `F4` | Rotate | Onion locator | -| `F5` | Who | Selected friend's profile | -| `F6` | Wallet | Wallet screen | -| `F7` | Setup | Node & wallet setup: RPC endpoint, chain source, start/stop | -| `F8` | RotatePrekey | Prekey hard cut | - -`F7` also fires on the wallet screen, which prints it. There is no `F9` and no -`/settings`: that menu restated F6 and F7. A screen that does not name a -function key does not answer one. Other screens handle their own keys (Esc -back, typed confirms). - -## Main - -Focus starts on the composer. Footer hints (`main_footer_hints`): - -``` -Tab F2 F3 F4 F5 Ctrl-Q F6 F7 ? help -``` - -Pane-specific (`pane_footer_hints`): - -| Pane | Hint | -|---|---| -| Roster | `j k p pay F3 add F6 wallet F7 setup ? help` | -| Chat | `j k g G p pay F6 wallet F7 setup ? help` | -| Composer | `Enter send / commands F6 wallet F7 setup ? help` | - -The status line is drawn from the focused pane's hint, and the compactor drops -tokens from the front until the line fits, so a key that only appears in -`main_footer_hints` never reaches an 80-column terminal. `F6` and `F7` are -therefore named in both, at the tail. `p` is named only on roster and chat: -the composer types the letter. - -| Key | Action | -|---|---| -| `Tab` / `Shift-Tab` | Cycle roster → chat → composer | -| `1` / `2` / `3` | Focus roster / chat / composer when not typing | -| `j` `k` / arrows | Move or scroll the focused pane | -| `g` / `G` | Top / bottom of the focused pane | -| Enter | Send chat, or run a `/command` | -| `Esc` | Close overlay / clear composer | -| `?` | Help (except on Paste, so `?` can be in a payload) | -| `Ctrl-Q` | Quit prompt | - -## Composer commands - -`parse_cmd` (`src/tui.rs`). Unknown `/foo` is sent as chat if it does not match. - -| Command | Effect | -|---|---| -| `/who` | Same as `F5` | -| `/profile` | Profile editor | -| `/pay [memo]` | Invoice (`inv `), one-shot | -| `/tip [memo]` | Transfer + `rcp ` + `tip `, one-shot | -| `/file /path` | File send, 1 MiB, one-shot | -| `/wallet create` | Same as `F6` then `c` | -| `/wallet import` | Same as `F6` then `i` | -| `/backup /path` | Encrypted identity export | -| `/restore /path` | Overwrite self keys | -| `/wipe` | Type `WIPE` — chat/payments/outbox; identity stays | -| `/wipe-all` | Type `WIPEALL` — delete data dir; new person | - -## Share / paste / rotate - -- **F2.** Full invite. `C` copies it (OSC 52). Esc back. -- **F3.** Paste buffer, Enter submits. Unknown `k` → Approve (`y`/`n`). Same `k` - updates locator and prekey only. -- **F4.** Type `ROTATE`. Identity fingerprint unchanged. Online friends get - `loc `; offline friends must F3-paste the new invite. -- **F8.** Type `ROTATE`. Prekey is the Noise static **and** the ratchet bootstrap - seed. Every friend must F3-paste the new invite. Status: - `prekey rotated · friends must F3-paste your new invite`. - -## Wallet (`F6`) - -The wallet, not the node: receive, balance, transfers, and create/import. Chain -and node configuration is `F7` (`Configures the wallet RPC endpoint and the -chain source`), named in the footer so the key is findable from here. - -Footer: - -``` -c create i import r qr w wallets F7 node Esc back ? help -``` - -| Key | Effect | -|---|---| -| `r` or Enter | Toggle receive-address QR | -| `w` | Saved wallets (`WalletSelect`) | -| `c` | Create wallet (`SPEND` then seed once, type `SEEN`) | -| `i` | Import 25-word seed | -| `F7` | Node & wallet setup (`WalletSetupConfig`) | -| Esc | Back to Main | - -The child's state and the chain source are shown here, but they are **set** on -`F7`: the start/stop/probe keys and the `1`/`2`/`3` in-process picker that used -to live on this screen are gone, so there is one place that configures the chain. - -The chain line for an in-process source always carries -`testnet only — mainnet is unvalidated` (`cuprate::TESTNET_ONLY`). The default -binary includes the in-process daemon. A build compiled without that feature -still shows the rebuild message on the chain row, and start fails with that -feature name only on such a build. - -Create/import require the wallet RPC started with `--wallet-dir`. Filename: -`onionwire`. Seed is never collected on the composer. - -## Saved wallets (`F6` then `w`) - -`WalletSelect`. One row per persisted wallet — name, identity prefix, locator -prefix, creation day — plus the selected row's full identity and locator under -the table. `j`/`k` or arrows select, Enter opens the selection, Esc back to -Main. Footer: `Esc back j k select Enter open ? help`. - -The last item is **not** a wallet: `+ create new wallet` starts the same create -flow as `F6` `c`, so an empty list still has a way forward. An unlabelled wallet -(`NULL` in the store) reads `(unlabelled)`; a wallet whose onion service is not -published yet reads `-`; an unknown creation time reads `unknown`. A read that -failed is named on the screen — that is a different state from `no saved wallets -yet`, and the two never share copy. - -Rows are plain display data (`WalletRow`), built by the caller from -`Node::list_wallets`; the render path never reads the store. Selection is by -row index, not by identity key (two records may share one). - -The list is read when the screen opens — from the start screen and from -`F6` `w` — so a wallet created or imported in this session is offered the next -time the screen opens, with no restart. Enter on a wallet row re-points the -app-owned wallet child at that row's `wallet_filename` (`Node::open_wallet`, -a read-modify-write of the sealed record, so the generated RPC creds survive); -a running child is restarted onto the new file, and an idle one picks the -change up on its next start. - -**Start screen.** An install with at least one saved wallet opens on -`WalletSelect`; a fresh install (empty catalogue) opens on the create flow -(`WalletSetup::CreateWarn`), so the first run has no dead empty list. The -stored identity and locator are catalogue columns, not session state: a locator -rotates (`F4`) and identity is the roster key the node already holds, so the -live header keeps reading them from the node. - -## Node & wallet setup (`F7`) - -Footer: `Esc back Enter save Ctrl-T test` (plus the status line's own `? help`). -The compactor drops tokens from the front, and at 80 columns the status line -leaves about 25 cells, so the tail is what the default terminal shows. `Tab` and -`?` are universal; the node's own keys (`ctrl-s`, `ctrl-x`, `ctrl-r`) and -`Ctrl-U` are named in the body, on the row they act on. -Live from Main and from the wallet screen, which prints `F7 node`. Body is -`WalletSetupConfigState`, a snapshot taken when the screen opens — the render -path never reads the store. - -This is the only screen that sets up the chain: the wallet RPC endpoint, and the -node that serves it. - -| Row | Kind | Notes | -|---|---|---| -| `url` | text | the wallet RPC endpoint | -| `login` | text | `user:pass`. Never rendered back: the row reads `hidden · set` or `(none)` | -| `view-only` | toggle | `no_spend`; `/tip` is refused before any dial | -| `chain` | picker | `space` cycles receive-only, local node, remote daemon, in-process | -| `daemon` | text | `host:port`, for the remote daemon | -| `monerod` | text | the binary this box spawns for a local node | -| `datadir` | text | where the chain is stored. Prefilled with the path already in use; an empty one is refused rather than silently defaulted | -| `prune` | toggle | local and in-process sources | -| `network` | picker | in-process source: `space` cycles mainnet (`unvalidated`) and testnet | - -Under them, a `NODE` section: the live `Node::wallet_child_status` line (state, -chain source, `sync h/t` once a daemon reports numbers, the last error) and the -last save/test answer. The live row is the node's answer, never the draft above -it, and it is re-read by `Ctrl-R`. - -`Enter` saves and answers on the status row: `saved · not dialled yet — ctrl-s -starts it, ctrl-t tests the endpoint`, or, when a half is refused, `not saved · -wallet config: · chain source: ` — one line shape either way round, -and the half that did write says so. Both halves are attempted even when one is -refused: a wallet-RPC refusal must not silently drop a chain source the user -just picked. The endpoint's own validator is `Node::wallet_save_config` -(`Wallet::from_config` behind it) — loopback host, login required — and a -rejected form is rejected **before** it is written: nothing in the sealed record -moves and a running wallet is not re-dialled. - -The one exception is an **app-owned** chain source (local `monerod`, in-process -Cuprate) with an empty `url`: the child the app spawns generates its own creds -and picks its own port (`creds()` / `pick_port()`, -`Node::start_wallet_child_with` replaces the stored client after the spawn), so -the `url`/`login` rows describe no endpoint the app dials and an empty pair must -not veto the save. A *typed* endpoint with no login is still refused — that is -the externally run RPC path (`ONIONWIRE_WALLET_RPC`), where the refusal is true. - -`Ctrl-T` dials the endpoint and answers with the sanitized `PingResult` line -(never the password). `Ctrl-U` clears the focused field, which is how a hidden -login gets replaced. - -`Ctrl-S` saves and then starts the wallet child — the daemon and, for a local -source, `monerod` — so the setup screen is also the key that brings the node up. -A start that lands on a wallet file with no stored passphrase moves the app to -the unlock prompt. `Ctrl-X` stops the child. Both go through the same -`Node::start_wallet_child` / `stop_wallet_child` the app's own lifecycle uses. - -The chain row is written only when it was changed. An untouched row leaves the -stored source alone, so opening `F7` to fix a port cannot silently undo an -in-process Cuprate choice or move a chain datadir. Picking a remote daemon says -so in the same frame — `a daemon you do not run sees this wallet's chain -traffic` — because that is the pick that moves chain trust off this box. The -address must parse as `host:port` first. - -The default `onionwire` binary includes the in-process daemon. A build without -that feature says so on the `chain` row, where the choice is made, rather than -offering it and refusing at start: the in-process wording is followed by -`NO_FEATURE_MSG` (clamped to the frame width). The pick is still offered — a -stored in-process source must still be readable — and that rebuild line appears -only on a build that left the feature out. - -Esc is the single exit and wipes the login buffer (`Zeroizing`). - -`/profile`, `/backup`, `/restore`, `/wipe` and `/wipe-all` stay composer -commands. They are named in help (`?`). There is no settings menu that restates -them, and no `F9`. - -## Peer payments (`p` on Main) - -Peer-scoped signed invoices and tips, not the wallet's own transfer list. -`p` opens it from the roster or the chat (the composer types the letter). With -no friend selected the screen says `no friend selected`. `j`/`k` or arrows -select. Esc back. Footer: `Esc back up/down select ? help`. - -## Delivery markers (chat) - -| Row state | Marker | -|---|---| -| delivered | `✓` | -| queued | `◷ queued (try n/8, retry …)` | -| sending | `» sending` | -| failed | `✗ failed: …` | -| inbound | no marker | - -Footer `{n} queued` while anything is outstanding. File transfer and payments -have no queue — outcome is a status note (`invoice sent`, `tip sent`, -`send failed: …`). - -## Size - -Floor **80×24**. Target **120×40**. Frame dumps: - -``` -cargo test --locked --test tui_spec -- --nocapture dump_spec_frames -cargo test --locked --lib f6_and_f7_frames_fit -- --nocapture -cargo test --locked --test tui_select -- --nocapture wallet_select_frame_dumps -``` diff --git a/docs/VERIFY.md b/docs/VERIFY.md deleted file mode 100644 index d2f2c4e..0000000 --- a/docs/VERIFY.md +++ /dev/null @@ -1,264 +0,0 @@ -# Verifying OnionWire - -You were told OnionWire is a honeypot, or a trojan that steals Monero. That is a -claim about a *binary*, and it deserves an answer you can check yourself in ten -minutes rather than an argument you have to take on faith. - -This document is that answer. It is written so that nothing here has to be -believed: every section is a command whose output you read yourself. - -If you only do one thing, do [Check 3](#check-3--10-minutes-rebuild-the-release-and-compare-bytes). -It is the one that actually settles the question, and it is the thing most -projects claiming "the source is public" cannot offer. - ---- - -## What OnionWire can do to your Monero, and what it cannot - -Start with the honest part, because a threat model that only lists the good news -is not a threat model. - -**The wallet is optional and chat never needs it.** OnionWire is a messenger. -With no wallet configured at all there is no seed, no spend key, and no code -path that touches Monero. `docs/WALLET.md` opens with that sentence and it is -literally true. - -**By default it cannot spend.** No seed and no spend key are on the device. -Receive works from a profile address or a view-only wallet. `/tip` is refused -locally, before any network dial, unless spend was explicitly turned on at -wallet create/restore. `ONIONWIRE_WALLET_NO_SPEND=1` forces that refusal. - -**A view-only wallet is detected and cannot be spent.** OnionWire probes -`query_key` with `key_type=spend_key`; monero answers `-29 WATCH_ONLY` -("Cannot retrieve spend key") for a wallet with no spend key, and that answer is -what the app keys off. It cannot extract a spend key that is not in the wallet. - -**The wallet RPC is loopback-only, and it demands a login.** OnionWire refuses -an RPC URL with no credentials and refuses to run against an open RPC. It never -puts wallet RPC on clearnet and never over `.onion`, and it never passes -`--trusted-daemon`. - -**The part that is genuinely exposure — read this one.** In *app-owned wallet* -mode OnionWire spawns `monero-wallet-rpc` itself and therefore knows the RPC -credentials it set. It can read the open wallet's recovery phrase, and it does: -`src/wallet.rs` calls `query_key keytype=mnemonic` to drive the backup screen, -and `query_key spend_key` / `view_key` for the key-display actions. `docs/THREAT_MODEL.md` -says so directly — "the recovery phrase and the private keys are displayable on -demand", and a spend-capable wallet makes OnionWire "a local spend authority for -that file". - -So: **a malicious build of that path could exfiltrate a seed.** That is not -spin, it is the surface. The mitigations are that the seed-read is a user- -initiated action on a wallet you chose to give it, that a funded wallet should -be a separate hot wallet rather than savings, and that if you want OnionWire to -*not* be able to spend, point it at a view-only wallet or run it with no wallet -at all. The threat model already recommends exactly this; it is not a -concession extracted by criticism. - -The rest of this document is about how you check that the binary you downloaded -is the code described above, and not something else. - ---- - -## Check 0 — first, get the file, and know why a download can fail - -Two things break a download from this host, and neither means the release is -missing: - -- **`/releases/latest/download/…` is not served by this Forgejo — it is a 404.** - The GitHub habit fails here. Always pin the tag: - `…/releases/download/v0.7.0/onionwire-x86_64-unknown-linux-gnu`. -- **Cloudflare in front of the Forgejo rejects non-browser User-Agents.** A - script that sends a default library UA gets `HTTP 403` with the body - `error code: 1010` — even with a correct tag and URL. Measured against a real - asset on this host: browser UA → `206`, `curl/8.7.1` → `206`, - `Python-urllib/3.14` → `403`. Set a real `User-Agent` on any scripted fetch, - or use `curl`. - -## Check 1 — 30 seconds: what code is even in the binary - -From a clone, on whatever commit you are interested in: - -```bash -cargo tree --locked -e normal --depth 1 # direct dependencies: 27 of them -cargo tree --locked -e normal | wc -l # ~523 crates in total -``` - -The direct list is the one worth reading. All 27 are known crates: - -``` -argon2 arti-client chacha20poly1305 cuprated ed25519-dalek futures hkdf -hmac md-5 qrcode rand ratatui rpassword rusqlite rustls safelog -serde_json sha2 sha3 snow tokio toml tor-cell tor-hsservice -tor-rtcompat x25519-dalek zeroize -``` - -Two of those deserve naming, because they are the honest answer to "why is there -HTTP in a chat program": - -- **`arti-client`** — Tor, in-process. -- **`cuprated`** — the in-process Monero chain node, pinned to a git revision. - It is a **default feature**, so the release binary ships it. - -That second one is why the graph contains `hyper`, `axum`, `tower-http` and -`http`. Do not take a grep's word for provenance — ask the graph: - -```bash -cargo tree --locked -e normal -i http # axum <- cuprate-rpc-interface <- cuprated -cargo tree --locked -e normal -i reqwest # "did not match any packages" -``` - -`axum` and `hyper` are Cuprate's **JSON-RPC server** — the thing that answers a -wallet client on loopback. That is a server, not a client. `http`/`httparse` -also reach the graph through Arti's directory client, which speaks the Tor -directory protocol inside a Tor circuit. - -What is genuinely absent, and worth confirming yourself: - -- **No HTTP client.** `cargo tree -i reqwest` matches nothing: no `reqwest`, - `ureq`, `isahc` or `curl` anywhere. -- **No telemetry.** No Sentry, analytics or crash-reporting SDK in the graph. - -## Check 2 — 2 minutes: run it with no wallet at all - -```bash -ONIONWIRE_WALLET_NO_SPEND=1 ./onionwire -``` - -Chat, invites, onion rotation and the ratchet all work. Nothing about Monero is -reachable. If your concern is specifically "steals Monero", this is the -configuration where the concern does not apply. - -**The clearnet traffic you will see, stated plainly.** The release binary's -default feature set includes the in-process Cuprate node. If you start a chain -source, that node syncs to the Monero P2P network over clearnet, and you will -see it in `sudo ss -tupn` or `tcpdump`. That is the node doing its job — it is -not the messenger phoning home and it carries no chat data — but it *is* real -outbound traffic, and any "no clearnet at all" claim would be false without -this sentence. - -If you do not want it: - -- leave the chain source unset and unstarted (`F7`), and let a wallet RPC you - run yourself be the only Monero side; or -- build without it: `cargo build --release --no-default-features --features rustls`. - -Honest note on that second option: a `--no-default-features` binary is a -different build and will not match the published hash. Building it yourself is -the trust-minimising move — you just cannot use Check 3 to compare it against a -download. - -## Check 3 — 10 minutes: rebuild the release and compare bytes - -This is the real check. It answers the only objection that survives "the source -is public": *the binary I downloaded might not be that source.* - -```bash -git clone https://forgejo.siriusdevops.com/sirius/onionwire -cd onionwire -git fetch --tags -scripts/verify-reproducible.sh v0.7.0 -``` - -Replace `v0.7.0` with the tag you are checking. You need docker; you do not -need Rust, or the right glibc, or the right distro. The rebuild happens inside -the same builder image, pinned **by digest**, that CI uses, with the source -paths, the target path, and `SOURCE_DATE_EPOCH` all fixed by -`scripts/reproducible-build.sh`. - -It prints one of: - -``` -RESULT: MATCH — the published onionwire-x86_64-unknown-linux-gnu is - byte-for-byte the output of commit built with the documented recipe. -``` - -or `RESULT: MISMATCH` and exits non-zero. - -**What a MATCH proves:** the released binary is exactly what this source -compiles to with this recipe. Auditing the source is therefore sufficient — -which is the property that was missing before, and the one the "just read the -code" argument always quietly assumed. - -**What a MATCH does not prove:** that the source is benign. A project could -publish source that does something bad and a binary that faithfully implements -it. Reproducibility removes the *builder* from your trust set; it does not -remove the *author*. Judging the source is still yours to do — now at least -against a binary you know corresponds to it. - -A mismatch is a finding, not a glitch. The release also carries -`build-info-.txt` recording the commit, epoch, toolchain, builder image -digest and resulting hash, so you can see whether the release was cut from a -different commit or the pinned image moved before you cry foul. - -## Check 4 — verify the release signature - -Every binary and checksum asset is signed with [minisign](https://jedisct1.github.io/minisign/). -The public key lives in the repo at `scripts/onionwire-signing.pub` and is also -published as a release asset — get it from the repo, not from the same download -you are checking, or the signature proves nothing. - -```bash -minisign -Vm onionwire-x86_64-unknown-linux-gnu -p onionwire-signing.pub -``` - -`Signature and comment signature verified` means the file is the one signed by -that key. A `.sha256` file next to a binary only proves the download matches the -release page; a signature proves the artifact is the one the maintainer signed, -even if the release page is later altered. - ---- - -## What is still not proven - -So that nobody over-claims on our behalf: - -- **There is no third-party audit.** `docs/SECURITY_AUDIT.md` is explicitly - in-house. It is a starting point for a reviewer, not a substitute for one. -- **Reproducible builds pin the build, not the intent.** See above. -- **The seed-display capability is by design.** If you consider "an app that can - read my seed" unacceptable regardless of what it does with it, then do not - give OnionWire a spend-capable wallet. Use a view-only wallet or none. That is - a legitimate position and OnionWire supports it without argument. -- **A build you compile yourself is stronger than a verified download.** If you - want the shortest trust chain, `git clone && cargo build --release` beats both - the signature and the reproduction check, because there is no released binary - to trust at all. - -If you find a discrepancy, a way to exfiltrate a seed, or a signature that does -not verify, that is exactly what these checks are for. Report it. - ---- - -## Maintainer: the signing key - -One-time setup, on a machine you control: - -```bash -minisign -G -W -p scripts/onionwire-signing.pub -s onionwire-signing.key -``` - -`-W` means the secret key is not encrypted: CI cannot answer a password prompt, -and a passphrase stored beside the key in the same secret store protects nothing. -Then: - -1. Commit `scripts/onionwire-signing.pub`. -2. Store the **contents** of `onionwire-signing.key` as the Forgejo Actions - secret `MINISIGN_SECRET_KEY` (Settings → Actions → Secrets). -3. Delete `onionwire-signing.key` from your machine, or keep it somewhere - genuinely offline. Anyone holding it can sign a release. - -`scripts/sign-release.sh` fails closed: with no key, or if a signature it just -produced does not verify against the committed public key, it exits non-zero and -the release is not published. That is deliberate — an unsigned release is worse -than a missing one, because it looks the same as a signed one to anyone who is -not checking. - -## Maintainer: the builder image digest - -`BUILDER_IMAGE` is pinned by digest in three files that must agree: -`.forgejo/workflows/release.yml` (`RUST_IMAGE`), `scripts/verify-reproducible.sh`, -and `scripts/build-release-local.sh`. When you bump it, the released hashes are -expected to change — that is a toolchain change, not a compromise. Bump all three -in one commit so a verifier never rebuilds with a different toolchain than CI -shipped. \ No newline at end of file diff --git a/docs/WALLET.md b/docs/WALLET.md deleted file mode 100644 index 3f6fdb4..0000000 --- a/docs/WALLET.md +++ /dev/null @@ -1,452 +0,0 @@ -# OnionWire + monero-wallet-rpc - -Chat does not require a wallet. A wallet is opt-in. - -**Default: no spend.** No seed and no spend key on the device. Receive uses the -profile `xmr_addr`, or a view-only wallet for invoices (`create_address`) and -receipt checks (`get_transfers`). `/tip` is off. - -**Spend is opt-in** at wallet create or restore (seed-backed). That makes -OnionWire a local spend authority for that wallet file — see the spend-authority -warning below. Threat model: [THREAT_MODEL.md](THREAT_MODEL.md). TUI keys: -[TUI.md](TUI.md). - -The app talks to `monero-wallet-rpc` over **loopback HTTP Digest only**, and it -can own that process itself: - -- hand out a receive subaddress for `/pay` invoices (`create_address`), -- read incoming transfers to verify a peer's receipt (`get_transfers`), -- and — only if you opted into spend — `/tip` (`transfer`). - -**Prefer view-only until you actually want `/tip`.** - -Wallet RPC is never on clearnet and never over `.onion`. Chain traffic is off -unless you opted into a wallet and chose a source. A remote daemon is untrusted -(`--trusted-daemon` is never passed). - -## Ports (do not swap these) - -| Port | What it is | -|---|---| -| **18081** | App-owned **local** daemon unrestricted RPC (`DEFAULT_MONEROD_RPC_PORT` in `src/wallet_child.rs`). Spawned `monerod` and in-process Cuprate both bind `127.0.0.1:18081`. The wallet child dials that. | -| **18089** | A daemon's *restricted*-RPC port. It belongs only in examples of a **remote** `--daemon-address` you type. Not the app-owned local port. | -| random loopback | App-owned `monero-wallet-rpc` bind (`127.0.0.1:0`, then the port is kept). | - -A doc or config that puts the local child on 18089 is wrong. - -## The app-owned wallet child - -`src/wallet_child.rs` owns the child pair instead of asking you to export an -env var: - -- **`monero-wallet-rpc`** is spawned with `--rpc-bind-ip 127.0.0.1`, a **random - free loopback port**, a generated `--rpc-login` (`user:pass`, random - `[a-z0-9]`), and `--wallet-dir $ONIONWIRE_HOME/wallet`. A bare name is the - executable of that name next to the OnionWire binary, when that file is - executable; otherwise `PATH`. An absolute path is spawned as given (Android's - bundled library, or a path the operator set). No `--wallet-file` and - no `--password`: argv is world-readable to the same user through `ps`, so the - wallet is opened **over RPC** (`open_wallet`) once the child is up, and never - named on the command line. -- **`monerod`** is spawned when the chain source is *local*: - `--non-interactive --data-dir --rpc-bind-ip 127.0.0.1 --rpc-bind-port - 18081`. The wallet child dials `127.0.0.1:18081`. -- **Start waits up to 5s for `127.0.0.1:18081` to accept before spawning - `monero-wallet-rpc`, and up to 5s for that child's own port before - `open_wallet`.** A closed port fails the start. A connect refusal while state is - still `connecting` is not shown as an error. -- **`arti`** is spawned as a SOCKS child only when the chain source is a - `.onion` daemon: `arti proxy -p `. -- `--trusted-daemon` is never passed. -- Wallet dir `0700`, wallet file `0600`. -- The child is watched by polling (`try_wait`). `stop()` kills children on - shutdown. Nothing promises “always running”, and Android will not. - -Generated `user:pass` is sealed with the store data key in the SQLCipher -`wallet_child` table. It never appears in `ONIONWIRE_WALLET_RPC`. - -`monero-wallet-rpc` starts with **no wallet open** and keeps one open only for -the life of its process, so a restart (app relaunch, Lock/unlock, a wallet -re-point) would otherwise answer every read with `-13 No wallet file` while the -file sits on disk. After the child is up the app therefore issues `open_wallet` -for the configured catalogue row. - -That needs the passphrase, and the app **keeps it**: the passphrase you type at -create/import (or the one you enter once for a wallet that predates this) is -sealed with the store data key in the SQLCipher `wallet_config` row, beside the -RPC creds, under its own AAD. It is never logged, never put in an error string, -and never on a process argv. The consequence is deliberate and stated in -[THREAT_MODEL.md](THREAT_MODEL.md): **the store passphrase is now sufficient to -spend** — an attacker who has it can open the wallet file and move the balance, -without a second secret. The spend-authority warning at create/restore is -unchanged and is not made weaker by this. - -Wipe semantics: `/wipe` keeps the wallet file and its passphrase (the file -survives `/wipe` today); `/wipe-all` removes the data dir, as before. - -If the stored passphrase does not open the configured file — a wallet the -catalogue holds but whose passphrase changed, or one created on another install — -the app reports it against that file and does **not** overwrite the stored one. -The child is stopped rather than left answering `-13`, and the status reports -`needs passphrase`; open the file once with its real passphrase -(`open_wallet_with_passphrase`, or the TUI/Android prompt) and it is remembered. - -Nothing spawns the child at boot. `Node::start_wallet_child` is the only start -path. The desktop TUI drives it from `F7` (`Ctrl-S` / `Ctrl-X`), which is also -the screen that picks the chain source: - -| Key | Effect | -|---|---| -| `Ctrl-S` | Save the form, then start the child and probe it once. A child whose wallet file needs a passphrase opens the passphrase prompt instead of leaving every read at `-13`. | -| `Ctrl-X` | Stop it (idempotent). | -| `Ctrl-R` | Re-read the live node line (`off` / `connecting` / `syncing` / `ready` / `exited`). | -| `Enter` | Save the endpoint and chain source without dialling or starting anything. | -| `chain` row + `space` | Receive-only / local `monerod` / remote daemon / in-process Cuprate. In a build without `cuprate-daemon` the row carries the `rebuild with --features cuprate-daemon` wording; the pick is still offered. | -| `network` row + `space` | In-process network: mainnet (unvalidated) or testnet. | - -State shown: `off` / `connecting` / `syncing` / `ready` / `exited`, plus a -chain-source label, plus `wallet locked` while a catalogue wallet is configured -but not open in the child's RPC. `ready` is never reported for a child that has -died. A live child is not a usable wallet: `wallet_status()` carries -`wallet_open` and `needs_passphrase` so a client can tell "the wallet is open" -from "the child is up and waiting for a passphrase". - -Once a probe has read the daemon, the line can include `sync /` -— the **daemon's** height and the tip it is syncing towards (wallet RPC -`get_info`, or the local daemon's `get_info` when wallet RPC does not answer). -`sync 0/0` or no segment means **unknown**, not caught up. - -`start` is idempotent: a live child is reported, not respawned. A start that -fails part way is **all or nothing**: whatever that call spawned — the in-process -daemon, a `monerod`, the SOCKS child, the wallet RPC — is stopped before the -error is handed back (`WalletChild::start_with_creds`), because the caller -receives the error rather than the client, so a daemon left running would have no -owner and no handle, and would hold `18081` against the next start. The same -contract is asserted one level up -(`node::tests::a_missing_binary_fails_the_start_and_leaves_no_child`), and what a -retry reuses is the chain **datadir** on disk, never a process that outlived its -owner. - -A save on an app-owned source needs no `url`/`login`: the child the app spawns -generates its own RPC creds and picks its own port, and -`Node::start_wallet_child_with` replaces the stored client after the spawn. A -typed endpoint with no login is still refused (`Wallet::from_config`), and the -screen reports both halves of a save on one line. See `docs/TUI.md`. - -## Chain source - -You pick one. OnionWire does not pick a public remote node for you. - -``` -ChainSource::None receive-only; no child, no daemon -ChainSource::Local { monerod_bin, datadir } spawn monerod on this box (port 18081) -ChainSource::InProcessCuprate { datadir, … } daemon inside this app (port 18081) -ChainSource::Remote { host, port } a daemon address you typed -``` - -1. **Local `monerod`.** Chain traffic stays on the box. -2. **In-process Cuprate.** No `monerod` binary. Wallet child still dials - `127.0.0.1:18081`. See below. -3. **A daemon address you supply** — becomes `--daemon-address` on the wallet - child. Loopback if you already run `monerod`. `.onion` if you want chain - traffic over Tor. Clearnet only if you type it — never a default. Restricted - RPC on `18089` is a common remote example, but you supply the port. - -Settings live in the sealed `wallet_child` record (`ChildConfig`: `source`, -`wallet_rpc_bin`, `arti_bin`, `wallet_filename`). Core: -`Node::wallet_child_config` / `set_wallet_child_config`, then -`start_wallet_child` / `stop_wallet_child` / `wallet_child_status` / -`wallet_child_refresh`. - -### The in-process chain daemon (`cuprate-daemon`) - -``` -cargo build --release --bin onionwire -``` - -That is the Linux TUI/release build. It includes the in-process daemon. -`--features cuprate-daemon` still selects it; that flag is no longer required -for the TUI. A build with `--no-default-features` does not include the daemon. - -- **On in the Linux TUI default.** `cuprated` is pre-1.0, not on crates.io - (placeholder crates), git-pinned. Without the feature, a stored in-process - source can still be read back, but start fails with - `this build has no in-process chain daemon — rebuild with --features cuprate-daemon`. -- **Pre-production.** Cuprate's own user book says do not use `cuprated` for - serious purposes. RPC parity is incomplete (`docs/cuprate-launch-spike.md`). -- **Mainnet is unvalidated.** The TUI stores the in-process network on `F7`'s - `network` row (mainnet or testnet) and the store's shape on its `prune` row. - Every in-process surface still prints `testnet only — mainnet is unvalidated` - (`cuprate::TESTNET_ONLY`). - Cross-compiled is not device-proven. Pointing a mainnet wallet at it is not - something this build claims to do. -- **No Tor on the chain path.** Cuprate's `arti` feature is off (arti-client - 0.44 vs this crate's 0.49). P2P is **clearnet**. OnionWire's Arti is the - messenger only. -- **Inbound P2P off**, restricted RPC listener disabled. Unrestricted RPC is - loopback 18081. `--trusted-daemon` still never passed. -- Chain lives under `$ONIONWIRE_HOME/chain/…` (split dirs so pruned mainnet - cannot mix with full). Database is **fjall**, not SQLCipher. -- Not a child process: dropping the node shuts it down. `x` / `stop_wallet_child` - asks it to stop with the wallet child. - -### Chain traffic over Tor (`.onion` daemons) - -A `.onion` daemon cannot be dialled directly. The wallet child is an external -C++ binary, so it reaches Tor through a SOCKS proxy the app provides: - -- Bundled `arti` binary: `arti proxy -p `. A second - Tor client, not the messenger's in-process one. No C-tor. -- Listener is TCP loopback only. Any local process at your privilege can use it. -- Wallet child: `--proxy socks5://127.0.0.1:` and - `--daemon-address :`. The `socks5://` scheme is required (Monero - defaults to SOCKS4a for a bare `host:port`). No local DNS on the onion target. -- Own state/cache: `$ONIONWIRE_HOME/wallet/arti-socks/{state,cache}`. -- Wait up to 20s for the SOCKS listener before spawning the wallet child. -- SOCKS child stops with the wallet child. - -**Tor hides the transport, not the host.** The daemon operator still sees the -wallet's addresses during sync. - -### Readiness — receipt verification needs a synced wallet - -`chain_ready()` compares the wallet's **own scanned height** with the **chain -tip**. Both halves must answer: - -1. the wallet RPC's `get_height` reports `height > 0`. That is - `monero-wallet-rpc`'s own method; `get_info` does **not** exist there — it - answers `-32601 Method not found`, so readiness never asks for it. -2. the chain daemon reports a tip, and the wallet is at it or within **2 - blocks**. The tip moves every ~2 minutes and the two numbers are two reads, - not one snapshot, so a strict equality flaps; two blocks of slack does not - hide a real lag. - -The tip comes from `daemon_get_height` (`GET /get_height` — one spelling that -works on monerod and Cuprate) against `ChildConfig::daemon_probe_addr()`: - -- local `monerod` / in-process Cuprate → `127.0.0.1:18081`; -- a **clearnet** remote daemon the user typed → that host. The wallet child - already dials it, so one `get_height` is the same exposure, not a new path; -- a **`.onion`** daemon → **not dialled** without the SOCKS child: a direct dial - would resolve the name on clearnet DNS and leak. Readiness stays false - (height-only); the status row reads syncing. A documented limit, not a bug; -- receive-only, or an externally run wallet RPC with no chain source → nothing - to ask, so not ready. - -Unknown is **not caught up**. A daemon that does not answer, a wallet with no -file open (`-13 No wallet file`), and a missing height all read *not ready*, -never a silent pass. "No wallet open" is a state, not an error banner. - -Until then, **receipt verification stays `verified=0`**. An unsynced wallet -cannot see the chain. That is an honest limit, not a UI bug. - -Loopback management calls (`get_address`, `query_key`, create/import) get 5s. -Calls that wait on the chain (`get_transfers`, `transfer`) get 60s -(`CHAIN_RPC_TIMEOUT`). Readiness is not a chain wait: it is one local -`get_height` plus one bounded daemon probe. - -## Env vars (migration path) - -| Variable | Meaning | -|---|---| -| `ONIONWIRE_WALLET_RPC` | `http://[user:pass@]host[:port][/path]` for an **externally run** `monero-wallet-rpc`. Unset → no wallet; chat still works; `/pay` falls back to profile `xmr_addr`. The app-owned child does not use this. | -| `ONIONWIRE_WALLET_RPC_LOGIN` | `user:pass` when the URL has no userinfo. | -| `ONIONWIRE_WALLET_NO_SPEND` | `1` / `true` / `yes` / `on` → `/tip` refused locally before any RPC dial. | - -Boot precedence: **stored config → env → disabled**. Stored config that cannot -be used (non-loopback, `.onion`, missing login) is reported and falls back to -env rather than dialling the bad endpoint. - -`Store::save_wallet_config` / `Node::wallet_save_config` exist, and the `F7` -screen (`WalletSetupConfig`) writes them: the endpoint, its login, the chain -source, and (for a local node) its datadir and network. It is also the only -screen that starts and stops the child (`Ctrl-S` / `Ctrl-X`). `F6` and `F9` -show state, the env vars are the headless path. The not-configured refusal says -`wallet not configured — open F7 to set it up, or set ONIONWIRE_WALLET_RPC` -(`src/wallet.rs`), and that key is real. - -A save validated by `Node::wallet_save_config` (loopback host, login required) -re-points the wallet without a restart; a rejected form writes nothing. - -`/pay` and `/tip` run `wallet_readiness` before send: - -1. not configured → the F7-worded message above -2. `/tip` on view-only / `ONIONWIRE_WALLET_NO_SPEND` → refused **before any dial** -3. configured but not connected → `wallet not connected — check endpoint, login, daemon` -4. otherwise ready (`/pay` is fine on view-only) - -## Android / SDK - -UniFFI: `set_chain_source(ChainConfig)` / `chain_source()`, -`start_wallet_child()`, `stop_wallet_child()`, `wallet_status()` (cached read: -no dial, for first paint) and `wallet_child_refresh()` (a live probe of the -same record — it dials the loopback wallet RPC and asks the configured daemon -for its tip (the wallet's `get_height` is the other half), so poll it on the -order of seconds). -Pass absolute paths for `wallet_rpc_bin` / `arti_bin` (`nativeLibraryDir`); the -core never resolves a binary the caller named explicitly. - -`ChainChoice.InProcessCuprate` is the in-process variant. Empty -`monerod_datadir` resolves to `$ONIONWIRE_HOME/chain`. `start_wallet_child()` -launches the node *and* the wallet child. `wallet_status()` carries -`chain_in_process`, `node_available`, and `node_state`. - -Monero ships **no Android binaries**. Any vendored blob's provenance doc must -say so. Cross-compiled is not device-proven. See `android/MONERO_BINARIES.md`. - -### The wallet catalogue, and which wallet is open - -`wallets()` lists every wallet this install remembers (oldest first), each row -carrying the `wallet_filename` the child opens, its label, the owning identity -pubkey as hex, and the locator. `active_wallet_filename()` returns the file the -child is **currently pointed at** (or `None` on a fresh install), so a picker can -mark the open row. `open_wallet(filename)` switches to a catalogue row: a -running child is stopped and restarted onto the new file, an idle one is only -re-pointed (the change applies at the next `start_wallet_child`), and a file the -catalogue does not hold is refused — the catalogue is the only directory this app -keeps wallets in. The restarted child then opens that file with the stored -passphrase; when this install has none for it, the call still succeeds and the -status says `needs_passphrase` — that is what the prompt is for, and -`open_wallet_with_passphrase(filename, passphrase)` is the API behind it. It -stores the passphrase only after a live daemon has opened the file with it. - -## Secrets belong to the open wallet - -The seed (`wallet_seed()`, `query_key mnemonic`) and the private keys -(`wallet_keys()` → `query_key view_key` / `query_key spend_key`) are answered by -the wallet file the child has **open**, so they always belong to the row -`active_wallet_filename()` names. There is deliberately no accessor that reads -another saved wallet's seed or keys without opening it: show a backups screen, -then `open_wallet(...)` the row — the UI must say *which* wallet it is showing. -`WalletKeys.spend_key` is `None` for a view-only wallet (the RPC's `-29`), which -is an answer, not an error. - -Both values are spend secrets. They are displayable on demand in the TUI and in -the Android app, are never logged, never written to the store or to disk, and -never put into an error string (the core's `WalletKeys` `Debug` redacts them). -The exposure this creates is enumerated in -[THREAT_MODEL.md](THREAT_MODEL.md), "The recovery phrase and the private keys -are displayable on demand". - -## Create vs import - -`/wallet create` (`F6` then `c`) → `create_wallet`, then seed **once** -(`query_key mnemonic`). Type `SPEND`, set a passphrase, write the seed, type -`SEEN`. The passphrase you set is sealed in the store (above), so the wallet -reopens on the next start without asking for it again. - -`/wallet import` (`F6` then `i`) → `restore_deterministic_wallet` from a -25-word seed. Do not put the seed on the composer. The import also takes an -optional **seed-offset passphrase** — a second spend secret mixed into the words -at restore time, not the wallet-file passphrase. It is never sealed, never -stored, never logged and never on an argv: blank `Enter` skips it, and a wrong -offset is *not* an error — the RPC succeeds and opens a different wallet. After -an import that used one, `query_key mnemonic` is the mnemonic of the keys the -wallet actually holds (the derived seed), so a later seed backup restores this -wallet **without** the offset; the original words plus the offset are the other -backup, and the app keeps neither. - -RPC must be started with `--wallet-dir` (not only `--wallet-file`). A created -wallet gets its own file name (`onionwire-1`, `onionwire-2`, …): `wallet_filename` -is UNIQUE in the catalogue, so a second create must not reuse the first file. - -## Recommended topology (view-only) - -``` - wallet host (this machine) - ┌──────────────────────────────────────────────────────────────┐ - │ monero-wallet-rpc --rpc-bind-ip 127.0.0.1 --rpc-login u:p │ - │ ▲ HTTP Digest, loopback only │ - │ │ │ - │ OnionWire (ONIONWIRE_WALLET_NO_SPEND=1) ── /pay, receipts │ - │ └── /tip refused locally │ - └──────────────────────────────────────────────────────────────┘ -``` - -Loopback is the only address OnionWire will dial for **wallet RPC**. - -## Create a view-only wallet - -Keep the seed / spend key on a machine that is **not** running OnionWire. - -```bash -monero-wallet-cli --generate-from-view-key "$HOME/.onionwire-viewonly" \ - --daemon-address "$YOUR_MONEROD:18089" --restore-height "$BIRTH_HEIGHT" -``` - -`18089` here is the **remote** daemon's restricted RPC, an address you type — -not the app-owned 18081. - -```bash -monero-wallet-rpc --wallet-file "$HOME/.onionwire-viewonly" \ - --rpc-bind-ip 127.0.0.1 --rpc-bind-port 18083 --rpc-login onionwire:secret \ - --daemon-address "$YOUR_MONEROD:18089" - -export ONIONWIRE_WALLET_RPC=http://127.0.0.1:18083 -export ONIONWIRE_WALLET_RPC_LOGIN=onionwire:secret -export ONIONWIRE_WALLET_NO_SPEND=1 -``` - -Restore from a height at or before the first incoming transaction. - -## What works, what does not - -| Feature | View-only | Spend-capable | -|---|---|---| -| `/pay ` invoice subaddress (`create_address`) | works | works | -| Receipt verification (`get_transfers`) | works, if daemon is synced | works, if daemon is synced | -| Profile `xmr_addr` fallback when RPC is down | works | works | -| `/tip ` (`transfer`) | **cannot work** | works | -| OnionWire copies your spend key into its own process | never | never (it stays in the wallet file / RPC) | -| Show the backup (seed via `query_key mnemonic`) | **no seed to show** (the RPC answers `-29`) | works | -| Show the private keys (`wallet_keys`) | view key only, `spend_key` is `None` | view + spend key | - -`ONIONWIRE_WALLET_NO_SPEND=1` refuses `/tip` before RPC with: - -``` -wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt verification still work -``` - -View-only detection after a failed `transfer`: `query_key` `spend_key` → `-29` -watch-only. The spend key is discarded immediately. OnionWire never probes a -healthy wallet for this. - -## Why loopback still needs authentication - -`--rpc-bind-ip 127.0.0.1` keeps the port off the network; it does **not** keep -it away from other processes on the same machine. - -OnionWire refuses an RPC that answers HTTP 200 without a Digest challenge, and -refuses URLs without credentials. Prefer `ONIONWIRE_WALLET_RPC_LOGIN` over -userinfo in the URL. Do not log the password. - -`monero-wallet-rpc` mints its Digest nonce **per TCP connection** (epee's -`http_custom_handler` owns the auth state), so the challenge and the -authenticated retry have to ride the same socket — a retry on a fresh connection -is refused with 401 no matter how correct the login is. OnionWire does exactly -that. A `wallet RPC HTTP HTTP/1.1 401 Unauthorized` status therefore means one -thing: the login does not match the child's `--rpc-login`. Regenerate the child -(and its sealed creds) rather than retrying. - -## The spend-authority warning - -An OnionWire instance pointed at a **spend-capable** `monero-wallet-rpc` is a -local spend authority: any process that can read the RPC credentials (env var, -`/proc//environ`, shell history, a stored URL) can spend the wallet's -balance, and `/tip` gives a chat peer a supported path to ask for a transfer. - -That is why view-only plus `ONIONWIRE_WALLET_NO_SPEND=1` is the recommended -default. If you want tips, use a **separate hot wallet with a small balance**, -not your savings wallet. - -## Payments are one-shot - -`/pay` and `/tip` fail when the peer onion is down. There is no queued invoice. -File transfer is the same rule. - -## References - -- Monero Wallet RPC: -- `WALLET_RPC_ERROR_CODE_WATCH_ONLY = -29` in the Monero tree -- Spike history (not operator docs): [cuprate-launch-spike.md](cuprate-launch-spike.md), - [arti-socks-feasibility.md](arti-socks-feasibility.md) diff --git a/docs/arti-socks-feasibility.md b/docs/arti-socks-feasibility.md deleted file mode 100644 index b7d05b8..0000000 --- a/docs/arti-socks-feasibility.md +++ /dev/null @@ -1,103 +0,0 @@ -# Arti SOCKS Feasibility Report - -**Status:** shipped as Option A (bundled `arti` binary as SOCKS child for -`.onion` daemons). Living doc: [WALLET.md](WALLET.md). Verdict below is the -historical finding; do not rewrite it. - -**Date:** 2026-09-13 -**Scope:** Can OnionWire's in-process `arti-client` 0.46.0 expose a SOCKS5 listener for an external process (monero-wallet-rpc child) to route its daemon traffic through Tor? -**Verdict:** **Not directly.** The `arti-client` library does not expose a configurable SOCKS proxy listener. See options below. - ---- - -## What the docs say - -### `arti-client` is an outbound client library, not a SOCKS server - -From [docs.rs/arti-client/0.46.0](https://docs.rs/arti-client/0.46.0/arti_client/): - -- The crate's public API surface is `TorClient::connect()`, `resolve()`, `bootstrap()`, etc. — all **outbound** connection primitives. -- There is no public `socks_port()`, `set_socks_listener()`, or equivalent configuration method on `TorClient` or `TorClientConfigBuilder`. -- `TorClientConfigBuilder` exposes: `storage`, `tor_network`, `channel`, `bridges`, `preemptive_circuits`, `circuit_timing`, `address_filter`, `stream_timeouts`, `vanguards`, `system`, `path_rules`, `download_schedule`, `directory_tolerance`. **No SOCKS listener configuration.** -- The crate's own overview explicitly says: *"If you are trying to glue Arti to some other programming language, right now your best bet is probably to spawn the [`arti` CLI](https://tpo.pages.torproject.net/core/doc/rust/arti/index.html) SOCKS proxy, as a subprocess."* - -This is a deliberate architectural statement: the library does not expose a SOCKS listener for external consumers. - -### The SOCKS functionality lives in the `arti` binary, not the library - -- The `arti` CLI (separate crate from `arti-client`) has a `proxy` subcommand: `arti proxy -l debug -p 9150`. This opens a SOCKS5 listener on the given port. -- `tor-socksproto` (a lower-level arti crate) implements the SOCKS protocol encode/decode, and the docs say it's *"only used to provide a SOCKS proxy over the Tor network"* — but it's a protocol implementation, not a ready-made listener you can slot into `arti-client`. -- `tor-hsrproxy` is for the **reverse** direction (onion service → local ports), not relevant here. - -### The one hint that SOCKS exists internally - -The `TorClient` docs say: *"This ObjectID for this object can be used as the target of a SOCKS stream."* This confirms SOCKS routing exists inside the arti RPC system, but it's an **internal** detail, not a public listener API. There's no method to expose "here's a port, connect external processes to it." - -### `isolated_client` is relevant but not a SOCKS solution - -`TorClient::isolated_client()` creates a new handle that shares state/config but doesn't share circuits. This is useful if you want separate isolation domains, but it doesn't give you a SOCKS listener. - ---- - -## Why this matters for OnionWire - -The payment plan's Backend 2 (local wallet child + remote onion daemon) needs the wallet child (`monero-wallet-rpc`) to reach a `.onion` daemon through a SOCKS5 proxy. The wallet child speaks plain SOCKS5 to `127.0.0.1:` via `--proxy`. It does not use Arti's `connect()` — it's an external binary that only knows SOCKS5. - -OnionWire already runs `arti-client` in-process for the messenger. The question was: can we configure that same Arti instance to also listen on a SOCKS port, so the wallet child just points `--proxy 127.0.0.1:` and everything routes through the same Tor client? - -**Answer: no, not through `arti-client` 0.46.0's public API.** - ---- - -## Options - -### Option A: Bundle the `arti` binary as a SOCKS subprocess - -Run the `arti` CLI (not `arti-client`) as a child process with `arti proxy -p `. The wallet child points `--proxy 127.0.0.1:` at it. The messenger continues using in-process `arti-client`. - -**Pros:** Uses the real arti SOCKS proxy. No custom protocol code. -**Cons:** Now you have two Tor clients — in-process `arti-client` for the messenger, and a subprocess `arti` for SOCKS. They don't share state, circuits, or configuration unless you point them at the same state dir (which may or may not be safe/supported). More moving parts. On Android, this is a third binary to bundle (messenger uses in-process arti-client, SOCKS uses arti binary, wallet uses monero-wallet-rpc). - -### Option B: Implement a SOCKS5 listener that forwards to in-process `arti-client::connect()` - -Use `tor-socksproto` (or another SOCKS5 server crate) to accept SOCKS5 connections on a localhost port, parse the target address, and then use the in-process `arti-client`'s `connect()` to open the actual Tor stream, bridging the two byte streams. - -**Pros:** One Tor client (in-process arti-client). No second binary. The wallet child talks SOCKS5 to localhost, your code translates that to `arti-client::connect()` calls. -**Cons:** You're writing a SOCKS5 server. `tor-socksproto` gives you the protocol encode/decode, but you still need the accept-loop, the byte bridging, the stream lifecycle management, error handling, DNS-leak precautions (SOCKS4a vs SOCKS5 remote DNS), etc. This is real code. The docs note `tor-socksproto` *"does no networking code: it only implements the server (proxy) side of the SOCKS handshake by handling a series of bytes"* — so the networking glue is on you. Also, routing all the wallet child's daemon traffic through your own SOCKS bridge means you're responsible for circuit isolation, timeout handling, and not leaking the target address via local DNS resolution. - -### Option C: Run a separate Tor daemon (C tor or arti binary) for SOCKS - -Run a dedicated Tor SOCKS proxy (system tor, or bundled arti binary) listening on localhost. Wallet child points at it. Messenger uses in-process arti-client. Two Tor clients, but the SOCKS one is a known quantity. - -**Pros:** Well-understood. The wallet child just works. -**Cons:** Another binary on Android. Two Tor clients again. - -### Option D: Skip the SOCKS indirection — make the wallet child use Arti directly - -This isn't viable. `monero-wallet-rpc` is a C++ binary. It speaks plain TCP or SOCKS5. It does not link arti-client. You cannot make it use in-process Arti without a SOCKS shim. - ---- - -## What I'd recommend - -**For the feasibility proof:** try Option B first (a small SOCKS5 listener using `tor-socksproto` + `arti-client::connect()`), because if it works, it's the cleanest path — one Tor client, no second binary, and it directly answers the question "can the in-process Arti serve the wallet child's SOCKS needs?" - -If Option B turns out to be more code than it's worth, fall back to Option A (bundle the `arti` binary as a SOCKS subprocess) — it's the known quantity, and the arti project itself points to this as the interop path. - -Either way, the answer to "does arti-client 0.46.0 expose a SOCKS port we can use" is **no** — you have to build or bundle the SOCKS layer yourself. - ---- - -## Things to verify during the proof - -1. **`tor-socksproto` 0.46.0 API surface** — can you actually build a working SOCKS5 server with it in reasonable code, or is it too low-level? The crate docs say it handles the handshake bytes but no networking — confirm what's actually involved. -2. **DNS leak handling** — SOCKS5 has a remote-DNS flag. The wallet child's daemon connection targets a `.onion` address, which is already a Tor address (not a DNS name), but verify the SOCKS handshake and the `arti-client::connect()` call handle it correctly and don't do local DNS on the target. -3. **Two-Tor-client question for Option A** — if you go with bundled `arti` binary for SOCKS, confirm whether sharing the state dir with the in-process `arti-client` is safe or whether they need separate state. -4. **Android thread/runtime constraints** — a SOCKS accept-loop bridging to `arti-client::connect()` runs in the app's Tokio runtime. Confirm it doesn't block or interfere with the messenger's Arti usage. -5. **`monero-wallet-rpc` `--proxy` behavior** — confirm the wallet child actually honors `--proxy` for its daemon connection and speaks SOCKS5 (not just HTTP proxy or something else). - ---- - -## Bottom line - -`arti-client` 0.46.0 is an outbound Tor client library. It does **not** expose a SOCKS5 listener. The SOCKS proxy is a feature of the `arti` binary, not the library. For the wallet child to route its daemon traffic through the app's Tor, you either build a SOCKS shim on top of in-process `arti-client` (Option B), or you run a separate SOCKS-capable Tor process (Option A/C). The cleanest architectural fit is Option B if `tor-socksproto` is usable for it; the safest fallback is Option A. diff --git a/docs/cuprate-android-spike.md b/docs/cuprate-android-spike.md deleted file mode 100644 index 0c55fc3..0000000 --- a/docs/cuprate-android-spike.md +++ /dev/null @@ -1,194 +0,0 @@ -# Cuprate on Android aarch64 — cross-compile spike - -**Status:** shipped as history. In-process Cuprate is an opt-in `cuprate-daemon` -feature; mainnet remains unvalidated. Living doc: [WALLET.md](WALLET.md). Do not -read this spike as current operator procedure. - -**Question (kanban `t_8293d96d`):** do the native dependencies of the in-process -Cuprate daemon (`randomx-rs`, `fjall`, sqlite, the C++ RandomX build) cross-compile -for the Android NDK target `aarch64-linux-android`? If they do not, §7a's Phase 1 -("Cuprate in-process instead of a `monerod` subprocess" on Android) keeps only its -desktop half and the mobile SDK story loses the point of it. - -**Verdict: yes.** `cargo check --release --target aarch64-linux-android` exits 0 on -the Cuprate PoC tree, and a *full link* of the resulting Android binary also -succeeds (`ld.lld` verdict: ELF 64-bit ARM aarch64 PIE, Android 26, NDK r28c). -The cross-compile needs a specific environment and four extra link arguments; both -are spelled out below. All of it is build plumbing — no Cuprate or RandomX source -change was needed, and no host-arch object leaked into the artifacts. - -## Environment used - -- Host: Arch x86_64, cargo/rustc 1.98.1, 16 cores. -- `aarch64-linux-android` std installed via rustup (`~/.cargo/bin` **must** win the - `PATH` lookup — see gotcha 1). -- NDK r28c at `/home/lancelot/Android/Sdk/ndk/28.2.13676358` (matches - `ndkVersion` in `android/sdk/build.gradle.kts`). -- API level **26** (matches `minSdk = 26` in `android/app/build.gradle.kts`). -- Spike tree: the `cuprate-poc` manifest (`cuprated` git dep at `4f8fcd1b`, - `randomx-rs` git dep at `76c2385`, `arti-client` 0.46 + `tor-hsservice`), copied - to `/var/tmp/cuprate-android-poc` so it does not race the testnet card editing the - shared `/home/lancelot/.hermes/tmp/cuprate-poc`. - -## Recipe - -```bash -export PATH="$HOME/.cargo/bin:/usr/bin:/bin" # rustup cargo/rustc, not the system ones -export ANDROID_NDK=/home/lancelot/Android/Sdk/ndk/28.2.13676358 -export ANDROID_NDK_ROOT="$ANDROID_NDK" ANDROID_NDK_HOME="$ANDROID_NDK" -eval "$(cargo ndk-env -t arm64-v8a -P 26)" # CC_/CXX_/AR_/CLANG_PATH for cc-rs + bindgen -export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=\ -"$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang" -export CARGO_TARGET_DIR=/var/tmp/-target TMPDIR=/var/tmp/-tmp - -cargo check --release --target aarch64-linux-android # exit 0 -``` - -Linking a real binary (what Gradle will do) needs the C++ runtime and the compiler-rt -builtins on the link line, because RandomX is C++ and its aarch64 JIT calls -`__clear_cache`: - -```bash -cargo rustc --release --target aarch64-linux-android -- \ - -C link-arg=-L$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android \ - -C link-arg=-L$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/19/lib/linux \ - -C link-arg=-lclang_rt.builtins-aarch64-android \ - -C link-arg=-lc++_static \ - -C link-arg=-lc++abi \ - -C link-arg=-Wl,--exclude-libs,libc++_static.a \ - -C link-arg=-Wl,--exclude-libs,libc++abi.a -``` - -## Evidence - -`cargo check --release --target aarch64-linux-android` (cold target dir, same tree): - -``` - Compiling ... 152 crates ... - Finished `release` profile [optimized] target(s) in 43.66s -### EXIT=0 -``` - -Full build + link, same env: - -``` - Finished `release` profile [optimized] target(s) in 1m 56s -### EXIT=0 -$ file /var/tmp/cuprate-android-target/aarch64-linux-android/release/cuprate-poc -ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, -interpreter /system/bin/linker64, for Android 26, built by NDK r28c (13676358), not stripped -``` - -RandomX specifically — the C++ half that could not be hand-waved: - -- `out/lib/librandomx.a` exists; member `aes_hash.cpp.o` is `ELF64 / AArch64` - (`readelf -h`) — real cross-built objects, not a host archive. -- `CMakeFiles/randomx.dir/src/` contains `jit_compiler_a64.cpp.o` **and** - `jit_compiler_a64_static.S.o`, i.e. the ARM64 JIT path was selected - (`CMakeCache.txt`: `CMAKE_SYSTEM_PROCESSOR=aarch64`, `-DHAVE_HWCAP`). -- Flags actually used: `-march=armv8-a+crypto` (from RandomX's ARMv8 branch). The - `DARCH=native` that `randomx-rs`'s `build.rs` passes is a **no-op** — RandomX's - `CMakeLists.txt` never reads `DARCH`, so `ARCH` stays `default`. That is lucky and - worth knowing: had `-march=native` applied, the ARM64 branch would have targeted - the *host* CPU while cross-compiling. - -Cost on the desktop: cold `cargo check` for this graph ≈ 44 s / 694 MB of target dir; -`cargo build --release` through to a linked binary ≈ 2 min with the dependency graph -mostly warm / 1.7 GB (the RandomX C++ build is 26 top-level sources plus the aarch64 JIT). -The release demo binary is 51 MB unstripped. - -## Gotchas (each one cost a run) - -1. **`PATH` order decides which toolchain answers.** With `/usr/bin` ahead of - `~/.cargo/bin` the system rustc answers and the build dies with - `error[E0463]: can't find crate for 'std' … the aarch64-linux-android target may - not be installed`, even though rustup has it. -2. **Plain `cargo check --target aarch64-linux-android` is not enough**: cc-rs cannot - find `aarch64-linux-android-clang` and `libsqlite3-sys` (bundled sqlite) fails - first. `cargo ndk-env` is what supplies `CC_/CXX_/AR_` for the target; the - per-target `linker` in `~/.cargo/config.toml` covers only the Rust link step, not - the C toolchain (same trap the global `[build] target` used to cause). -3. **CMake needs the NDK env var too.** `cmake-rs` does pass - `-DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_PROCESSOR=aarch64`, but CMake's - `Android-Determine.cmake` still aborts with *"Android: Neither the NDK or a - standalone toolchain was found"* unless `ANDROID_NDK` (or `ANDROID_NDK_ROOT`) is - exported. `randomx-rs`'s build script then panics inside `cmake-0.1.58`. -4. **`cargo-ndk-env`'s linker wrapper is broken on this toolchain**: - `CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER` points at `cargo-ndk` itself, and rustc - calls linkers with `-Wl,…`, which that binary re-parses as a *cargo* invocation - (`error: unexpected argument '-W' found`, then it prints a - `rustup target install armv7-linux-androideabi` hint that has nothing to do with - the failure). Point the linker at the NDK clang driver instead, as above. The - broken run also leaves a stale **directory** named `librandomx_rs-.so` in - `/release/deps/`, and the next cargo run then dies with *"the generated - executable … conflicts with the existing directory"* — `rmdir` it. -5. **The C++ runtime is not linked for you.** `randomx-rs`'s `build.rs` emits - `rustc-link-lib=static=stdc++`, and the NDK's `libstdc++.a` is a stub, so the final - link fails with `__cxa_allocate_exception` / `std::runtime_error` / `typeinfo` - undefined. `-static-libstdc++` does **not** fix it — NDK clang reports - *"argument unused during compilation"* and ignores it. Link `-lc++_static - -lc++abi` explicitly. Separately, `__clear_cache` (RandomX aarch64 JIT) is only in - `libclang_rt.builtins-aarch64-android.a`, so that library path and `-l` are needed - too (this is what `cargo ndk --link-builtins` exists for). -6. **API level matters.** With the NDK default (`-P 21`) the link fails on - `pthread_atfork`, referenced by `rand`'s fork handler; `pthread_atfork` is API 23+. - Use `-P 26` to match the app's `minSdk`. OnionWire's own - `~/.cargo/config.toml` already hints at 26 (`-Wl,-L…/sysroot/usr/lib/aarch64-linux-android/26`). - -## What this means for the payment plan - -- §7a Phase 1 survives the Android lens: the Cuprate-in-process daemon - (`cuprated` + RandomX + fjall) compiles **and links** for `aarch64-linux-android`. - What remains for Android is packaging plumbing in the Gradle/`cargo ndk` build — - the C++ runtime and builtins flags above have to be wired into - `android/sdk/build.gradle.kts`'s `cargoBuildAndroid` (or expressed as - `CARGO_TARGET_AARCH64_LINUX_ANDROID_RUSTFLAGS`), not a Cuprate feature gap. -- `RANDOMX_DIR` / `DARCH` in `randomx-rs`'s build script are not a cross-compile - hazard today only because `DARCH` is inert. If the fork ever honours it, a - `-march=native` Android build would be a silent host-arch miscompile. -- Dependency cost is worth restating for the Android AAR: the `cuprated` graph adds - `axum`/`hyper`/`fjall`/RandomX on top of this crate's own. That is build time and - binary size, not a correctness problem, but it is real on a phone. - The **two `arti` families** the spike tree built were an artifact of the PoC - manifest enabling `cuprated`'s default `arti` feature: OnionWire pins - `default-features = false` for `cuprated`, so its arti-client 0.44 is **not** in - this crate's graph — one Tor stack per process (see `docs/WALLET.md`). -- Throwaway harness (not committed, per spike policy): - `/var/tmp/cuprate-android-poc/{check-acceptance.sh,check-cold.sh,build-android.sh,link-android.sh}` - and the logs next to them (`/var/tmp/cuprate-android-{checkcold,accept,ndk2,link6}.log`). - -## Proven in-repo (2026-09-18, card `t_04975420`) - -The spike above ran on a throwaway PoC tree. The same two commands were re-run in -this repository, against `cuprated` at the same pinned revision -(`4f8fcd1bf468f566fcd89c460d50de4adb6825bf`) and behind this crate's -`cuprate-daemon` feature, with the environment from *Recipe* above: - -``` -$ cargo check --locked --release --target aarch64-linux-android --features cuprate-daemon - Finished `release` profile [optimized] target(s) in 1m 50s -CHECK_EXIT=0 - -$ cargo rustc --locked --release --target aarch64-linux-android \ - --features cuprate-daemon --bin onionwire -- - Finished `release` profile [optimized] target(s) in 2m 05s -LINK_EXIT=0 -$ file /aarch64-linux-android/release/onionwire -ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, -interpreter /system/bin/linker64, for Android 26, built by NDK r28c (13676358), -not stripped -``` - -`cargo rustc` needs `--bin onionwire` (or `--lib`) because this crate has both -targets and rustc link args may only go to one of them — the PoC had a single bin, -so this is new to the real tree. - -Sizes, same target and link args, `llvm-strip`ed: - -| build | stripped | -|---|---| -| without the feature | 24,725,704 bytes | -| `--features cuprate-daemon` | 37,053,472 bytes | - -That is a delta of **12,327,768 bytes (≈ +11.8 MiB)**, the number -`docs/WALLET.md` quotes. diff --git a/docs/cuprate-launch-spike.md b/docs/cuprate-launch-spike.md deleted file mode 100644 index 6c799b0..0000000 --- a/docs/cuprate-launch-spike.md +++ /dev/null @@ -1,156 +0,0 @@ -# Cuprate in-process launch spike (Phase 1, Spike A) - -**Status:** shipped as history. Production app-owned daemon RPC is **18081**, -not the spike's 18089 unrestricted example. Living doc: [WALLET.md](WALLET.md). - -**Question:** does `cuprated::Node::launch(config).await` start a real Monero chain daemon -*inside the OnionWire process* on testnet, and does the resulting JSON-RPC endpoint at -`127.0.0.1:18089` answer `get_info`, `get_height` and `get_block` the way `monerod` does — -i.e. is the §7a Phase 1 shape (Cuprate in-process for chain, `monero-wallet-rpc` as a -subprocess pointing at it) worth building? - -**Verdict: VALIDATED, with four `get_info`/error-path parity gaps to fix or work around.** - -Status: exploration only. Nothing in `src/` changes here, and no `cuprated` dependency is -added to the repo by this spike. Compile-level feasibility was already proven by the -preceding card; this card proves **runtime** feasibility (launch, RPC, P2P, sync, shutdown). - -## Method - -Throwaway spike crate (not in this repo): `/home/lancelot/.hermes/tmp/cuprate-poc/` -(`src/main.rs`, `run-1.log`, `run-2.log`, `rpc-evidence/`). - -* `cuprated` git dep at the rev already in the POC lock file: - `4f8fcd1bf468f566fcd89c460d50de4adb6825bf` (`cuprated` 0.1.0-preview, features `["arti"]`), - alongside `arti-client` 0.46. Both `arti-client` 0.44.0 (pulled by Cuprate) and 0.46.0 - (OnionWire's pin) resolve side by side in the one lock file (693 packages), and - `tor-hsservice` likewise carries 0.44.0 and 0.46.0. -* The node is launched **in-process**: `Node::launch(config).await` inside a `#[tokio::main]`. - No `cuprated` binary, no `monerod`, no subprocess of any kind for the chain. -* Config: `network = "Testnet"`, `target_max_memory = 2 GB`, `fast_sync = true`, - `p2p.tor_net.enabled = false` (so no Arti bootstrap in this spike), - `p2p.clear_net.enable_inbound = false`, unrestricted RPC on `127.0.0.1:18089`, - restricted RPC on `127.0.0.1:28089`, data dir under the spike tree. -* RPC probes are raw HTTP/1.1 over `tokio::net::TcpStream` (no HTTP client dependency), - with `cuprated::logging::init_logging` enabled so cuprated's own tracing lands in the log. -* CUPRATE's own `get_info` reports the network as `"nettype":"testnet"`, `"testnet":true`. - -## Results - -### Launch and listener - -``` -==== LAUNCH OK in 953.837093ms (resume, data dir with 1160 blocks) -==== LAUNCH OK in 2.842708694s (cold, empty data dir) -==== network=Testnet in-process chain_height=1 -==== RPC socket 127.0.0.1:18089 accepting connections -``` - -Both RPC ports (`18089` unrestricted, `28089` restricted) were bound and accepting TCP within -0.2 s of `Node::launch` returning. Dropping the `Node` handle shuts the node down and the -process exits cleanly (no hung tokio tasks, no orphan process). - -### The three endpoints the card asked for - -| Probe | Status | Payload | -|---|---|---| -| `POST /json_rpc {"method":"get_info"}` | 200 | full daemon-info JSON, `"status":"OK"`, `nettype: testnet`, `height`, `target_height`, `synchronized`, `top_block_hash`, `difficulty`, `cumulative_difficulty`, `block_size_limit`, `version: "0.1.0-preview-release"` | -| `GET /get_info` | 200 | same object (both the JSON-RPC route and the URI route are served, as monerod does) | -| `GET /get_height` | 200 | `{"status":"OK","hash":"7458280c…","height":23758}` | -| `POST /json_rpc {"method":"get_block_count"}` | 200 | `{"count":23758}` | -| `POST /json_rpc {"method":"get_block","params":{"height":H}}` | 200 | `blob` (hex block), `block_header` (monerod-shaped: `height`, `hash`, `prev_hash`, `reward`, `timestamp`, `num_txes`, `difficulty`, `cumulative_difficulty`, `long_term_weight`, `major_version`, `minor_version`, …), `miner_tx_hash`, `tx_hashes`, `json` | - -`get_block` succeeded for heights **0, 1, 2 and 1000** (after sync): e.g. height 1000 returned -a 640-hex-char blob with `block_header.height = 1000`, and the genesis block returned -`block_header.hash = 48ca7cd3…`, the same hash `/get_height` reported at height 1. - -Two naming facts worth recording, because the card's wording ("get_height via /json_rpc") -does not match either daemon: - -* `get_height` is **not** a JSON-RPC 2.0 method in monerod — it is registered as a URI - endpoint only (`MAP_URI_AUTO_JON2("/get_height", …)` and `"/getheight"` in - `src/rpc/core_rpc_server.h:92-93`), while the JSON-RPC method is - `MAP_JON_RPC("get_block_count", …)` (line 134). Cuprate mirrors exactly that split: - `/get_height` answers, `{"method":"get_height"}` over `/json_rpc` is rejected 422 - ("unknown variant `get_height`"), and `get_block_count` answers. This is parity, not a gap. -* Cuprate's router also carries the monerod aliases (`/getinfo`, `/getheight`, - `/getblockcount`, `/gethashes.bin`, …). - -### Real testnet P2P sync in-process - -``` -INFO net{zone="ClearNet"}: Starting outbound connection maintainer, target outbound connections: 32 -INFO net{zone="ClearNet"}:connect_to_random_seeds: Failed to connect to seed node 51.79.173.165:28080: Connection refused -INFO incoming_block_batch{start_height=17968 len=100}: Successfully added block batch fast_sync=false -... - t+ 0s height=1160 target_height=0 in-process_chain_height=1160 - t+ 40s height=4549 target_height=3090939 in-process_chain_height=4549 - t+ 80s height=14068 target_height=3090939 in-process_chain_height=14068 - t+ 120s height=23758 target_height=3090939 in-process_chain_height=23758 -``` - -Testnet sync runs from inside the OnionWire-style process at roughly **200 blocks/s** -(~23.7k blocks in 120 s against a 3.09M-block target), and the RPC `height` tracks the -in-process `node.blockchain.context().chain_height` at every sample — the RPC reads live -chain state, so a wallet child pointed at it sees progress as it happens. - -### Binary cost - -Spike binary (arti 0.46 + cuprated + tokio + harness), release, stripped: -**33,256,328 bytes (31.7 MiB)**; unstripped 48,489,392 bytes. This is consistent with the -earlier +5.6 MB stripped delta over OnionWire's own 25.6 MB release binary. - -## Parity gaps observed (must be handled before Phase 1 lands) - -1. **Out-of-range `get_block` returns a bare HTTP 500 with an empty body.** Requesting - `height = chain_height + 1_000_000` produced `HTTP/1.1 500 Internal Server Error` with a - zero-byte body. monerod answers HTTP 200 with an epee JSON-RPC error object instead: - `error_resp.code = CORE_RPC_ERROR_CODE_TOO_BIG_HEIGHT; - error_resp.message = "Requested block height: N greater than current top block height: M"` - (`src/rpc/core_rpc_server.cpp`, `on_get_block`). A wallet child or our own `wallet.rs` - has to treat a 500-with-no-body as an error it cannot decode, where monerod gave it a - machine-readable code. -2. **`get_info` always reports zero peers**, including while actively downloading blocks: - `outgoing_connections_count = 0`, `incoming_connections_count = 0` in every sample while - `height` climbed 1,160 → 23,758. monerod reports live counts there. Any UI that shows - peer count or "connected" from `get_info` will show zero on a syncing node. -3. **Restricted `get_info` returns placeholder values**: `database_size = 5368709120` - (exactly 5 GiB, `0x1_4000_0000`) and `version = ""`, where the unrestricted server on the - same process/DB returned the real size and `"0.1.0-preview-release"`. `free_space` is - `18446744073709551615` (u64::MAX) on both servers — a placeholder, not a measurement. - `monero-wallet-rpc` polling the restricted endpoint would show a bogus database size and - a blank version. -4. **Version string** is the pre-release label `0.1.0-preview-release`; anything doing a - monerod version comparison against it will not recognise it. - -Not tested here (out of scope for this card): `get_transfers`-shaped flows through a real -`monero-wallet-rpc`, mainnet sync, prune behaviour, Tor zone, and field-by-field equality -against a live `monerod` (no `monerod` binary on this host — the comparison above is against -monerod's source, `core_rpc_server.h` / `core_rpc_server.cpp`). - -## Recommendation - -Phase 1 is **viable**: the chain daemon genuinely runs in-process, its RPC is monerod-shaped -for the three endpoints a wallet needs, and real testnet P2P sync works with no external -binary. Before wiring `monero-wallet-rpc` to it: - -* decide how to handle the 500-on-bad-height path (fix upstream, or treat 5xx as a typed - error in `src/wallet.rs`); -* do not source peer count, database size, free space or version from `get_info` for UI - claims — the restricted server returns placeholders, and the daemon reports zero peers; -* keep the pre-production warning honest in `docs/WALLET.md` / `docs/THREAT_MODEL.md`: - Cuprate's own user book says not to use `cuprated` for anything serious, and RPC parity - (`Cuprate/cuprate#278`) is still open. - -## Reproduction - -```sh -cd /home/lancelot/.hermes/tmp/cuprate-poc -CARGO_TARGET_DIR=/home/lancelot/.hermes/tmp/cuprate-poc-target \ -TMPDIR=/home/lancelot/.hermes/tmp/cuprate-poc-tmp \ - cargo run --release --offline -``` - -The run log (`run-2.log`) and every raw RPC response body (`rpc-evidence/`) are kept in the -spike directory; the data dir (`data/testnet/`) is a 53 MB fjall store after 23.7k testnet -blocks, so restarting the spike resumes instead of re-syncing. diff --git a/docs/design/pq-bootstrap-epoch.md b/docs/design/pq-bootstrap-epoch.md deleted file mode 100644 index 602dc93..0000000 --- a/docs/design/pq-bootstrap-epoch.md +++ /dev/null @@ -1,301 +0,0 @@ -# ADR: a post-quantum bootstrap epoch (epoch 0) - -**Status:** proposed. This is a decision record: it recommends a direction and -changes no code. The protocol and threat-model wording it depends on is already -on `main`; this file does not restate it. - -**Decision:** accept the window (Option C). Revisit when the one-shot session -model changes, or when a one-time prekey can reach the peer without a new wire -field. - -Related: [PROTOCOL.md](../PROTOCOL.md) ("Hybrid ratchet steps, and why epoch 0 -stays classical") and [THREAT_MODEL.md](../THREAT_MODEL.md) ("Epoch 0 is -classical — this is the remaining harvest-now window"). - -## 1. Context: the invariant, stated exactly - -Epoch 0 is the ratchet state a friend pair starts from. It is derived, not -negotiated: - -1. **Each chat message is its own one-shot Noise session.** `Node::send` encodes - exactly one `rat ` frame and hands those bytes to the outbox - (`src/node.rs:1905`, `src/outbox.rs:168`). Sending again opens a new Noise - session to the same onion. There is no connection, stream, or session object - that outlives one application frame. -2. **The Noise handshake carries no application payload.** It is frozen at - `Noise_IK_25519_ChaChaPoly_BLAKE2s`, so no field can hand the peer an initial - ratchet key (`src/node.rs:2316`). -3. **Either peer may send first.** Two peers can each build a sending chain - before either has received anything. The resolution is per-direction chains - over the *unordered pair* of ratchet public keys, so authorship of a direction - is decided by key order rather than by who spoke first - (`src/ratchet.rs:94-116`). -4. **Therefore epoch 0 must be a pure function of material both sides already - have**: the X25519 DH of the two long-lived signed prekeys, with each side's - initial ratchet keypair seeded by - `HKDF(info = "ratchet-key" || pubkey)` - (`src/node.rs:2325-2370`). No wire field, no round trip, no per-session - secret. This is the invariant the three options are measured against. - -The consequence, already documented and not re-argued here: epoch 0 is derived -with the classical `KDF_RK` and the ML-KEM secret enters at the **first -rotation** (`src/ratchet.rs:66-73`, `docs/PROTOCOL.md:683`). Every frame sent -before that point is X25519-only at the ratchet layer. - -Two facts bound how much that costs, and they matter for the ranking: - -- **For a v2 friend the `rat ` frame rides inside a hybrid Noise session.** A - recorded transcript is not opened by an X25519 break alone; the ML-KEM-768 - prelude has to be broken too, and it is per-dial. Epoch 0 becomes the exposed - layer when the rat frame is separated from the session that carried it — a - state snapshot, an outbox row at rest, a logging client, or a classical peer - (`docs/THREAT_MODEL.md:163-192`). -- **The ML-KEM half of a ratchet keypair is derived from the X25519 secret** - (`src/ratchet.rs:56-63`, `src/ratchet.rs:326`). It adds no independent secret - to epoch 0, so "every keypair is hybrid" does not mean the bootstrap epoch is. - -## 2. Options - -Each subsection has the same shape: mechanism, wire cost, convergence, effect on -the outbox and stored/replayed frames, test surface, and cost in slice-days. One -slice-day is one focused working day for one agent in this repo, including tests -and the doc updates the change would force. - -### Option A — one-time prekey batch in the invite - -**Mechanism.** The invite carries N ML-KEM-768 one-time prekeys (OPKs) in -addition to the long-lived `kem=`. The peer consumes one per dial or per epoch, -depending on which layer the OPK is meant to protect — that ambiguity is the -first finding below. The threat model already lists "No one-time prekeys" as an -honest limit (`docs/THREAT_MODEL.md:199-203`), so this is the option that would -close a named gap; the size and convergence findings are what kill it. - -**What the invite gains.** A new version, necessarily. The v2 signature domain is -`onionwire-invite-v2 || 0x00 || k || 0x00 || o || 0x00 || spk || 0x00 || kem` -(`src/qr.rs:38`), and `parse_fields` rejects any unrecognised field with -`unknown field` (`src/qr.rs`, `parse_fields`). So an `opk=` field on a v2 string -is a decode error, not an ignored extra: the batch is `onionwire:v3`, a new -signature domain, and a new field in the signed message. - -**Size, numerically.** A v2 invite is 1930 characters for a 56-character v3 -onion. Each ML-KEM-768 OPK is 1184 bytes, which is 1579 base64url characters -plus a 5-character `:opk=` prefix — **1584 characters each**. The decoder caps -input at `MAX_INVITE = 4096` (`src/qr.rs:30`), and the TUI renders the invite -through `qrcode` 0.14.1 at its default `EcLevel::M` (`src/tui.rs:2818`), whose -byte capacity is **2331 characters** (measured against the pinned crate, not -recalled). Therefore: - -| Invite | chars | fits `MAX_INVITE` | fits one QR at M | -|---|---|---|---| -| v2 today | 1930 | yes | yes | -| v3, 1 OPK | 3514 | yes | **no** | -| v3, 2 OPKs | 5098 | **no** | no | -| v3, 4 OPKs | 8266 | no | no | - -A batch that could survive more than one use cannot be carried by this invite at -all: two OPKs already exceed the decoder's own cap, and one already exceeds what -the QR path can render. The invite would have to move to a file/NFC transfer, or -the QR would have to be dropped, before the batch is even representable. - -**What is consumed, and when.** This is where the option loses its premise. If -the OPK is consumed at the **transport** layer (one per Noise dial), it is one -per message: a retry after a queued send is a new dial and burns another, and a -batch of N is exhausted after N dials with no replenishment path — the peer has -the invite, not a directory, so the next invite paste is the only refill. If it -is consumed at the **ratchet** layer, it is one per epoch, and the secret has to -reach the peer: ML-KEM encapsulation is randomised, so the sender must transmit -a 1088-byte ciphertext. That is exactly Option B's wire field. **A does not fix -epoch 0 without B**; on its own it only improves the transport handshake, which -already carries a per-dial ML-KEM secret in the v2 prelude. - -**Unused prekeys.** They are decapsulation keys stored for the life of the -install, with no expiry and no ratchet benefit. A state snapshot hands them over, -so they become an additional long-lived secret rather than a forward-secrecy -win. The roster already drops state when a peer's prekey changes -(`src/node.rs:2385-2395`); a batch would need its own consumption cursor, its own -versioned blob, and a rule for when a partly-consumed batch is abandoned. - -**Wire cost.** Invite only, if the OPK is used at the transport layer (+1584 -characters per prekey, and the QR stops working at one). Invite *and* frame -(+1088 header bytes per epoch-0 frame, repeated until the first rotation) if used -at the ratchet layer — at which point it is B. - -**Convergence.** At the transport layer, unchanged: each Noise session's two -endpoints both know that session's `ss_kem`, so per-dial secrets are fine there. -At the ratchet layer, A *breaks* convergence on its own: both peers encapsulate -to the same OPK, get different secrets (fresh randomness on each side), and -derive different epoch-0 roots. Only one direction's ciphertext can be the -authoritative one, and carrying it is a wire field. - -**Outbox and replayed frames.** A stored `rat ` frame is replayed byte-for-byte -over a fresh Noise session (`src/outbox.rs:161-175`; the retry loop must not -advance the sending chain twice, so the frame is encoded once). Transport-layer -OPK consumption therefore drains the batch on retries, not on delivered -messages. Ratchet-layer consumption requires the receiver to retain the OPK -private key until every queued row encrypted under it is delivered or -terminally failed — unbounded retention, which contradicts "one-time". - -**Test surface.** Invite v3 round-trip and signature domain; rejection of `opk=` -on v2; batch exhaustion and the fallback to `kem=`; QR capacity (the invite -render path currently has no graceful path for "too long for one symbol"); -retry-burns-a-prekey; a both-send-first test showing the two roots diverge if the -ratchet layer is attempted without a field. - -**Cost (estimate).** 5–7 slice-days for the invite/transport version of A (invite v3, -signed field, store pool, consumption cursor, tests, docs). It buys a -transport-layer improvement that is already covered by the per-dial prelude, and -leaves epoch 0 exactly as it is. The ratchet-layer variant is B plus this cost. - -### Option B — per-session epoch derivation with an extra wire field - -**Mechanism.** Add material to the ratchet header and derive the epoch from it. -The natural shape is a new version byte (`0x03` classical + field, `0x04` hybrid -+ field) because `0x01` and `0x02` are already taken and the header is the AEAD -associated data, so its exact shape is load-bearing -(`src/ratchet.rs:1-40`, `src/ratchet.rs:585-601`). The field would be a 32-byte -salt, or a 1088-byte ML-KEM ciphertext if it carries a prekey secret. - -**Wire cost.** 32 bytes per frame (salt) or 1088 bytes per frame (ciphertext), -repeated on every frame of the epoch-0 chain because the first frame can be lost. -The classical header goes 40 → 72 bytes, the hybrid header 2312 → 3400, and the -documented minimum frame sizes (350 classical, 2622 hybrid, -`docs/THREAT_MODEL.md:217-220`) all move. The minimum-size tests and the padding -ladder's interaction with the floor would have to be re-derived, not just -re-numbered. - -**Convergence.** This is the option's fatal case. The field arrives *in* the -frame, so neither side has the other's field before its first send. Two designs -are available and neither restores the invariant: - -- *Sender-chosen salt, per direction.* Each side derives its own sending chain - from its own salt. That works for the first message in each direction, but the - epoch's shared root advance now depends on two salts, and the side that rotates - first — the tie-break side rotates on its first *decrypt* - (`src/ratchet.rs:624-630`) — may have seen only one of them. The root is no - longer a pure function of the pair, so the lockstep argument in - `src/ratchet.rs:100-116` no longer holds and the peers can diverge at the - first rotation. -- *Salt derived from the Noise session secret.* Then the two peers' first sends - ride different sessions with different secrets, and message 2 rides a third - session, so a stored and retried frame cannot be re-derived at all — see the - outbox row. - -A public salt in the header adds no secrecy, because it is transmitted in clear -inside the Noise transport. It would only bind the chain to a random value, -which is not the threat. So B is either a no-op against harvest-now, or it is a -salt that breaks convergence, or it is a KEM ciphertext that reintroduces A's -consumption and retention problems. - -**Outbox and replayed frames.** A salt lives in the stored frame, so a verbatim -replay is consistent. A ciphertext likewise survives the replay, but the -receiver must still hold the matching private key when the retry lands — so the -"one-time" key is retained until the outbox row is delivered or fails, and -`DEFAULT_MAX_ATTEMPTS` (8) with a 30-minute backoff cap means that retention is -measured in hours at minimum. This is the same retention conflict as A, now on -the frame path. - -**Test surface.** New version bytes and header layout; AAD coverage of the new -field; the both-send-first matrix re-derived (the existing convergence tests in -`src/ratchet.rs` and `tests/ratchet_wire.rs` assert the current argument, not just -the happy path); `STATE_VERSION` 2 → 3 with a v2 blob dropped exactly like v1 -(`src/ratchet.rs:163`, `src/node.rs:2385-2395`); cross-version interop, since a -friend with a v2 invite has no field to send — downgrade is decided by the -roster, never by what arrives on the wire, so these are two different epoch -shapes that must never be negotiated dynamically; padding floor and minimum-frame -constants. - -**Cost (estimate).** 8–12 slice-days, and it leaves the ambiguous root-advance rule open -(that is the item in "Not solved by this doc"). - -### Option C — accept the window, keep the honesty bounds - -**Mechanism.** No change. Epoch 0 stays prekey-derived and classical; the KEM -secret enters at the first rotation; the docs keep saying so in the three places -they already do (`src/ratchet.rs:66-73`, `docs/PROTOCOL.md:683-720`, -`docs/THREAT_MODEL.md:163-192`). - -**What has to be true for this to stay acceptable.** These are the conditions the -decision rests on; if one stops holding, the trigger in §3 fires. - -- *The first rotation is prompt.* It happens on the first inbound frame after - `established`, and the lower-key side also rotates immediately on that decrypt - (`src/ratchet.rs:624-630`). A peer that sends and never receives stays on - epoch 0 by definition; the window closes with the first reply, not with time. -- *Nothing claims otherwise.* "Post-quantum transport, classical bootstrap - epoch" is the ceiling. `docs/THREAT_MODEL.md:25` and - `docs/THREAT_MODEL.md:163` are the sentences that must not drift, and - README/marketing copy inherits them. -- *A state snapshot is already the whole game.* The ratchet state lives in the - same SQLCipher file as the plaintext history, and `docs/THREAT_MODEL.md:205-209` - says a snapshot carries both chain keys, the skipped keys, and the history. - Epoch 0 is therefore not the weakest link at rest: an attacker with the store - reads the messages, not the chain. The epoch-0 exposure is about frames outside - the store — captured traffic and delivered outbox rows — not about the device. -- *Outbox exposure stays bounded by delivery.* A row encoded on epoch 0 carries - epoch-0 keys until it is delivered or terminally fails - (`docs/THREAT_MODEL.md:176`). The queue is local, bounded by - `DEFAULT_MAX_ATTEMPTS`, and never handed to a third party, so this is the same - window as a live epoch-0 message, not a new one. -- *The roster still decides downgrade.* A v1 friend has no PQ layer anywhere; - that is a roster fact, not a wire negotiation - (`docs/THREAT_MODEL.md:183-187`). - -**Wire cost.** Zero. **Convergence.** Unchanged, and covered by the existing -both-send-first and cross-peer tests. **Outbox and stored frames.** Unchanged; -the verbatim-replay property stays exact. **Test surface.** No new tests; the -existing ones already pin the invariant. **Cost.** 0 slice-days. The standing -cost is one honest sentence in the docs, which is already paid. - -## 3. Comparison and decision - -| | A — OPK batch | B — epoch field | C — accept | -|---|---|---|---| -| Wire cost | +1584 chars/invite (QR dies at 1) | +32 or +1088 B/frame, new versions | 0 | -| Fixes epoch 0? | no (transport only; needs B for ratchet) | only as a public salt, which is not the threat | n/a | -| Convergence | breaks it at the ratchet layer | ambiguous root advance; breaks lockstep | unchanged | -| Outbox / replay | drains batch on retries; unbounded OPK retention | verbatim replay OK, retention unbounded | unchanged, bounded by delivery | -| Test surface | invite v3, pool, QR capacity, divergence | header, state v3, both-send-first matrix, floors | none | -| Slice-days (est.) | 5–7 (and buys no epoch-0 fix) | 8–12 | 0 | - -**Decision: C.** A does not make epoch 0 post-quantum — it adds invite mass and a -consumption problem, and the part that would touch the ratchet is B's wire field, -which cannot converge under both-send-first without an ambiguous root rule. C -costs nothing, keeps the one property the design actually relies on (a root that -is a pure function of the prekey pair), and the exposure it accepts is already -shadowed for v2 friends by the per-dial hybrid Noise session. - -**Revisit triggers**, in priority order. Any one of these reopens this ADR; none -is a reason to start work now: - -1. **The one-shot session model changes.** If chat ever gets a session that - outlives one frame, the blocker in §1 disappears and epoch 0 can take a - per-session secret. This is the real trigger. -2. **A delivery path for a prekey ciphertext exists without a new field.** E.g. - the handshake gains an application payload. Then A becomes viable at the - ratchet layer. -3. **The invite stops being QR-first.** If invites move to file/NFC and the - `MAX_INVITE` cap can move with them, a batch is at least representable — still - subject to the replenishment problem, so this alone is not enough. -4. **Any doc or release note claims post-quantum messaging.** That is a - documentation failure to fix immediately, not a reason to ship A or B. - -**Consequences.** No code changes. The next card on this topic is not A or B; if -one is proposed anyway, it must answer B's root-advance question and the QR -capacity finding in A before it can be scoped. The docs on `main` continue to be -the authority on what is and is not post-quantum. - -## 4. Not solved by this doc - -- **In-band revocation / unfriend.** There is no revoke frame; the roster drops - a friend locally, and the peer keeps the current onion until F4 - (`docs/THREAT_MODEL.md:19`). -- **Prekey or KEM rotation without a new invite.** F8 rotates the signed prekey - and the ML-KEM install key, and every friend must paste the new invite; there - is no push path (`docs/THREAT_MODEL.md:21-24`). Option A makes this worse, not - better: a batch has no refill channel, so it inherits the same hard cut. -- **Option B's open question.** Which input advances the epoch root when two - per-direction salts exist and the first rotator has seen only one of them. A - future B proposal has to answer that before it can be implemented; this doc - does not. -- **Guard discovery.** The long-lived v3 onion and Arti's vanguards-lite are a - separate opsec gap and are not addressed by any of the three options. diff --git a/docs/option-a-recommendation.md b/docs/option-a-recommendation.md deleted file mode 100644 index 93e86d5..0000000 --- a/docs/option-a-recommendation.md +++ /dev/null @@ -1,76 +0,0 @@ -# Recommendation: Option A — bundle the `arti` binary as a SOCKS subprocess - -**Status:** shipped. The wallet child uses `arti proxy -p` for `.onion` daemons. -Living doc: [WALLET.md](WALLET.md). This file is the decision record. - -## What Option A is - -Run the `arti` CLI (not `arti-client`) as a child process doing `arti proxy -p `. The wallet child points `--proxy 127.0.0.1:` at it. The messenger continues using in-process `arti-client`. Two Tor clients in one app: one in-process for the messenger, one subprocess for SOCKS. - -This is the path the arti project itself points to for interop with external processes, and it is the known quantity. It answers the Android wallet question with the least custom code. - -## What makes it attractive - -- **No custom SOCKS server.** You do not write a SOCKS5 accept-loop, byte bridge, DNS-leak handling, stream lifecycle, or error handling. The arti binary already does all of that. -- **Wallet child just works.** `monero-wallet-rpc --proxy 127.0.0.1:` speaks plain SOCKS5. It does not need to know anything about Arti. This is the shape the wallet binary was built for. -- **Smallest diff to the messenger code.** The in-process `arti-client` used for chat does not change. You add one child-process manager for the SOCKS proxy and one config knob for the wallet child's `--proxy` target. No change to the Noise/identity/store paths. - -## The auth gap - -This is the real trade-off and the reason the recommendation is not unconditional. - -The app's `--password` enforcement lives in the in-process `arti-client` path: the messenger dials friends' onions through Arti, and the wallet child reaches a remote `.onion` monerod through the SOCKS proxy. With Option A, the SOCKS listener is a separate process on a localhost port. Any local process that can connect to `127.0.0.1:` can use it — including a wallet child that was started without the app's credentials, or any other local code. - - Concretely: if the wallet child is the only local consumer of the SOCKS port, the gap is small. If the app ever runs other local processes, or if the wallet child can be started by something other than the app, the SOCKS port is an open Tor exit for anything on the device. - -This is not a Tor anonymity failure in the usual sense — the SOCKS port is localhost, not a clearnet bridge. But it is an authorization gap: the app's `--password` gate does not cover traffic that enters Tor through the child's SOCKS port, because that traffic never passes through the app's Arti client. - -## How to reduce the gap without abandoning Option A - -The cleanest mitigation is to make the SOCKS port access-controlled at the process boundary, not at the Tor boundary: - -1. **Bind the SOCKS listener to a Unix domain socket, not TCP.** If `arti proxy` can listen on a Unix socket, only processes that can open that socket can use it. On Android that path lives in app-private storage, so it is gated by the app sandbox. This is the strongest local control and removes the TCP localhost exposure entirely. Verify `arti proxy` supports a Unix socket listen target before committing; if it does not, this mitigation is unavailable and you are back to TCP localhost. -2. **If TCP is the only option, bind to `127.0.0.1` only and treat the port as app-private.** Do not expose it on `0.0.0.0` or a LAN address. Document that the port is a local Tor entry point for the wallet child only, and that any other local process with user-level access can use it. This is honest, not a fix. -3. **Gate the wallet child's start on the same credential material the app already owns.** If the app requires `--password` / a wallet passphrase / a host identity before it will start the wallet child, then the only process that can reach the SOCKS port is one the app launched. That is not a technical block on a hostile local process that somehow gets on the box, but it means the normal path is closed unless the user already authenticated to the app. -4. **Keep the two Tor clients' state separated unless you have verified sharing is safe.** If you point the subprocess `arti` at the same state dir as the in-process client, confirm upstream whether that is supported and what the failure modes are. If it is not safe, run them with separate state and accept that they do not share circuits or cached data. Do not silently share state on the assumption that it works. - -## What the wallet child's connection looks like under Option A - -``` -Android app process - ├── in-process arti-client → friend onions (messenger) - └── arti proxy subprocess → SOCKS5 on 127.0.0.1: (Unix socket if supported) - └── monero-wallet-rpc child --proxy 127.0.0.1: - └── ( 양파 ) remote .onion monerod :18089 -``` - -Wallet RPC itself stays loopback-local between the app and the wallet child. Only the chain traffic — the wallet child's `--daemon-address` connection to the remote `.onion` monerod — goes through the SOCKS proxy. That matches the existing rule: wallet RPC is loopback, chain traffic is Tor. The SOCKS proxy is the Tor entry point for the wallet child's chain connection. - -## What to verify before committing to Option A - -1. **Does `arti proxy` support a Unix domain socket listen target?** If yes, use it. If no, you are stuck with TCP localhost and the auth gap is real and must be documented. -2. **State sharing between the in-process client and the subprocess.** Can they safely share a state dir, or must they have separate state? This affects disk use, startup time, and whether the SOCKS proxy can reuse circuits the messenger already built. -3. **`monero-wallet-rpc --proxy` behavior.** Confirm the wallet child speaks SOCKS5 (not HTTP proxy), honors `--proxy` for its daemon connection, and does not do local DNS on the `.onion` target. The traffic is already a Tor address, so DNS is less of a leak than with a DNS name, but verify the handshake does not pre-resolve. -4. **Child lifecycle on Android.** The SOCKS proxy and the wallet child are both long-running subprocesses. Android can kill them under memory pressure, during Doze, or when the app is backgrounded. Confirm the app restarts them on resume and that the wallet child reconnects to its daemon after a kill. This is the same lifecycle problem the messenger already has with in-process Arti, but now multiplied by two children. -5. **APK size impact.** Bundling `arti` as a binary per ABI is additional APK weight. Quantify it before committing. If the binary is large and the SOCKS path is the only reason for it, that is a real cost against a feature that most users will not exercise (most will use receive-only or a remote wallet host, not a local chain connection through SOCKS). - -## When Option A is the right call - -Option A is right when: - -- You want the wallet child to reach a remote `.onion` monerod and you do not want to write a SOCKS server. -- You accept that the SOCKS port is a localhost Tor entry point and you either control access via a Unix socket or document the TCP-localhost reality. -- You are willing to bundle `arti` as a subprocess binary and manage its lifecycle on Android. -- The alternative — writing a SOCKS5 bridge on top of in-process `arti-client` — is more code than you want to own, or the bridge's DNS/circuit/stream handling is not worth the maintenance. - -## When to reconsider - -Reconsider toward Option B if: - -- `arti proxy` cannot listen on a Unix socket and you are unwilling to accept an open TCP localhost SOCKS port as the authorization model. -- Bundling `arti` as a binary is too heavy for the APK and the SOCKS path is not core enough to pay for it. -- You want a single Tor client and a single state dir, and you are willing to own the SOCKS bridge code to get there. - -## Bottom line - -Option A is the pragmatic choice: it uses the real arti SOCKS proxy, requires the least custom code, and matches the shape the wallet child expects. The cost is a second Tor client and an authorization gap on the SOCKS port, which is best closed with a Unix domain socket listen if `arti proxy` supports it, and otherwise documented honestly as a localhost-only Tor entry point gated by the app's own process launch policy. diff --git a/docs/payment-integration-plan.md b/docs/payment-integration-plan.md deleted file mode 100644 index 27b060b..0000000 --- a/docs/payment-integration-plan.md +++ /dev/null @@ -1,262 +0,0 @@ -# OnionWire payment integration — next steps - -**Status:** largely shipped (child wallet, `/pay` `/tip`, F6 create/import, F9 -menu). Still open on desktop: no TUI editor for a stored external RPC URL or a -typed remote daemon host (API exists; error copy still says “F7”). Living docs: -[WALLET.md](WALLET.md), [TUI.md](TUI.md). This file is the plan as written; do -not rewrite the conclusion. - -**Audience:** dev profiles (rust-dev for core/SDK/TUI, apk-dev for Android), with CI as a cross-cutting concern. -**Goal:** turn the existing `inv`/`rcp`/`tip` wire frames and the existing `monero-wallet-rpc` HTTP Digest client into a real in-app payment flow on both TUI and Android, with the wallet fully owned by the app (bundled binaries), chain backends opt-in (local pruned node, or remote onion daemon), clearnet refused, Tor for the messenger and for any remote-daemon chain traffic. - -This is the plan for the payment half of "comms and payment terminal." Chat, identity, invites, QR, outbox, store encryption, and the Noise transport are pre-existing and in scope only where a payment feature touches them. - ---- - -## 1. What exists today (don't rebuild) - -- **Wire frames:** `src/pay.rs` — `Invoice`, `Receipt`, `Tip`, with encode/decode/sign/verify, domain-separated signatures (v2) and legacy v1 accept, `invoice_chat_line` / `receipt_chat_line` / `tip_chat_line` display helpers, `TIP_PREFIX`/`INV_PREFIX`/`RCP_PREFIX` dispatch. -- **Wallet RPC client:** `src/wallet.rs` — `Wallet` struct, HTTP Digest to a `monero-wallet-rpc` on loopback, `get_address` / `create_address` / `get_transfers` / `get_balance` / `transfer`, view-only detection via `query_key spend_key → -29`, open-RPC refusal, loopback-only host check. This is the RPC client we keep; it does not change for the wallet-RPC path. -- **Node wiring:** `src/node.rs` — `pay_invoice` (create subaddress or use profile `xmr_addr`, sign `inv`, send one-shot), `tip` (RPC `transfer`, sign `rcp` + `tip`, send both one-shot), `wallet_receive_address`, `wallet_balance`, `wallet_balance_line`, `wallet_recent_transfers`. These are the shapes to preserve; they already call the right `Wallet` methods and emit the right frames. -- **Receipt verification:** `node.rs::ingest_receipt` — verify sig, insert payment row `verified=0`, then if wallet configured do a conjunctive `get_transfers` match on `(txid, amount, address)` and mark `verified=1` on exact match; RPC down/err → stays unverified. This logic stays; only the wallet backend behind it changes. -- **QR / invite:** `src/qr.rs` — `QrPayload` encode/decode for the messenger invite. The wallet also has a receive address; the app will render that as a QR too (separate from the messenger invite QR). The `monero:` address path in the TUI already exists for the wallet screen — reuse/extend that, don't invent a new address representation. -- **Threat model / wallet docs:** `docs/THREAT_MODEL.md`, `docs/WALLET.md` — read before changing anything wallet-related; the new backends are changes to those claims. - ---- - -## 2. The architecture to build - -### 2.1 One wallet surface, three chain backends - -The `Wallet` client (loopback HTTP Digest) does not care where the wallet child's daemon lives. What changes is **how the app launches the wallet child and where the wallet child points its `--daemon-address`**. Build one abstraction that owns both binaries and their lifecycle, and exposes the same wallet ops through it. - -Backends (opt-in, user chooses; not hidden defaults): - -1. **Local pruned node (on-device).** Bundle both `monerod` and `monero-wallet-rpc`. App owns `/chain` and `< datadir>/wallet`. Wallet child's `--daemon-address` = `127.0.0.1:`. Both children are app subprocesses. This is the maximal on-device shape. -2. **Local wallet + remote onion daemon.** Bundle `monero-wallet-rpc` only (or both — see §2.3). Wallet child's `--daemon-address` = `.onion:18089`, and the wallet child reaches it through a SOCKS5 proxy the app provides on localhost. Chain traffic goes over Tor through that SOCKS hop; the wallet RPC itself stays loopback. -3. **Remote clearnet daemon (explicit opt-in, warned, non-default).** Same as above but daemon address is a clearnet host. Document the trust shift. Do not make this the default or the implied path. - -The messenger (Arti onion ↔ onion) is separate from the wallet backend in all three cases. Tor for the messenger is always on; Tor for chain traffic is only for backend 2 (and backend 3 if you allow it, though backend 3 is the one you don't center the design on). - -### 2.2 Wrapper model (this is the product shape) - -The app is a wrapper around the real binaries, specialized for messenger + payment. The binaries do the real Monero work; the app is the control plane + UI + the messenger on top. This is the xmr-pocket-node pattern: not a wallet rewrite, a managed-node wrapper. - -The wrapper owns: - -- **Binaries** — bundled per platform/ABI (and/or auto-fetched on first opt-in with verification). -- **Data dirs** — chain dir, wallet file, both in the app's storage. TUI: `$ONIONWIRE_HOME/chain`, `$ONIONWIRE_HOME/wallet`. Android: app-private storage. -- **Lifecycle** — start monerod, wait for ready, start wallet-rpc pointed at the daemon, watch both, restart on resume, stop on shutdown, tolerate kills. Do not assume long-running guarantees on Android. -- **Sync state** — expose daemon sync progress to the UI; don't let the wallet act on a node that isn't ready enough. Don't lie about readiness. -- **Controls** — start/stop daemon, sync-on-Wi-Fi-only, sync-while-charging-only, storage/sync honesty in the UI. -- **RPC wiring** — wallet-rpc loopback with generated creds + random port; its daemon address points at local monerod (backend 1) or at the remote onion through SOCKS (backend 2). -- **Spending opt-in** — wallet create/restore, seed backup + passphrase, spend-capable vs view-only, spend-authority warning. - -### 2.3 The SOCKS question is the Android gating item - -For backend 2 on Android, the wallet child is a SOCKS5 client that talks to a localhost SOCKS listener the app provides. The wallet child does **not** use Arti's `connect()` — it just speaks SOCKS5 to localhost. - -- If the app's in-process Arti (the same one the messenger uses) exposes a usable SOCKS5 listener on localhost, backend 2 on Android is: bundle `monero-wallet-rpc`, configure it with `--proxy 127.0.0.1: --daemon-address :18089`, wallet child speaks SOCKS5 to Arti's listener, chain traffic goes over Tor. No third binary. -- If Arti 0.46 does **not** expose a usable SOCKS5 listener, backend 2 on Android needs a bundled Tor daemon for the SOCKS listener — a third binary, more APK weight, more lifecycle. At that point backend 2 on Android is "wallet child + bundled Tor + remote onion daemon," and the local-node option (backend 1, monerod on device) may be the cleaner on-device chain story. - -**Verify this first, before committing backend 2 on Android.** Whether Arti gives you a SOCKS5 listener the wallet child can use decides a lot of the Android shape. Do not wire the Android remote-daemon path until this is known. - -### 2.4 Pruned node — the honest on-device bargain - -When the user opts into a local node on device, the realistic target is a pruned node in the ~50-60GB range (mainnet, current prune behavior), not a full archiving node. State this in the UI and gate it with a storage check. - -Pruning has a real boundary the app must be honest about: - -- Incoming transfers within the prune window: fine, daemon has them. -- Incoming transfers older than the prune depth: the daemon may not be able to serve them from its own chain data. The wallet may still know about them from its own cache, but a daemon rescan of deep history is not available. Receipt verification and old-transfer queries can degrade past the prune window. -- Receiving new funds: fine either way. -- Send: needs current chain state and unspent outputs; a pruned node has those for current outputs. - -Don't promise the local pruned node can rescan everything forever. State the prune-window boundary in the wallet UI and in the threat model. - -### 2.5 Spend is opt-in, not default - -- **View-only by default** — receive address, balance, receipt verification only. No seed, no spend. -- **Spend-capable is an explicit choice** at wallet create/restore (seed-backed wallet). When the user creates a spend-capable wallet, show the spend-authority warning: this wallet file can spend; anyone with its passphrase or the RPC creds can spend; back up the seed; don't leave it on a box/host you don't trust. Make it unavoidable at creation time. -- TUI and Android use the same spend-opt-in concept; the UI differs. - ---- - -## 3. Proof order (do these before scaling) - -### P1 — Arti SOCKS feasibility (Android backend 2 gate) - -Determine whether the in-process Arti you bundle exposes a SOCKS5 listener the bundled `monero-wallet-rpc` can use as a `--proxy`. This is a read-the-Arti-config-surface / small-experiment task, not a full build. Outcome is a yes/no and, if yes, the exact config + port selection approach; if no, the fallback is "bundle a Tor daemon for SOCKS" or "Android backend 2 is not clean, local node is the on-device chain story." - -### P2 — TUI local-node proof (the tractable on-device node proof) - -On Linux, spawn a `monerod` child into a test chain dir, get it to start and make real sync progress, spawn a `monero-wallet-rpc` child pointed at that local monerod, and get the existing `Wallet` client to talk to it: `create_address`, `get_balance`, `get_transfers`. No messenger integration yet — just the local-node pipe working on-device on Linux. This proves the wrapper + on-device node shape and surfaces the real storage/sync/runtime behavior before Android carries it. - -### P3 — Android wallet-child + remote onion daemon proof (if backend 2 is viable) - -Bundle `monero-wallet-rpc` for one Android ABI, get it running on-device talking to a remote onion daemon through the SOCKS path (or through a bundled Tor if Arti SOCKS isn't viable). This is the Android "wallet in the binary, chain over Tor" proof, and it's lighter than bundling a full local node. - -### P4 — Android local-node proof (if you want backend 1 on Android) - -Bundle `monerod` too for Android, get it starting and syncing at least a little on-device, wallet child pointed at local monerod, same wallet ops through the same surface. This is the heavy proof — storage, sync, lifecycle. Gate it behind the storage check. - ---- - -## 4. Work breakdown by profile - -### rust-dev — core + SDK + TUI - -**A. Chain + wallet lifecycle abstraction (shared core logic, platform runner differs).** - -Build the concepts and the ops the app uses, implemented in core with platform-specific subprocess runners contributed by the platform layer: - -- `ChainBackend` — `Local { datadir, binary, args }`, `RemoteOnion { onion, port, transport }`, with clearnet as an explicit opt-in shape if you keep it. -- `WalletBackend` — `datadir, binary, rpc_port, creds, daemon_address`. -- Subprocess manager ops: start node, start wallet, watch both, restart on resume, stop on shutdown, expose sync state. -- Wallet ops through the existing `Wallet` client: `create_address`, `get_address`, `get_balance`, `get_transfers`, `transfer`, view-only detection — same shapes, now backed by whichever backend the app configured. -- Random loopback port selection for wallet-rpc; generated HTTP Digest creds stored in the encrypted store (they're sensitive); wallet file + creds persisted so the app can restart the child without asking the user again. Wallet passphrase is the user's to provide at runtime or store — that choice affects the model and should be a deliberate app decision, not an accidental default. - -**B. `wallet.rs` path — minimal change.** - -Keep the HTTP Digest client and JSON-RPC parsing. The new bit is the app telling the wallet child where its daemon is: - -- Local node: `--daemon-address 127.0.0.1:` (no SOCKS needed). -- Remote onion daemon: `--proxy 127.0.0.1: --daemon-address :18089`, wallet child speaks SOCKS5 to the app's SOCKS listener. - -Don't change the wallet client's loopback model. Don't make the wallet client speak Tor directly. - -**C. TUI wallet + node UI.** - -Wiring into the existing command/screen shapes: - -- Wallet create/restore screen: seed generation, show seed for backup, passphrase, spend-capable vs view-only selection with the spend-authority warning. -- Node control: start/stop local node, storage check + prune-target honesty, sync state, sync-on-Wi-Fi/charging options, daemon status. -- Chain backend choice: local node vs remote onion daemon vs (explicit opt-in) remote clearnet, with the trust tradeoff stated for remote. -- Balance, receive address + QR, recent transfers, send/tip flow that goes through the wallet child and emits the existing `inv`/`rcp`/`tip` frames. -- Keep the existing messenger invite QR (F2/F3) and add a separate receive-address QR for the wallet screen. Don't conflate the two. - -**D. TUI integration points to preserve.** - -- `node.rs::pay_invoice`, `node.rs::tip`, `node.rs::ingest_receipt` stay the spines; the lifecycle abstraction feeds them a `Wallet` that points at whichever backend is active. -- The outbox/one-shot frame sending for `rcp`/`tip` stays as-is. -- Receipt verification conjunctive match stays as-is; only the daemon behind `get_transfers` changes. - -### apk-dev — Android app + SDK surface - -**A. Binary packaging for Android.** - -Bundle `monero-wallet-rpc` per ABI now; bundle `monerod` per ABI for the local-node path (either from the start or as the heavier opt-in). This is what "in the binary" means. Include the CI for these binaries (see §5). - -**B. Android subprocess lifecycle.** - -Start/stop/restart the wallet child (and monerod for backend 1), random RPC port, creds in the encrypted store, wallet file + chain dir in app-private storage, restart on resume, kill on shutdown, tolerate the daemon being down. Don't promise "always running" on Android — it won't be. - -**C. Android wallet UI.** - -Same options as TUI, Android-shaped: local node or remote onion daemon (and explicit clearnet opt-in if you keep it), create/restore wallet with seed backup + passphrase, spend vs view-only with the warning, balance, receive address + QR, recent transfers, send flow through the on-device wallet child emitting the existing frames, sync/daemon state, daemon control, storage/sync honesty. - -**D. Android SOCKS path for backend 2.** - -If P1 confirms Arti SOCKS is viable, configure the wallet child with `--proxy` to the Arti listener and `--daemon-address` to the remote onion. If not, wire the bundled-Tor-SOCKS path or treat backend 2 on Android as not clean. Don't ship backend 2 on Android without knowing which SOCKS path you're using. - -**E. SDK surface.** - -Keep the UniFFI surface honest about wallet state: running/not running, balance, receive address, recent transfers, send outcome. The Android app owns the subprocess lifecycle; the SDK exposes wallet state and ops, not the binaries. - -### CI (cross-cutting) - -- **Native binary build + bundle pipeline** for `monerod` and `monero-wallet-rpc` for TUI assets and Android ABIs, kept current, with whatever verification you want on the bundle/download path. This is the make-or-break for "the bundle is the product." If the binaries aren't reliably built and shipped/current, the wrapper can't deliver. -- **Verification of bundled binaries** — checksums, provenance, whatever you want to trust. Don't hand-wave "we bundled it" without a verification story. -- **Cross-compilation toolchain** for the Monero binaries on CI (NDK for Android; whatever you use for TUI assets). This is heavier than a Rust-only CI. - ---- - -## 5. Proof criteria (done means these work) - -- **Local-node pipe works on TUI:** a spawned `monerod` child reaches a usable sync point; a spawned `monero-wallet-rpc` child pointed at it services `create_address`, `get_balance`, `get_transfers` through the existing `Wallet` client. -- **Receipt verification works end to end on the local path:** an incoming `rcp` frame verifies against the local daemon's `get_transfers` conjunctive match, and the UI reflects verified/unverified correctly. -- **Send/tip works end to end on the local path:** `/tip` (or the UI send path) calls the on-device wallet child's `transfer`, gets a txid, signs and sends `rcp` + `tip` one-shot, and the UI shows the result. -- **Remote-onion-daemon pipe works (where viable):** wallet child reaches a remote onion daemon through the chosen SOCKS path and the same wallet ops work; the app surfaces that the chain backend is remote over Tor. -- **Both backends go through the same wallet surface:** the app switches backend without the wallet ops or the payment frames changing shape. -- **Android lifecycle tolerance:** killing the app/daemon and resuming restarts the children and recovers wallet state from disk; the UI reflects daemon-not-running / not-synced states honestly. -- **Storage gate works on Android:** the local-node option is gated by free space vs the pruned target, with the number visible to the user; on a device that can't hold it, local node is off the table and the user gets remote daemon or receive-only. -- **Spend opt-in is honest:** view-only works out of the box; spend requires an explicit seed-backed wallet creation with the spend-authority warning shown. - ---- - -## 6. Documents that must change with the code - -- **`docs/WALLET.md`** — new backends (local pruned node, remote onion daemon), the SOCKS path for remote daemon, the wrapper model, spend opt-in, the prune-window history boundary, clearnet opt-in if kept. -- **`docs/THREAT_MODEL.md`** — local node on device (chain + wallet on device, spend key on device, device trust), remote onion daemon (host trust, Tor hides transport not host, daemon sees addresses), SOCKS path and what backs it, clearnet refusal and any explicit clearnet opt-in, Android lifecycle (process kills, daemon not always running), bundle trust (your binaries doing the work). -- **`docs/PROTOCOL.md`** — only if a payment frame changes. The `inv`/`rcp`/`tip` frames stay; don't touch the protocol doc just because the wallet backend changed. -- **`README.md`** — user-facing summary of the payment options (local node vs remote daemon, spend opt-in, storage/sync honesty) once the shapes are real. -- **Skill `onionwire`** — update if the locks/shape change (e.g. the wallet backend abstraction becomes a hard constraint, or the SOCKS path becomes a lock). Don't over-update; only when the rule actually changes. - ---- - -## 7. Out of scope for this plan (don't let them creep in) - -- Rewriting Monero in Rust, or embedding the C++ wallet library in-process unless a maintained Rust binding is clearly production-ready for full tx construction (it isn't, as of this write). The wrapper model is the intended shape. -- A full archiving node on mobile. Pruned is the on-device target; full node is not the mobile story. -- Making the wallet RPC speak clearnet by default. Clearnet daemon is an explicit opt-in if kept, not the design center. -- A server-side wallet or a hosted outbox. Still out of scope; the local outbox stays device-only. -- Changing the messenger's Noise / invite / on onion transport for payment. Payment frames are additive; the transport is unchanged. - ---- - -## 7a. Alternative: in-process Cuprate daemon (rust-dev exploration) - -A rust-dev card may explore baking a Monero chain daemon directly into the OnionWire binary via [Cuprate](https://github.com/Cuprate/cuprate)'s internal crates, instead of spawning `monerod` as a subprocess. This is an **exploration**, not a commitment. Key facts that decide whether it's viable: - -- **Cuprate crates are not published to crates.io** — every `cuprate-*` crate is a `0.0.0-placeholder` name reservation. Using them requires a git dependency on `https://github.com/Cuprate/cuprate` at a specific commit, pinning a pre-1.0 project. The root `Cargo.toml` declares no versions on workspace members (path deps only). -- **`cuprated`'s `Node::launch(config)` API** (`binaries/cuprated/src/lib.rs`) is the in-process entry point. It takes a `Config`, opens the database (fjall), starts consensus, P2P, RPC servers, and the sync loop. A `Node` handle is returned with `blockchain`, `txpool`, `clearnet`/`tor` network interfaces, and a `task_executor` for shutdown. This is a real embeddable API — not CLI-only. -- **Tor is already integrated** via `arti-client` (0.44), `tor-hsservice`, `tor-rtcompat` — the same crates OnionWire uses. Config has a `[tor]` section with `mode = Auto|Daemon|Arti` and onion service settings. OnionWire already uses `arti-client` 0.46, so a version-resolution conflict is a real risk. -- **Cuprate is pre-production** — the user book says `do NOT use cuprated for any serious purposes`. RPC parity with `monerod` is tracked in [issue #278](https://github.com/Cuprate/cuprate/issues/278) and is not complete. -- **No wallet layer in Cuprate.** Cuprate replaces only the `monerod` daemon (chain + P2P + consensus). `monero-wallet-rpc` is still required for wallet operations (`create_address`, `get_transfers`, `get_balance`, `transfer`). On Android, the wallet-rpc subprocess survives but the chain daemon is in-process — so the binary-spawning problem is **halved, not eliminated**. -- **Dependency bloat.** `cuprated`'s `Cargo.toml` pulls in `axum`, `hyper`, `tower-http`, `rayon`, `fjall`, `clap`, `tokio-socks`, plus RandomX and CryptoNight bindings. The combined dependency tree would significantly increase binary size and build time. `axum`/`hyper` are not currently in OnionWire's graph. -- **Database is fjall** (an embedded key-value store, not LMDB or SQLCipher), which means a separate chain data store alongside OnionWire's SQLCipher store. - -**Exploration card (confirmed feasible via cargo check):** - -- **`rust-dev`: Spike — embed `cuprated` (git dep) alongside `arti-client` 0.46, verify `Node::launch(Config).await` compiles and the documented usage (`node.blockchain.context().chain_height`) type-checks.** PROOF OF CONCEPT: `cargo check` passed (exit 0) with 575 packages; `arti-client` 0.44 (Cuprate) and 0.46 (OnionWire) coexisted. `cuprated::Node::launch(config: impl Into>) -> Result` is accessible. `Node` fields: `blockchain`, `txpool`, `clearnet`, `tor`, `config`, `task_executor`; implements `Drop` → `shutdown()`. Config is at `cuprated::config::Config`. See `references/cuprate-integration.md` for full test log. - -- **`rust-dev`: If spike passes, actually launch Node::launch on testnet/fakchain, verify sync starts and monerod-compatible JSON-RPC (get_info, get_height) responds with the chain data OnionWire needs for receipt verification.** PROOF: in-process launch on testnet works — `Node::launch` returns in ~2.8 s cold, the unrestricted RPC on `127.0.0.1:18089` answers `get_info` / `/get_height` / `get_block` (heights 0, 1, 2, 1000 all retrievable) with monerod-shaped payloads, and the node synced 0 → 23,758 testnet blocks in ~120 s over its own clearnet P2P. Four parity gaps are recorded (bare HTTP 500 on out-of-range `get_block`, `get_info` peer counts always 0, restricted `get_info` placeholder `database_size`/`version`, and the `0.1.0-preview` version label) in [docs/cuprate-launch-spike.md](cuprate-launch-spike.md). Verdict: Phased Phase 1 is viable, with those gaps handled before `monero-wallet-rpc` is pointed at it. -- **`rust-dev`: If launch spike passes, assess wallet gap.** Since Cuprate has no wallet layer, determine whether to (a) keep `monero-wallet-rpc` as a subprocess and point it at the in-process Cuprate daemon (halves Android binary spawning), or (b) also adopt `monero-oxide`/`monero-wallet` as an in-process wallet to eliminate all subprocesses. - -This card does **not** pre-empt the existing subprocess-based cards in §9 — those remain the default path until Cuprate proves itself in-process. - -**Strategic recommendation (hybrid phased approach):** - -- **Phase 1:** Use Cuprate in-process for the chain daemon (P2P + consensus + RandomX). Keep `monero-wallet-rpc` as a subprocess pointing at the in-process Cuprate node over localhost RPC. Cuprate's RPC mirrors `monerod`'s, so `monero-wallet-rpc` talks to it using the same JSON-RPC calls. This eliminates the ~52 MB `monerod` binary while preserving all wallet code. Binary overhead: +5.6 MB stripped. Android: bundle only `monero-wallet-rpc` (~4 MB/ABI) instead of both `monerod` (~52 MB) + `monero-wallet-rpc`. The Android cross-compile is **verified**: `cargo check --release --target aarch64-linux-android` exits 0 and the binary links as an Android 26 aarch64 ELF — env recipe and the required C++/builtins link args in [`cuprate-android-spike.md`](cuprate-android-spike.md). - -- **Phase 2 (future):** Only after Phase 1 is stable, consider replacing `monero-wallet-rpc` with the [`monero-wallet`](https://crates.io/crates/monero-wallet) crate (from the monero-oxide workspace). This is a transaction construction library, not a full wallet — replacing wallet-rpc requires reimplementing seed/key storage, address derivation, balance tracking, and output selection. Major effort. - ---- - -## 8. Key risks to flag in the card descriptions - -- **Arti SOCKS feasibility on Android** — backend 2 on Android depends on it. Verify before committing the Android remote-daemon path. -- **Pruned-node history boundary** — receipt verification and old-transfer queries past the prune window may degrade; state it and test it, don't let users assume infinite local history. -- **First sync as the UX cliff** — on both platforms, opting into a local node is signing up for a sync. On a phone it's a lot. Make it visible and controllable; don't pretend it's instant. -- **Android process kills** — the daemon and wallet child will be killed; design for restart-on-resume and honest "not running / not synced" states. -- **Bundle trust + binary maintenance** — the user runs your bundled binaries; keep the CI and verification story real, and keep the binaries current. -- **Spend-authority warning must be unavoidable at wallet creation** — a spend-capable wallet on device is a local spend authority; the warning isn't a tooltip, it's part of the create/restore flow. - ---- - -## 9. Suggested card titles for the kanban - -- `rust-dev`: Chain + wallet lifecycle abstraction (local node, remote onion daemon, clearnet opt-in) with shared wallet ops -- `rust-dev`: TUI wallet + node UI — create/restore, spend opt-in, balance, receive + QR, send/tip, daemon control, storage/sync honesty -- `rust-dev`: Wire local-node pipe on TUI (spawn monerod + wallet-rpc, prove create_address / get_balance / get_transfers through the existing Wallet client) -- `rust-dev`: Wire remote-onion-daemon path through SOCKS (wallet child --proxy + --daemon-address), prove the same wallet ops -- `apk-dev`: Bundle monero-wallet-rpc per Android ABI + subprocess lifecycle + wallet UI (wallet-in-binary, remote daemon via SOCKS) -- `apk-dev`: Bundle monerod per Android ABI + local-node opt-in with storage gate + sync controls (full on-device node) -- `apk-dev`: Android receive-address QR for wallet screen (separate from messenger invite QR) -- `ci`: Native binary build + bundle + verification pipeline for monerod and monero-wallet-rpc (TUI assets + Android ABIs) -- `rust-dev`: Spike — embed `cuprated` (git dep) alongside `arti-client` 0.46, verify `Node::launch(Config).await` compiles and the documented usage (`node.blockchain.context().chain_height`) type-checks** — PoC PASSED -- `rust-dev`: If spike passes, actually launch Node::launch on testnet/fakchain, verify sync starts and monerod-compatible JSON-RPC (get_info, get_height) responds -- `rust-dev`: If launch spike passes, assess wallet gap — keep `monero-wallet-rpc` subprocess (daemon in-process only) or also adopt `monero-oxide`/`monero-wallet` -- `docs`: Update WALLET.md + THREAT_MODEL.md for the new backends, SOCKS path, prune-window boundary, spend opt-in, Android lifecycle - -Cut releases manually and batched as the repo policy already requires — don't let a payment feature land push a release. CI for the native binaries is part of the work, not a follow-up. diff --git a/docs/tui-wallet-ux-review.md b/docs/tui-wallet-ux-review.md deleted file mode 100644 index 644ad76..0000000 --- a/docs/tui-wallet-ux-review.md +++ /dev/null @@ -1,1079 +0,0 @@ -# TUI wallet surfaces: presentation and flow review - -Audit of the wallet screens as they render at `a1f5c878` (main). Report only — -no source file was changed by this review. Frames below are the real render -path unless the caption says RECONSTRUCTED; see **Method** and **Not examined**. - -## Summary - -The two wallet screens the user is most likely to reach first are the two that -do not render: a fresh install opens on the create-spend-wallet confirmation, and -pressing `F6` on that install exits the process with a one-line error. At the -width where wallets are actually named — `F6` then `w` — the flow is good: a -designed empty state, a designed failed-read state, fixed columns measured in -terminal cells, and the create row always last. Two structural faults account for -most of what is wrong here: `draw_wallet` gives its body pane `Constraint::Length(2)` -inside a full border (so the wallet data is never drawn at any width), and -`draw_text_overlay` pins every long body to its **tail** (so the SPEND warning, -the seed, the offset notice and the help overlay all lose their first lines). -Everything below the crash is copy and ordering, not architecture. - -## Method - -* Widths are terminal **cells**, via `onionwire::tui::cell_width` (`Span::width`, - `src/tui.rs:3895`) — never `chars().count()`. The dump helper asserts - `cells <= width` on every row of every frame below. -* Sizes: 80x24 (floor), 120x40 (target), 200x60. A frame is shown at each width - where the behaviour differs. -* The F6 wallet screen and the setup overlays are private (`draw_wallet` - `src/tui.rs:5277`, `draw_wallet_setup` `src/tui.rs:5386`), so their frames are - **RECONSTRUCTED** by a scratch driver that copies the layout constants and the - copy from those two functions verbatim, and draws through the real public - `draw_text_overlay`. The card forbids changes under `tests/`, so this driver is - not committed; its source and the raw dump are attached to the task and the - follow-up should add them to `tests/tui_frames.rs` as labelled dumps. - Everything marked **REAL** calls the shipped public render path - (`draw_wallet_select`, `draw_wallets_settings`, `draw_text_overlay`, - `status_footer_phased`) with the same footers `App::draw` builds. -* Styling (colour, weight) does not appear in a text dump. Tone claims below are - read from the `style_*` call sites, and are labelled as such. - -## Frames - -### 1. First run — what a fresh install sees (`App::new`, `src/tui.rs:1387-1390`) - -`list_wallets()` returning empty selects `Screen::WalletSetup(WalletSetup::CreateWarn)`, -drawn by `draw_wallet_setup` (`src/tui.rs:5388-5394`) through `draw_text_overlay`. - - -**RECONSTRUCTED — first run, `create spend wallet`, 80x24, nothing typed** - -``` - - - - - - - - - - ┌create spend wallet─────────────────────────────────────────────────────────┐ - │trust. │ - │ │ - │Type SPEND to confirm Esc to cancel │ - └────────────────────────────────────────────────────────────────────────────┘ - - - - - - - - - - - -``` - - -At the floor the whole warning is one word: `trust.` The popup has three inner -rows and the body wraps to four, so `draw_text_overlay`'s -`scroll = wrapped - inner_h` (`src/tui.rs:3820`) drops the head — which is where -the sentence that says what this wallet can do lives. - -**RECONSTRUCTED — first run, 120x40, nothing typed** - - -``` - - - - - - - - - - - - - - - - - - ┌create spend wallet─────────────────────────────────────────────────────────────────────────────────────────────────┐ - │do not leave it on a box you do not trust. │ - │ │ - │Type SPEND to confirm Esc to cancel │ - └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - - - - - - - - - - - - - - - - - - - -``` - - -Still one sentence: `do not leave it on a box you do not trust.` - -**RECONSTRUCTED — first run, 200x60, nothing typed** - - -``` - - - - - - - - - - - - - - - - - - - - - - - - - - - - ┌create spend wallet────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ - │this wallet file can spend. anyone with its passphrase or the RPC creds can move the balance. write down the seed. do not leave it on a box you do not trust. │ - │ │ - │Type SPEND to confirm Esc to cancel │ - └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - - -The warning only reads in full at 200 columns, where it happens to fit one row. -Nothing in the frame says the install has no wallet, or that this screen is a -dead end other than `Esc`. - -**RECONSTRUCTED — first run, 80x24, `SPEN` typed (before the gate opens)** - - -``` - - - - - - - - - - ┌create spend wallet─────────────────────────────────────────────────────────┐ - │trust. │ - │ │ - │Type SPEND to confirm Esc to cancel │ - │SPEN │ - └────────────────────────────────────────────────────────────────────────────┘ - - - - - - - - - - -``` - - -The typed buffer is echoed one row lower, unlabelled: the frame shows `SPEN` with -no prompt saying what is being collected. Accepting the gate is -case-insensitive (`handle_wallet_setup`, `src/tui.rs:2440-2448`), so `spend` -works too, and the frames give no hint of that. - -### 2. The F6 wallet screen with nothing configured - -`open_wallet` (`src/tui.rs:2022-2033`) asks `Node::wallet_receive_address` first; -on an install with no profile `xmr` and no `ONIONWIRE_WALLET_RPC` that call -returns `Err("no receive address — set profile xmr or ONIONWIRE_WALLET_RPC")` -(`src/node.rs:1322`, `:1345`). The key handler propagates it -(`FunctionKey::Wallet => self.open_wallet()?`, `src/tui.rs:1504`), the event loop -propagates it (`run`, `src/tui.rs:1438`), and `main` prints and exits -(`src/main.rs:30`). **The screen below is therefore not reachable at HEAD** — it -is what the same function draws whenever the address read *does* succeed, which -is why it is shown: it is the frame a user gets on any install that has a wallet -configured. - -**RECONSTRUCTED — F6 wallet, unconfigured (address empty, balance `off`), 80x24** - - -``` -┌wallet────────────────────────────────────────────────────────────────────────┐ -└──────────────────────────────────────────────────────────────────────────────┘ - - - - - - - - - - - - - - - - -┌──────────────────────────────────────────────────────────────────────────────┐ -└──────────────────────────────────────────────────────────────────────────────┘ -s start child x stop child p probe c create i import r qr Esc back - - - - -``` - - -**RECONSTRUCTED — F6 wallet, unconfigured, 120x40** - - -``` -┌wallet────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -s start child x stop child p probe c create i import r qr Esc back - - - - -``` - - -**RECONSTRUCTED — F6 wallet, connected (address, balance and one transfer), 200x60** - - -``` -┌wallet────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -s start child x stop child p probe c create i import r qr Esc back - - - - -``` - - -All three frames are the same screen: an empty `wallet` title box, a blank field, -a second empty box, one help line. `draw_wallet` renders the body — `address`, -`balance`, `recent transfers` — into `cols[2]`, and the layout at -`src/tui.rs:5327-5333` gives `cols[2]` `Constraint::Length(2)`. With -`Borders::ALL` (`src/tui.rs:5379`) that is zero inner rows, so the paragraph is -never drawn: address, balance, transfers and the child line are all invisible, at -every size, configured or not. The `Min(4)` row and the trailing `Length(1)` row -are never rendered into. - -### 3. `F6` then `w` — the wallet list (REAL) - - -**REAL — `draw_wallet_select`, empty list (`WalletSelectState::from_rows(vec![])`), 80x24** - -``` -┌(o) wallets───────────────────────────────────────────────────────────────────┐ -│ no saved wallets yet │ -│ create one to get an identity and an onion address │ -│ │ -│ │ -│ │ -│ │ -│> + create new wallet │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -└──────────────────────────────────────────────────────────────────────────────┘ -✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back j k select Enter open ? help - -``` - - -The one row the card asks about is `> + create new wallet`, last, marked and -bold. The state above it is designed copy, not a blank pane. - -**REAL — `draw_wallet_select`, two saved wallets (one unlabelled, one unpublished), 120x40** - - -``` -┌(o) wallets · 2 saved─────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ name identity locator since │ -│> spend 9f2c41ab… abcdefgh… 2026-09-21 │ -│ (unlabelled) - - unknown │ -│ │ -│ id 9f2c41ab8d7e0f13a5b6c7d8e9f0a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2 │ -│ onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx │ -│ │ -│ + create new wallet │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -✓ TOR ready me:abcdef01… onion:abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion Enter open ? help - -``` - - -**REAL — `draw_wallet_select`, failed read (`WalletSelectState::error`), 80x24** - - -``` -┌(o) wallets───────────────────────────────────────────────────────────────────┐ -│ could not read saved wallets │ -│ no wallet store: database is locked by another process │ -│ │ -│ │ -│ │ -│ │ -│> + create new wallet │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -└──────────────────────────────────────────────────────────────────────────────┘ -✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back j k select Enter open ? help - -``` - - -**REAL — `draw_wallet_select`, read in flight (`WalletSelectState::reading()`), 80x24** - - -``` -┌(o) wallets───────────────────────────────────────────────────────────────────┐ -│ reading saved wallets │ -│ one moment │ -│ │ -│ │ -│ │ -│ │ -│> + create new wallet │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -└──────────────────────────────────────────────────────────────────────────────┘ -✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back j k select Enter open ? help - -``` - - -### 4. The create-spend-wallet warning frame - -The warning frame is frame 1: same function, same body, `src/tui.rs:5388-5394`. -Judged as a security gate at the moment of commitment: - -* **Unmissable**: yes. It owns the whole screen, the gate is a typed word, and - `SPEND` is stated on the frame (`Type SPEND to confirm Esc to cancel`). -* **A wall?** Only in the sense that its content is not readable: at 80x24 and - 120x40 the user confirms a warning they cannot see (finding 2). -* **The confirmation affordance**: the accepted word is on the frame, and the - typed echo is visible (`SPEN` above). It does not say the word is - case-insensitive, and it does not gate on the buffer being complete before - entering it — the transition fires on the last letter - (`src/tui.rs:2443`), which is the right behaviour for a typed gate. -* **Do not weaken it.** The warning text, the `type SPEND` gate, the seed's - `type SEEN` acknowledgement and the offset notice that `Esc` must not dismiss - (`handle_wallet_setup`, `src/tui.rs:2410-2415`) are deliberate. Finding 2 is a - rendering bug, not a request to shorten any of it. - -Supporting frame, same overlay idiom, same fault: - -**RECONSTRUCTED — `write down this seed`, 80x24 (25-word BIP39 test vector)** - - -``` - - - - - - - - - - ┌write down this seed────────────────────────────────────────────────────────┐ - │abandon abandon abandon abandon abandon abandon about │ - │ │ - │this is shown once. anyone with it can spend. │ - │Type SEEN when you have written it down │ - └────────────────────────────────────────────────────────────────────────────┘ - - - - - - - - - - -``` - - -Six words of twenty-five. The popup clips the seed to its last wrapped row. - -**RECONSTRUCTED — `write down this seed`, 200x60** - - -``` - - - - - - - - - - - - - - - - - - - - - - - - - - - - ┌write down this seed────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ - │about │ - │ │ - │this is shown once. anyone with it can spend. │ - │Type SEEN when you have written it down │ - └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - - - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - - -At 200 columns the seed is 197 cells and the popup's inner width is 196, so it -wraps to two rows, the box shows four, and the scroll drops row one: the frame -reads `about` alone. A user who writes down what they can see writes down one -word. Same mechanism at every width, for `import seed`, `seed offset passphrase` -and `offset not saved` (`src/tui.rs:5403-5441`). - -### 5. The F9 WALLETS & SETTINGS menu (REAL) - -`menu_groups` (`src/tui.rs:3970`) builds **seventeen** rows — nine under WALLET -(`endpoint`, `child`, `sync`, `receive`, `balance`, `transfers`, `payments`, -`create`, `import`) and eight under SETTINGS (`nickname`, `profile`, `identity`, -`colour`, `backup`, `restore`, `wipe`, `wipe-all`). The card's brief says eleven; -the tree says seventeen. - -**REAL — `draw_wallets_settings`, unconfigured, 80x24** - - -``` -┌(o) wallets & settings────────────────────────────────────────────────────────┐ -│WALLET ───────────────────────────────────────────────────────────────────────│ -│ endpoint not configured · receive-only │ -│ child receive-only · not started F6 s/x│ -│ sync not probing · no chain source F6 p│ -│ receive no address yet · wallet unreachable │ -│ balance off F6│ -│ transfers no transfers yet F6│ -│ payments no friend selected │ -│ create /wallet create · seed shown once F6 c│ -│ import /wallet import · 25-word seed F6 i│ -│ │ -│SETTINGS ─────────────────────────────────────────────────────────────────────│ -│ nickname (none) /profile│ -│ profile bio unset · xmr unset /profile│ -│ identity abcdef01… · identity = pubkey F2│ -│ colour auto · follows NO_COLOR / TERM │ -│ backup encrypted identity export /backup│ -│ restore overwrite self keys from a backup /restore│ -│ wipe messages · identity and friends stay /wipe│ -│ wipe-all deletes your identity key · new person /wipe-all│ -│ │ -└──────────────────────────────────────────────────────────────────────────────┘ -✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back c copy ? help - -``` - - -**REAL — `draw_wallets_settings`, configured and connected, 120x40** - - -``` -┌(o) wallets & settings────────────────────────────────────────────────────────────────────────────────────────────────┐ -│WALLET ───────────────────────────────────────────────────────────────────────────────────────────────────────────────│ -│ endpoint configured · connected │ -│ child local node · running F6 s/x│ -│ sync chain at tip · wallet answering F6 p│ -│ receive 4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYJKUGVktfzxayYmZreZ3Gvd1AAb1d1EU7oFyJX8… c copy F6 r│ -│ balance 12.500000000000 F6│ -│ transfers 3 recent F6│ -│ payments 4 with alice p│ -│ create /wallet create · seed shown once F6 c│ -│ import /wallet import · 25-word seed F6 i│ -│ │ -│SETTINGS ─────────────────────────────────────────────────────────────────────────────────────────────────────────────│ -│ nickname lance /profile│ -│ profile bio set · xmr set /profile│ -│ identity abcdef01… · identity = pubkey F2│ -│ colour auto · follows NO_COLOR / TERM │ -│ backup encrypted identity export /backup│ -│ restore overwrite self keys from a backup /restore│ -│ wipe messages · identity and friends stay /wipe│ -│ wipe-all deletes your identity key · new person /wipe-all│ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -✓ TOR ready me:abcdef01… onion:abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion Esc back c copy ? help - -``` - - -Scanning order is right: capability group first, then the identity/settings -group, with the wallet's own `transfers` and the peer-scoped `payments` kept -distinct and worded differently. Three rows carry no key at all (`endpoint`, -`receive` when empty, `colour`), and the value column truncates in cells with an -ellipsis so no row wraps or pushes its key off the row. - -### 6. Empty and error states - -Every distinct "nothing here yet" / "that failed" string the wallet surfaces can -render, and where it lands: - -| string | surface | tone | source | -|---|---|---|---| -| `no saved wallets yet` + `create one to get an identity and an onion address` | `F6`→`w`, no rows | dim | `src/tui.rs:5003-5007` | -| `could not read saved wallets` + the reason | `F6`→`w`, read failed | alert | `src/tui.rs:4990-4995` | -| `reading saved wallets` + `one moment` | `F6`→`w`, in flight | dim | `src/tui.rs:4996-5001` — unreachable, see finding 11 | -| `(none)` | `F6` body, no transfers | text | `src/tui.rs:5366` — never drawn, see finding 1 | -| `no address` | `F6` body, address empty | text | `src/tui.rs:5344` — never drawn | -| `(qr error)` | `F6`, QR modal | text | `src/tui.rs:5306` | -| `no transfers yet` | `F9`, `transfers` row | dim | `src/tui.rs:4042` | -| `no address yet · wallet unreachable` | `F9`, `receive` row | dim | `src/tui.rs:4018` | -| `off` | `F9`, `balance` row | dim | `src/node.rs:1092` | -| `err` | `F9`, `balance` row | alert | `src/node.rs:1096` | -| `not configured · receive-only` | `F9`, `endpoint` row | dim | `src/tui.rs:3972` | -| `configured · not connected` | `F9`, `endpoint` row | stale | `src/tui.rs:3976` | -| `child exited` | `F9`, `sync` row | alert | `src/tui.rs:4002` | -| `not probing · no chain source` | `F9`, `sync` row | dim | `src/tui.rs:4003` | -| `no friend selected` | `F9`, `payments` row / status note | dim / text | `src/tui.rs:4060`, `2106` | -| `history unreadable · ` | `F9`, `payments` row | — | `src/tui.rs:4064` | -| `no history with ` | `F9`, `payments` row | dim | `src/tui.rs:4065` | -| `-` (empty identity/locator cell) | `F6`→`w` row | dim | `src/tui.rs:5064-5079` | -| `(unlabelled)` (NULL name) | `F6`→`w` row | row style | `src/tui.rs:5056-5063` | -| `unknown` (no creation date) | `F6`→`w` row | dim | `src/tui.rs:4864` | -| `no receive address to copy` | status line, `c` on `F9` | text | `src/tui.rs:2216` | -| `could not write the clipboard sequence` | status line | text | `src/tui.rs:2227`, `:2247` | -| `no receive address — set profile xmr or ONIONWIRE_WALLET_RPC` | **process exit** | — | `src/node.rs:1322`, `:1345` | -| `the saved wallets changed — reopen the list` | `alert` | alert | `src/tui.rs:2187` | -| `wallet