chore: wallet child lifecycle + chain source + SOCKS proxy (t_1bcecf90)

This commit is contained in:
agent 2026-09-15 01:40:12 -04:00
commit 11a021acb3
No known key found for this signature in database
3 changed files with 652 additions and 28 deletions

View file

@ -33,6 +33,8 @@ export an env var:
- **`monerod`** is spawned too when the chain source is *local*:
`--non-interactive --data-dir <datadir> --rpc-bind-ip 127.0.0.1 --rpc-bind-port
18081`. One box, one daemon: the wallet child dials it at `127.0.0.1:18081`.
- **`arti`** is spawned as a SOCKS child only when the chain source is a
`.onion` daemon: `arti proxy -p <port>` (see below).
- `--trusted-daemon` is never passed. A remote daemon stays untrusted.
- The wallet dir is created `0700` and the wallet file is kept `0600` — it is a
spend authority.
@ -67,14 +69,58 @@ ChainSource::Remote { host, port } a daemon address you typed
sync, and (on Android) the daemon not always running.
2. **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 — that needs a SOCKS proxy for the wallet child and is **not
implemented here**: configuring a `.onion` host today fails with a clear error
instead of silently dialling clearnet. Clearnet only if you type it — your ISP
sees Monero-node traffic; it is never a default.
traffic over Tor (see *Chain traffic over Tor* below). Clearnet only if you
type it — your ISP sees Monero-node traffic; it is never a default.
The port is a convention, not a constant: restricted RPC on `18089` is common,
but you supply it.
### Chain traffic over Tor (`.onion` daemons)
A `.onion` daemon cannot be dialled directly, and OnionWire does not fall back
to a clearnet resolve. The wallet child is an external C++ binary, so it reaches
Tor the only way it can: through a SOCKS proxy the app provides.
- The app runs the **bundled `arti` binary** as a child:
`arti proxy -p <random free loopback port>`. `arti-client` 0.46 has no SOCKS
listener API — the SOCKS listener lives in the `arti` *binary* — so this is a
second, separate Tor client, not the messenger's in-process one. There is no
C-tor and no system `tor`.
- The listener is **TCP loopback only**. `arti proxy -p <port>` binds localhost
(`127.0.0.1` and `::1`) and nothing else, and there is nothing safer to
prefer: `arti` 2.6.0 / `tor-config` 0.46 have no Unix-socket listen target
(`Listen` is IP-only; arti's own port record calls AF_UNIX future work,
arti#1965). The port is app-private in practice, but any local process with
user-level access can also use it — that is the honest statement of the
boundary, not a claim of access control.
- The wallet child is then spawned with
`--proxy socks5://127.0.0.1:<port>` **and** `--daemon-address <onion>:<port>`.
The `socks5://` scheme is explicit: Monero's `--proxy` defaults to SOCKS4a for
a bare `host:port` (`docs/proxies.md` in the Monero tree). The `.onion` name
goes to the proxy inside the SOCKS request — Monero's SOCKS5 client uses the
domain-name form — so **no local DNS** runs on the onion target.
- The SOCKS child gets **its own state and cache dirs**
(`$ONIONWIRE_HOME/wallet/arti-socks/{state,cache}`). The messenger's Arti
state is not shared with it.
- Starting it is gated on the same credential material as everything else: the
SOCKS child is only spawned from `WalletChild::start(&store)`, which needs the
already-unlocked store.
- The app waits **up to 20s** for the SOCKS listener to accept a connection
before it spawns the wallet child. A dead proxy is a visible error, not a
wallet screen that hangs dialling a daemon. Arti binds its listener before it
bootstraps, so this is a listener check, not a Tor-bootstrap check.
- The SOCKS child stops with the wallet child; a killed wallet child leaves no
orphaned listener behind.
**Tor hides the transport, not the host.** The daemon operator still sees the
wallet's addresses (and the transaction set it is scanning) during sync. A
`.onion` address protects the path between you and that operator, nothing more.
The TUI copy for a chain source says this in one line
(`WalletChild::chain_copy`): `.onion` → "over Tor … the daemon operator still
sees your addresses during sync"; clearnet → "the daemon operator and your ISP
see the traffic".
### Readiness, and why it is not a guess
`chain_ready()` asks the wallet RPC `get_info` and requires **`synchronized ==