Commit graph onionwire/android/MONERO_BINARIES.md
Author SHA1 Message Date
agent
e2c77da6bc
docs(android): rewrite Android docs to match the tree
android/README.md, CUPRATE_DAEMON.md and MONERO_BINARIES.md were the
half PR #133 left out. Releases are two manual dispatches, not a push
to main; the APK version comes from the tag android-release checks out;
the layout now includes wallet/ and keepalive/; the status line's
sync h/t is documented; the APK poller still calls wallet_status, not
wallet_child_refresh.
2026-09-20 00:54:27 -04:00
sirius
e6b6bc8dd6
android: build the SDK with cuprate-daemon and offer the on-device node
Part 3 of "cuprated built in": the chain daemon now ships inside the APK and the
wallet screen can pick it.

Build (android/sdk/build.gradle.kts)
- `cargoBuildAndroid` runs `cargo ndk … build --release --lib --features
  cuprate-daemon`. The Android target only: `cargoHostLib` / `uniffiBindgen` stay
  feature-free, because the host cdylib exists only so `uniffi-bindgen --library`
  can dlopen it and the UniFFI surface does not fork on a cargo feature.
- The link needs the NDK's libc++ and compiler-rt builtins explicitly (RandomX is
  C++ and its aarch64 JIT calls `__clear_cache`; `randomx-rs` links the NDK's stub
  `libstdc++.a`). `cargo ndk --link-builtins` covers the builtins only, so the
  whole set is spelled out as per-ABI `CARGO_TARGET_<TRIPLE>_RUSTFLAGS` — a global
  `RUSTFLAGS` would break the host build scripts. The linker is the NDK clang
  driver at the app's API level, named explicitly, because the dev machines pin
  the API 21 wrapper for `aarch64-linux-android` and API 21 fails this link.
- `ANDROID_NDK` is exported alongside `ANDROID_NDK_HOME`/`NDK_HOME`: without it
  `cmake-rs` aborts and `randomx-rs`'s build script panics.
- The task logs the feature it builds with, so CI carries the request, not just
  the task name.

Wallet screen
- Third chain source, **On-device node (Cuprate)**, beside the daemon field and
  Receive-only. Stored as `ChainChoice.InProcessCuprate` with an empty
  `monerod_datadir`, which the SDK resolves to `$ONIONWIRE_HOME/chain`. Existing
  Save daemon / Receive-only / Start / Stop behaviour is unchanged.
- The status line grows `· node <word>` from `WalletChildStatus.node_state` for
  this source only, fail-closed on an unrecognised word. No sync height: the SDK
  exposes none, so the screen does not show a number it cannot get.
- Storage honesty: free space on the chain store's filesystem, and Start is
  refused below a 3 GiB floor or when that filesystem cannot be read. The floor is
  a floor, not a sync estimate — nothing here exposes one.
