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

@ -198,7 +198,17 @@ the app does not pick a public remote node for them.
- **Loopback** — same privacy as (1); the user owns `monerod`.
- **`.onion`** — chain traffic over Tor through a localhost SOCKS5 listener
the app provides for the wallet child (not the messenger’s Arti
`connect()`, and not a C-tor fallback for chat). Tor hides the transport.
`connect()`, and not a C-tor fallback for chat). That listener is the
bundled `arti` **binary** run as a child (`arti proxy -p <port>`) — a
second, separate Tor client with its own state and cache dirs, because
`arti-client` 0.46 exposes no SOCKS listener API. It is TCP loopback only
(`arti proxy -p` binds `127.0.0.1`/`::1`; arti 2.6.0 / `tor-config` 0.46
have no Unix-socket listen target — arti#1965), and the port is usable by
any local process at the user's privilege level: it is an app-private port,
not an access-controlled one. The app gates the spawn on the unlocked store
and waits ≤20s for the listener to accept before starting the wallet child,
so a dead proxy fails visibly instead of hanging. The SOCKS child stops
with the wallet child. Tor hides the transport.
The daemon operator still sees the wallet’s addresses during sync. The
host is the trust boundary.
- **Clearnet** — only if the user typed it. Not a default, not implied.
@ -228,7 +238,11 @@ That socket is the app talking to the wallet process, not to the chain.
**Chain** traffic is the wallet child’s connection to a Monero daemon. It is
off unless the user opted into a wallet and chose a chain source: spawned local
`monerod` (loopback), or a daemon address they entered. A `.onion` daemon is
reached through a localhost SOCKS5 proxy used only by that wallet child. A
reached through a localhost SOCKS5 proxy used only by that wallet child: the
bundled `arti` binary run as `arti proxy -p <port>`, whose `--proxy` target is
`127.0.0.1` and whose `.onion` name travels inside the SOCKS request (Monero's
SOCKS5 client sends the domain-name form, so no local DNS runs on it). The
messenger's in-process Arti client is never handed to the wallet child. A
clearnet daemon address is an explicit user choice — a clearnet socket they
asked for — not the messenger path and not a hidden default.

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 ==