android: start/stop the monero-wallet-rpc child from WalletScreen, bundle the binary (issue #107) #109

Merged
sirius merged 1 commit from onionwire/t_87984328-android-start-stop-the-monero-wallet-rpc into main 2026-09-18 14:33:54 +00:00
Owner

Implements the Android half of issue #107. The Rust half landed as #108 (src/wallet_child.rs, start_wallet_child / stop_wallet_child / wallet_status / set_chain_source / chain_source over UniFFI), so this is based straight on main.

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 (516e5355a103a2bf0b7e10328ebcaa2945019445) via upstream's own contrib/depends + emitted toolchain.cmake, then stripped with the target's own strip.

bytes 19 954 224 (stripped; deflate-stored at 6.9 MB in the APK)
sha256 d9126788030ecd1ccdb40c7764e66e9a14d158a147ad335b256f0577681b5ad4
format ELF 64-bit LSB shared object, ARM aarch64, dynamically linked, interpreter /system/bin/linker64, for Android 21, built by NDK r17b
NEEDED libc.so, libm.so, libdl.so — everything else static

It ships through jniLibs rather than as an asset on purpose: since API 29 the kernel refuses exec() on a file in the app's own data directory (SELinux has no execute on app_data_file), 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" — app/build.gradle.kts now sets packaging.jniLibs.useLegacyPackaging = true, 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. android/MONERO_BINARIES.md records the four host quirks that cost the most time, because each one presents as something else:

  1. CMake must be 3.x — CMake 4 dropped the standalone-NDK-toolchain handling depends emits, silently falls back to host clang, and configure dies on libclang_rt.builtins.a.
  2. NDK r17b's prebuilt clang60 needs libtinfo.so.5; current distros ship ncurses 6 only. A shim directory on LD_LIBRARY_PATH fixes it.
  3. The generated toolchain.cmake puts the host /usr in CMAKE_FIND_ROOT_PATH, so find_library() returns host libraries. That gives /usr/lib/libpgm.so: error adding symbols: File in wrong format at the final link and a HAVE_HIDAPI define that makes src/device compile against host headers. The script pins CMAKE_FIND_ROOT_PATH to the depends prefix.
  4. The CMake target is wallet_rpc_server; monero-wallet-rpc is only the output name.

Not bit-reproducible — build paths and timestamps land in the binary. The sha256 is a provenance record of the shipped blob, not a reproducible-build assertion; that is stated in the doc.

CI re-verifies rather than trusting the blob. scripts/build-android-local.sh (which android-ci.yml and android-release.yml both call) checks android/monero-binaries.sha256 before Gradle, and after packaging pulls lib/<abi>/libmonerowalletrpc.so back out of the produced APK and compares its sha256 with the committed file. A mismatch fails the build.

arti is NOT bundled

WalletChild runs arti proxy as the SOCKS child for a .onion daemon and ChildConfig::validate requires a non-empty arti_bin. There is no arti executable here, and producing one means building a standalone arti bin for android — which needs Cargo.toml/crates/** changes that are outside this card.

So the app says so instead of pretending: arti_bin is set to the path the binary would occupy (<nativeLibraryDir>/libarti.so), which is inert for a loopback or clearnet daemon, and the screen refuses an .onion daemon while that file is absent, with the reason on screen. 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.

Today: loopback and clearnet daemons work; .onion daemons do not.

UI

WalletScreen gains a "wallet daemon" card above the existing Create / Import / Invoice / Tip actions, which are untouched (no removal, no reorder):

  • 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 wallet / Stop wallet calling start_wallet_child / stop_wallet_child through WireViewModel, on Dispatchers.IO (the spawn is synchronous inside the node and a .onion source waits up to 20s; 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, with the stored config prefilling the field;
  • 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 (mirroring the ChatRowInput/OutboxRowInput convention) and holds the state mapping, the status line and the Start/Stop gates; WalletChildStatusTextTest covers them on the JVM.

WireViewModel.kt is the known hotspot for the wallet cards — this touches only the wallet-child section and the wallet methods.

Verified

  • ./gradlew :app:testDebugUnitTest passes (new WalletChildStatusTextTest included).
  • 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 d9126788…, matching the committed blob, 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 to run it under 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 that plainly and lists the emulator steps to close the gap. The CI artifacts are the second half of the evidence.

Implements the Android half of issue #107. The Rust half landed as #108 (`src/wallet_child.rs`, `start_wallet_child` / `stop_wallet_child` / `wallet_status` / `set_chain_source` / `chain_source` over UniFFI), so this is based straight on `main`. ## 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** (`516e5355a103a2bf0b7e10328ebcaa2945019445`) via upstream's own `contrib/depends` + emitted `toolchain.cmake`, then stripped with the target's own strip. | | | |---|---| | bytes | 19 954 224 (stripped; deflate-stored at 6.9 MB in the APK) | | sha256 | `d9126788030ecd1ccdb40c7764e66e9a14d158a147ad335b256f0577681b5ad4` | | format | `ELF 64-bit LSB shared object, ARM aarch64, dynamically linked, interpreter /system/bin/linker64, for Android 21, built by NDK r17b` | | NEEDED | `libc.so`, `libm.so`, `libdl.so` — everything else static | It ships through `jniLibs` rather than as an asset on purpose: since API 29 the kernel refuses `exec()` on a file in the app's own data directory (SELinux has no `execute` on `app_data_file`), 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"` — `app/build.gradle.kts` now sets `packaging.jniLibs.useLegacyPackaging = true`, 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. `android/MONERO_BINARIES.md` records the four host quirks that cost the most time, because each one presents as something else: 1. CMake must be **3.x** — CMake 4 dropped the standalone-NDK-toolchain handling depends emits, silently falls back to host clang, and configure dies on `libclang_rt.builtins.a`. 2. NDK r17b's prebuilt `clang60` needs `libtinfo.so.5`; current distros ship ncurses 6 only. A shim directory on `LD_LIBRARY_PATH` fixes it. 3. The generated `toolchain.cmake` puts the **host** `/usr` in `CMAKE_FIND_ROOT_PATH`, so `find_library()` returns host libraries. That gives `/usr/lib/libpgm.so: error adding symbols: File in wrong format` at the final link and a `HAVE_HIDAPI` define that makes `src/device` compile against host headers. The script pins `CMAKE_FIND_ROOT_PATH` to the depends prefix. 4. The CMake target is `wallet_rpc_server`; `monero-wallet-rpc` is only the output name. Not bit-reproducible — build paths and timestamps land in the binary. The sha256 is a provenance record of the shipped blob, not a reproducible-build assertion; that is stated in the doc. **CI re-verifies rather than trusting the blob.** `scripts/build-android-local.sh` (which `android-ci.yml` and `android-release.yml` both call) checks `android/monero-binaries.sha256` before Gradle, and after packaging pulls `lib/<abi>/libmonerowalletrpc.so` back out of the produced APK and compares its sha256 with the committed file. A mismatch fails the build. ## `arti` is NOT bundled `WalletChild` runs `arti proxy` as the SOCKS child for a `.onion` daemon and `ChildConfig::validate` requires a non-empty `arti_bin`. There is no `arti` executable here, and producing one means building a standalone `arti` bin for android — which needs `Cargo.toml`/`crates/**` changes that are outside this card. So the app says so instead of pretending: `arti_bin` is set to the path the binary *would* occupy (`<nativeLibraryDir>/libarti.so`), which is inert for a loopback or clearnet daemon, and the screen refuses an `.onion` daemon while that file is absent, with the reason on screen. 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. Today: loopback and clearnet daemons work; `.onion` daemons do not. ## UI `WalletScreen` gains a "wallet daemon" card **above** the existing Create / Import / Invoice / Tip actions, which are untouched (no removal, no reorder): * 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 wallet** / **Stop wallet** calling `start_wallet_child` / `stop_wallet_child` through `WireViewModel`, on `Dispatchers.IO` (the spawn is synchronous inside the node and a `.onion` source waits up to 20s; 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, with the stored config prefilling the field; * 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 (mirroring the `ChatRowInput`/`OutboxRowInput` convention) and holds the state mapping, the status line and the Start/Stop gates; `WalletChildStatusTextTest` covers them on the JVM. `WireViewModel.kt` is the known hotspot for the wallet cards — this touches only the wallet-child section and the wallet methods. ## Verified * `./gradlew :app:testDebugUnitTest` passes (new `WalletChildStatusTextTest` included). * `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 `d9126788…`, matching the committed blob, 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 to run it under `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 that plainly and lists the emulator steps to close the gap. The CI artifacts are the second half of the evidence.
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
0134396588
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.
sirius merged commit 8ba1cf4c6c into main 2026-09-18 14:33:54 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!109
No description provided.