- The pre-production warning (quoted user book, testnet only, Cuprate issue #278)
  is a sentence above Start, assertable in a test. Opt-in, never a default.
- The daemon field's hint no longer suggests a loopback daemon on the phone.

CI
- `android-ci.yml` extracts `lib/<abi>/libonionwire_sdk.so` from the built APK and
  fails the job unless it contains `target_max_memory`, a rodata literal compiled
  only under `cuprate-daemon`. v0.7.0's shipped `.so` has zero of them, so this
  separates "in the artifact" from "requested".

Docs
- `android/CUPRATE_DAEMON.md`: the build wiring, the link line, the CI gate, and
  an explicit "not verified on a device" section. `MONERO_BINARIES.md` points at
  it for the chain source that is not a binary.
2026-09-18 17:16:05 -04:00
apk-dev
0134396588
android: start/stop the monero-wallet-rpc child from WalletScreen, bundle the binary
All checks were successful
android-ci / android (pull_request) Successful in 8m59s
Implements the Android half of issue #107. Stacked on `wt/t_8a8ff353`
(PR #108) because the UniFFI wallet-child surface is not on `main` yet.

Binary
------

`android/app/src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so` is a real
`monero-wallet-rpc` cross-compiled for `aarch64-linux-android` from
monero-project/monero v0.18.4.4 (516e5355) via upstream's own
`contrib/depends` + toolchain.cmake path, then stripped with the target's own
strip. 19 954 224 bytes, sha256
d9126788030ecd1ccdb40c7764e66e9a14d158a147ad335b256f0577681b5ad4.

It ships through `jniLibs` and not as an asset on purpose: since API 29 the
kernel refuses `exec()` on a file in the app's data directory, so the only
executable directory an app has is `applicationInfo.nativeLibraryDir`, which
the package manager fills from `lib/<abi>/` at install time. That requires
`android:extractNativeLibs="true"` (`packaging.jniLibs.useLegacyPackaging`),
which `app/build.gradle.kts` now sets, plus `keepDebugSymbols` for this one
entry so AGP's strip pass cannot rewrite the bytes CI verifies.

`scripts/build-monero-wallet-rpc-android.sh` reproduces the build and
`android/MONERO_BINARIES.md` records the four host quirks that cost the most
time (CMake must be 3.x; NDK r17b clang60 needs a libtinfo.so.5 shim; the
generated toolchain.cmake puts the HOST `/usr` in CMAKE_FIND_ROOT_PATH, which
breaks the link with a host libpgm.so and defines HAVE_HIDAPI against host
headers; the CMake target is `wallet_rpc_server`, not `monero-wallet-rpc`).

CI re-verifies the blob rather than taking it on trust:
`scripts/build-android-local.sh` checks `android/monero-binaries.sha256` before
Gradle, and after packaging pulls `lib/<abi>/libmonerowalletrpc.so` back out of
the APK and compares its sha256 with the committed file.

`arti` is NOT bundled, so a `.onion` daemon cannot be started yet. The app says
that instead of pretending: `arti_bin` is set to the path the binary would
occupy, and the screen refuses an `.onion` daemon while it is absent.
Loopback and clearnet daemons work.

UI
--

`WalletScreen` gains a "wallet daemon" card above the existing
Create / Import / Invoice / Tip actions, which are untouched:

* a status line from `Wire::wallet_status()` rendered verbatim —
  `off` / `connecting` / `syncing` / `ready` / `exited` plus the core's
  chain-source label (`receive-only` / `local node` / `remote onion daemon` /
  `remote daemon`). A died child reads `exited`; it is never folded into `off`
  and never into `ready`;
* Start / Stop calling `start_wallet_child` / `stop_wallet_child` through
  `WireViewModel`, on `Dispatchers.IO` (the spawn is synchronous inside the node
  and the status read re-decrypts the sealed record);
* a `host:port` field that saves a remote daemon via `set_chain_source`, plus a
  Receive-only button;
* honest failure states instead of a spinner: no bundled binary, no chain
  source, a `.onion` daemon with no arti, or a start that failed — each gets its
  own sentence, and Start is disabled with the reason on screen.

`WireViewModel` owns the 2s wallet-child poller, the same way it owns the chat
poller, so leaving the wallet screen and coming back cannot stack a second loop.
`ui/WalletChildStatusText.kt` is the pure model (mirrors the
`ChatRowInput`/`OutboxRowInput` convention) and carries the state mapping, the
status line and the Start/Stop gates; `WalletChildStatusTextTest` covers them on
the JVM.

Verified
--------

`./gradlew :app:testDebugUnitTest` passes, `scripts/build-android-local.sh`
produces `dist/onionwire-0.1.0-android-arm64-v8a.apk` (27 884 277 bytes,
versionName 0.1.0 / versionCode 100) with
`lib/arm64-v8a/libmonerowalletrpc.so` inside it at the committed sha256, and
`extractNativeLibs="true"` in the merged release manifest.

NOT verified: the binary was never executed. The build host has no arm64-v8a
AVD (all three existing AVDs are x86_64) and no aarch64 sysroot for qemu-user,
so nothing here proves `monero-wallet-rpc` starts, opens its wallet file and
answers JSON-RPC under Android's runtime. `android/MONERO_BINARIES.md` says so
plainly and lists the emulator steps to close the gap.
2026-09-18 10:20:08 -04:00