monerod: spawn a pruned local monerod as the chain source #91

Closed
sirius wants to merge 2 commits from wt/t_4789c42f into main

2026-09-16

agent
monerod: fix the PATH-empty test and the wallet-child doc overclaim
All checks were successful
ci / test (pull_request) Successful in 4m56s
ci / sdk (pull_request) Successful in 1m9s
android-ci / android (pull_request) Successful in 8m35s
Review round 1 (artifact lens) on PR #91 found two defects.

1. `spawn_without_monerod_on_path_is_a_clear_error` passed
   `Some(OsStr::new(""))` as the search path. `std::env::split_paths("")`
   yields ONE empty element, so `find_in` probed the relative path
   `monerod` in the test's cwd and passed only because the crate root
   happened to hold no such file. Point it at an empty temp dir instead,
   which is what the card's "test by pointing PATH empty" asked for.
   Verified RED first: with an executable `./monerod` planted in the
   crate root, the old test fails
   ("spawn monerod: No such file or directory") and the new one passes
   with that same file still present.

2. The docs claimed a wiring the code does not perform:
   "The wallet child is pointed at that RPC with --daemon-address
   127.0.0.1:18089". Nothing points anything — `--daemon-address` exists
   in `src/` only inside comments, and `Node::monerod_rpc_addr()` has no
   caller. docs/WALLET.md now tells the operator to point their own
   wallet child at the loopback RPC and says the address is only exposed
   programmatically. The same overclaim in the `monerod_rpc_addr` doc
   comment in src/node.rs is corrected too.

Also one module-doc line for the non-blocking note: a port-liveness
check cannot tell whose port it is, so a pre-existing listener on 18089
yields Ok for a child that failed to bind.
2026-09-16 21:30:05 -04:00
agent
monerod: spawn a pruned local monerod as the chain source
All checks were successful
ci / test (pull_request) Successful in 5m6s
ci / sdk (pull_request) Successful in 1m18s
android-ci / android (pull_request) Successful in 8m32s
docs/WALLET.md §Chain source offered "spawn a local monerod (pruned
on-device)" but nothing implemented it. Add src/monerod.rs: find monerod
on PATH, mkdir $ONIONWIRE_HOME/monero at 0700, spawn it with
--prune-blockchain --non-interactive and its RPC bound to 127.0.0.1:18089,
poll the port for readiness, and stop it with SIGTERM (SIGKILL after 10s).

Locks held: loopback-only RPC, no --trusted-daemon, no SOCKS, no C-tor,
no clearnet default, no UDP, no new dependency (std only — SIGTERM goes
through kill(1) because the crate takes no libc). A missing binary or a
port that never answers is an Err the node logs and shrugs off: no local
chain is the honest state, not a crash.

Node wires it opt-in via ONIONWIRE_MONEROD=1: start_monerod spawns on a
blocking task during start_with_passphrase, shutdown() takes the daemon
and stops it off the reactor, and monerod_rpc_addr() reports where the
wallet child should point --daemon-address.

Tests (7, in-module): argv is pruned/loopback and carries no forbidden
flag; PATH lookup needs an executable; empty PATH and a missing binary
both Err with a clear message (and the data dir is 0700); default addr is
127.0.0.1:18089; wait_for_ready times out against a dead port; a fake
daemon spawns, reports its addr, and stops via SIGTERM (its pid is gone).
2026-09-16 21:00:28 -04:00