diff --git a/docs/WALLET.md b/docs/WALLET.md index eb3afd2..9b7f303 100644 --- a/docs/WALLET.md +++ b/docs/WALLET.md @@ -86,9 +86,12 @@ Set `ONIONWIRE_MONEROD=1` and the app starts the daemon itself — you do not ru `$ONIONWIRE_HOME/monero/` (mode 0700, never `/tmp` and never a shared location), and starts it with `--prune-blockchain --non-interactive`, its RPC bound to loopback only (`--rpc-bind-ip 127.0.0.1 --rpc-bind-port 18089`), logging to -`$ONIONWIRE_HOME/monero/monerod.log`. The wallet child is pointed at that RPC -with `--daemon-address 127.0.0.1:18089`; which process runs the wallet RPC (and -how it is started) is separate from this and unchanged. +`$ONIONWIRE_HOME/monero/monerod.log`. Point your wallet child at that RPC +yourself — `--daemon-address 127.0.0.1:18089`, exactly like the daemon address in +option 2 above. OnionWire does not configure the wallet child for you; the +address is only *exposed* to callers as `Node::monerod_rpc_addr()`, so a wallet +child left on its previous `--daemon-address` keeps using that one. Which process +runs the wallet RPC (and how it is started) is separate from this and unchanged. Zero trust is not optional here either: the spawn never passes `--trusted-daemon`, and the daemon's RPC is loopback so only this machine can diff --git a/src/monerod.rs b/src/monerod.rs index a6be2c3..803d18f 100644 --- a/src/monerod.rs +++ b/src/monerod.rs @@ -58,7 +58,10 @@ pub fn rpc_addr(port: u16) -> SocketAddr { /// /// A listening port is "ready enough": `monerod` binds RPC before it serves /// blocks, and the wallet child reports its own sync progress from there. We do -/// not speak HTTP ourselves. +/// not speak HTTP ourselves. Corollary: a port check cannot tell *whose* port it +/// is — if something already listens on `addr` (an operator's own `monerod`), +/// this returns `Ok` even though our child may have failed to bind. The +/// effective state is still "a local chain on loopback `addr`". pub fn wait_for_ready(addr: SocketAddr, timeout: Duration) -> Result<(), String> { let started = Instant::now(); loop { @@ -234,7 +237,6 @@ fn sigterm(pid: u32) -> bool { #[cfg(test)] mod tests { - use std::ffi::OsStr; use std::net::TcpListener; use std::os::unix::fs::PermissionsExt; use std::path::{Path, PathBuf}; @@ -326,7 +328,11 @@ mod tests { #[test] fn spawn_without_monerod_on_path_is_a_clear_error() { let dir = tempfile::tempdir().expect("tempdir"); - let empty = OsStr::new(""); + // The search path must be empty of `monerod`. `Some(OsStr::new(""))` is + // NOT that: `split_paths("")` yields one empty element, which `Path::join` + // resolves to `./monerod` in the test's cwd (so a `monerod` sitting in the + // crate root would be found). Point at an empty directory instead. + let empty = dir.path().as_os_str(); let err = match Monerod::spawn_with_path(dir.path(), Some(empty)) { Ok(_) => panic!("no monerod on PATH"), Err(e) => e, diff --git a/src/node.rs b/src/node.rs index b2ff2b9..c9e0392 100644 --- a/src/node.rs +++ b/src/node.rs @@ -278,8 +278,9 @@ impl Node { } /// Where the spawned local chain source listens, if this node started one - /// (`ONIONWIRE_MONEROD=1`). This is what the wallet child is pointed at - /// with `--daemon-address`; `None` means no local chain. + /// (`ONIONWIRE_MONEROD=1`). Exposed so a caller can point the wallet child + /// here with `--daemon-address`; the node does not wire that up itself. + /// `None` means no local chain. pub fn monerod_rpc_addr(&self) -> Option { self.monerod .lock()