docs: rewrite README and living docs to match the tree
Audit the operator docs against the source: pin downloads to v0.14.0, document the real CLI/flags/env/F-keys (including F9, no F7), keep 18081 as the app-owned daemon port, describe the local chat outbox vs a server-side one, and stop implying SECURITY_AUDIT.md is a third-party audit. Spike reports stay; they get a status header only.
This commit is contained in:
parent
db12f4838b
commit
f95c1e7ca7
14 changed files with 664 additions and 1649 deletions
600
docs/WALLET.md
600
docs/WALLET.md
|
|
@ -8,405 +8,214 @@ receipt checks (`get_transfers`). `/tip` is off.
|
|||
|
||||
**Spend is opt-in** at wallet create or restore (seed-backed). That makes
|
||||
OnionWire a local spend authority for that wallet file — see the spend-authority
|
||||
warning below. The threat-model write-up is [THREAT_MODEL.md](THREAT_MODEL.md).
|
||||
warning below. Threat model: [THREAT_MODEL.md](THREAT_MODEL.md). TUI keys:
|
||||
[TUI.md](TUI.md).
|
||||
|
||||
The app talks to `monero-wallet-rpc` over loopback HTTP Digest only, and it can
|
||||
own that process itself:
|
||||
The app talks to `monero-wallet-rpc` over **loopback HTTP Digest only**, and it
|
||||
can own that process itself:
|
||||
|
||||
- hand out a receive subaddress for `/pay` invoices (`create_address`),
|
||||
- read incoming transfers to verify a peer's receipt (`get_transfers`),
|
||||
- and — only if you opted into spend — `/tip` (`transfer`).
|
||||
|
||||
**Prefer view-only until you actually want `/tip`.** Everything else in this
|
||||
document explains why, and what breaks when you do.
|
||||
**Prefer view-only until you actually want `/tip`.**
|
||||
|
||||
Wallet RPC is never on clearnet and never over `.onion`. Chain traffic is off
|
||||
unless you opted into a wallet and chose a source. A remote daemon is untrusted
|
||||
(`--trusted-daemon` is never passed).
|
||||
|
||||
## Ports (do not swap these)
|
||||
|
||||
| Port | What it is |
|
||||
|---|---|
|
||||
| **18081** | App-owned **local** daemon unrestricted RPC (`DEFAULT_MONEROD_RPC_PORT` in `src/wallet_child.rs`). Spawned `monerod` and in-process Cuprate both bind `127.0.0.1:18081`. The wallet child dials that. |
|
||||
| **18089** | A daemon's *restricted*-RPC port. It belongs only in examples of a **remote** `--daemon-address` you type. Not the app-owned local port. |
|
||||
| random loopback | App-owned `monero-wallet-rpc` bind (`127.0.0.1:0`, then the port is kept). |
|
||||
|
||||
A doc or config that puts the local child on 18089 is wrong.
|
||||
|
||||
## The app-owned wallet child
|
||||
|
||||
`src/wallet_child.rs` owns the child pair instead of asking you to start it and
|
||||
export an env var:
|
||||
`src/wallet_child.rs` owns the child pair instead of asking you to export an
|
||||
env var:
|
||||
|
||||
- **`monero-wallet-rpc`** is spawned with `--rpc-bind-ip 127.0.0.1`, a **random
|
||||
free loopback port** (bind `127.0.0.1:0`, read the port, drop the listener, pass
|
||||
it on — two instances on one box cannot collide), a generated `--rpc-login`
|
||||
(`user:pass`, random `[a-z0-9]`, no shell or HTTP metacharacters), and
|
||||
`--wallet-dir $ONIONWIRE_HOME/wallet`.
|
||||
- **`monerod`** is spawned too when the chain source is *local*:
|
||||
free loopback port**, a generated `--rpc-login` (`user:pass`, random
|
||||
`[a-z0-9]`), and `--wallet-dir $ONIONWIRE_HOME/wallet`.
|
||||
- **`monerod`** is spawned 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`.
|
||||
18081`. The wallet child dials `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.
|
||||
- The child is watched by polling (`try_wait`); an exit is reported rather than
|
||||
hidden, and `stop()` kills both children on shutdown. The next launch starts
|
||||
them again. Nothing promises "always running", and Android will not.
|
||||
`.onion` daemon: `arti proxy -p <port>`.
|
||||
- `--trusted-daemon` is never passed.
|
||||
- Wallet dir `0700`, wallet file `0600`.
|
||||
- The child is watched by polling (`try_wait`). `stop()` kills children on
|
||||
shutdown. Nothing promises “always running”, and Android will not.
|
||||
|
||||
### Where the RPC credentials live
|
||||
Generated `user:pass` is sealed with the store data key in the SQLCipher
|
||||
`wallet_child` table. It never appears in `ONIONWIRE_WALLET_RPC`.
|
||||
|
||||
The generated `user:pass` is **sealed with the store data key and kept in the
|
||||
encrypted SQLCipher store** (`wallet_child` table, AEAD with the store key on top
|
||||
of whole-db encryption). It is never written to a plaintext file next to the
|
||||
wallet, and it never appears in `ONIONWIRE_WALLET_RPC`. They persist across
|
||||
launches, so the child restarts with the same login without asking you again.
|
||||
The wallet passphrase for `create_wallet` / `restore_deterministic_wallet` is
|
||||
your runtime choice, not stored by the app.
|
||||
|
||||
The wallet passphrase is a separate thing: the child prompts/needs it for
|
||||
`create_wallet` / `restore_deterministic_wallet`, and that is your runtime choice,
|
||||
not something the app stores for you.
|
||||
Nothing spawns the child at boot. `Node::start_wallet_child` is the only start
|
||||
path. The desktop TUI drives it from `F6`:
|
||||
|
||||
| Key | Effect |
|
||||
|---|---|
|
||||
| `s` | Start the child, then probe it once. |
|
||||
| `x` | Stop it (idempotent). |
|
||||
| `p` | Probe: is wallet RPC answering, is the chain at the tip? |
|
||||
| `1` / `2` / `3` | Store in-process Cuprate as mainnet-pruned / mainnet-full / testnet. |
|
||||
|
||||
State shown: `off` / `connecting` / `syncing` / `ready` / `exited`, plus a
|
||||
chain-source label. `ready` is never reported for a child that has died.
|
||||
|
||||
Once a probe has read the daemon, the line can include `sync <height>/<target>`
|
||||
— the **daemon's** height and the tip it is syncing towards (wallet RPC
|
||||
`get_info`, or the local daemon's `get_info` when wallet RPC does not answer).
|
||||
`sync 0/0` or no segment means **unknown**, not caught up.
|
||||
|
||||
`start` is idempotent: a live child is reported, not respawned.
|
||||
|
||||
## Chain source
|
||||
|
||||
The wallet needs a daemon for scan, verify, and spend. You pick one; OnionWire
|
||||
does not pick a public remote node for you. The four shapes are:
|
||||
You pick one. OnionWire does not pick a public remote node for you.
|
||||
|
||||
```
|
||||
ChainSource::None receive-only; no child, no daemon
|
||||
ChainSource::Local { monerod_bin, datadir } the app spawns monerod on this box
|
||||
ChainSource::InProcessCuprate { datadir } the daemon is inside this app
|
||||
ChainSource::Local { monerod_bin, datadir } spawn monerod on this box (port 18081)
|
||||
ChainSource::InProcessCuprate { datadir, … } daemon inside this app (port 18081)
|
||||
ChainSource::Remote { host, port } a daemon address you typed
|
||||
```
|
||||
|
||||
1. **Local `monerod`.** Chain traffic stays on the box. You accept disk, first
|
||||
sync, and (on Android) the daemon not always running.
|
||||
2. **An in-process daemon** ([Cuprate](https://github.com/Cuprate/cuprate)
|
||||
running inside the OnionWire process). No `monerod` binary to install or
|
||||
spawn, chain on this device, and the wallet child dials the same loopback
|
||||
port. **Testnet only** in this build, and it needs the `cuprate-daemon`
|
||||
feature — see *The in-process chain daemon* below.
|
||||
1. **Local `monerod`.** Chain traffic stays on the box.
|
||||
2. **In-process Cuprate.** No `monerod` binary. Wallet child still dials
|
||||
`127.0.0.1:18081`. See below.
|
||||
3. **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 (see *Chain traffic over Tor* below). Clearnet only if you
|
||||
type it — your ISP sees Monero-node traffic; it is never a default.
|
||||
traffic over Tor. Clearnet only if you type it — never a default. Restricted
|
||||
RPC on `18089` is a common remote example, but you supply the port.
|
||||
|
||||
The port is a convention, not a constant: restricted RPC on `18089` is common,
|
||||
but you supply it.
|
||||
Settings live in the sealed `wallet_child` record (`ChildConfig`: `source`,
|
||||
`wallet_rpc_bin`, `arti_bin`, `wallet_filename`). Core:
|
||||
`Node::wallet_child_config` / `set_wallet_child_config`, then
|
||||
`start_wallet_child` / `stop_wallet_child` / `wallet_child_status` /
|
||||
`wallet_child_refresh`.
|
||||
|
||||
### The in-process chain daemon (`cuprate-daemon`)
|
||||
|
||||
Cuprate's chain daemon — P2P, consensus, RandomX — can run **inside the
|
||||
OnionWire process** instead of as a spawned `monerod`. The wallet layer does not
|
||||
change: `monero-wallet-rpc` is still a child, and it still dials the unrestricted
|
||||
loopback RPC, `127.0.0.1:18081`, the same address a spawned `monerod` gets.
|
||||
|
||||
```
|
||||
cargo build --release --features cuprate-daemon
|
||||
```
|
||||
|
||||
- **Off by default.** `cuprated` is pre-1.0 and is not published to crates.io
|
||||
(every Cuprate crate there is a `0.0.0-placeholder` name reservation), so it is
|
||||
a git dependency pinned to a revision, behind the `cuprate-daemon` feature. A
|
||||
default build does not compile it: the graph is large (RandomX, fjall,
|
||||
axum/hyper, rayon) and it is a *choice*, never compiled-in. Without the feature
|
||||
a stored in-process chain source can still be read back — the chain-source type
|
||||
and its record do not fork on a cargo feature — but starting it fails with
|
||||
`this build has no in-process chain daemon — rebuild with --features
|
||||
cuprate-daemon`.
|
||||
- **+11.8 MiB (12,327,768 bytes)** on a stripped `aarch64-linux-android` release
|
||||
binary, measured in this repo: 24,725,704 bytes without the feature and
|
||||
37,053,472 with it (`cargo rustc --release --target aarch64-linux-android
|
||||
[--features cuprate-daemon] --bin onionwire`, both linked with the NDK C++
|
||||
runtime / compiler-rt link args, then `llvm-strip`). The `+5.6 MB` figure that
|
||||
circulated with the spike was an estimate and understates it. A cold build
|
||||
also compiles the Cuprate graph in addition to this crate's own, so first-build
|
||||
time grows accordingly.
|
||||
- **Testnet only.** Cuprate is **pre-production software**. Its own user book
|
||||
says *"do NOT use cuprated for any serious purposes"*, and its `monerod` RPC
|
||||
parity is incomplete (Cuprate issue #278; the four gaps measured in this repo
|
||||
are in `docs/cuprate-launch-spike.md` §Parity gaps). The config pins
|
||||
`network = "Testnet"`; pointing a mainnet wallet at it is not something this
|
||||
build claims to do. The wallet screen's chain line says so next to the source
|
||||
(`testnet only — mainnet is unvalidated`).
|
||||
- **No Tor in the chain path.** Cuprate's own `arti` feature is *not* enabled:
|
||||
its Tor stack is `arti-client` 0.44, which cannot unify with this crate's 0.46,
|
||||
and running two Tor stacks in one process is not a trade this app makes.
|
||||
OnionWire's Arti is the only Tor here, and it serves the messenger. The
|
||||
in-process daemon's P2P traffic is therefore **clearnet**: your ISP can see
|
||||
that this device talks to Monero testnet peers, exactly as a spawned `monerod`
|
||||
would.
|
||||
- **Inbound connections are off** and the restricted RPC listener is disabled:
|
||||
this is a wallet's daemon, not a public node (the restricted listener only
|
||||
answers placeholder metrics — see below).
|
||||
- **It is not a child process.** There is no pid to watch or signal: the node is
|
||||
a value the app owns, and dropping it shuts the daemon down. `stop` (TUI key
|
||||
`x`, or the SDK's `stop_wallet_child`) asks it to shut down with the wallet
|
||||
child, and it does not outlive the app.
|
||||
- **The chain lives in `$ONIONWIRE_HOME/chain`** — the same per-identity
|
||||
directory a spawned `monerod` would use, so the two local sources are
|
||||
interchangeable on disk. It is created `0700`. The chain database itself is
|
||||
**fjall**, a separate embedded store from OnionWire's SQLCipher file:
|
||||
Cuprate puts it under the datadir it is given (`<datadir>/testnet/fjall`), so
|
||||
it is never beside `onionwire.db`.
|
||||
- **Selecting it.** The chain source is a stored setting (`ChildConfig`), and
|
||||
this build has no on-screen chain-source picker on the desktop TUI — that is
|
||||
true of the other three sources too; the picker is a separate, unmerged piece
|
||||
of work. What selects this source today is a `ChainSource::InProcessCuprate`
|
||||
record with a `datadir` written through `Node::set_wallet_child_config` (the
|
||||
SDK's `ChainConfig` path), and the daemon then starts with the child when the
|
||||
wallet is started. The SDK's `ChainChoice.InProcessCuprate` is that variant
|
||||
over UniFFI, and `kind = "cuprate"` is the record's spelling.
|
||||
- **Off by default.** `cuprated` is pre-1.0, not on crates.io (placeholder
|
||||
crates), git-pinned, behind the feature. Without the feature, a stored
|
||||
in-process source can still be read back, but start fails with
|
||||
`this build has no in-process chain daemon — rebuild with --features cuprate-daemon`.
|
||||
- **Pre-production.** Cuprate's own user book says do not use `cuprated` for
|
||||
serious purposes. RPC parity is incomplete (`docs/cuprate-launch-spike.md`).
|
||||
- **Mainnet is unvalidated.** The TUI can store mainnet-pruned (`F6` `1`) or
|
||||
mainnet-full (`F6` `2`) or testnet (`F6` `3`). Every in-process surface still
|
||||
prints `testnet only — mainnet is unvalidated` (`cuprate::TESTNET_ONLY`).
|
||||
Cross-compiled is not device-proven. Pointing a mainnet wallet at it is not
|
||||
something this build claims to do.
|
||||
- **No Tor on the chain path.** Cuprate's `arti` feature is off (arti-client
|
||||
0.44 vs this crate's 0.46). P2P is **clearnet**. OnionWire's Arti is the
|
||||
messenger only.
|
||||
- **Inbound P2P off**, restricted RPC listener disabled. Unrestricted RPC is
|
||||
loopback 18081. `--trusted-daemon` still never passed.
|
||||
- Chain lives under `$ONIONWIRE_HOME/chain/…` (split dirs so pruned mainnet
|
||||
cannot mix with full). Database is **fjall**, not SQLCipher.
|
||||
- Not a child process: dropping the node shuts it down. `x` / `stop_wallet_child`
|
||||
asks it to stop with the wallet child.
|
||||
|
||||
### 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.
|
||||
A `.onion` daemon cannot be dialled directly. The wallet child is an external
|
||||
C++ binary, so it reaches Tor 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.
|
||||
- Bundled `arti` binary: `arti proxy -p <random free loopback port>`. A second
|
||||
Tor client, not the messenger's in-process one. No C-tor.
|
||||
- Listener is TCP loopback only. Any local process at your privilege can use it.
|
||||
- Wallet child: `--proxy socks5://127.0.0.1:<port>` and
|
||||
`--daemon-address <onion>:<port>`. The `socks5://` scheme is required (Monero
|
||||
defaults to SOCKS4a for a bare `host:port`). No local DNS on the onion target.
|
||||
- Own state/cache: `$ONIONWIRE_HOME/wallet/arti-socks/{state,cache}`.
|
||||
- Wait up to 20s for the SOCKS listener before spawning the wallet child.
|
||||
- SOCKS child stops with the wallet child.
|
||||
|
||||
**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.
|
||||
wallet's addresses during sync.
|
||||
|
||||
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 — receipt verification needs a synced daemon
|
||||
|
||||
### Readiness, and why it is not a guess
|
||||
`chain_ready()` asks the wallet RPC `get_info` and requires
|
||||
**`synchronized == true`** with `height > 0` and `height >= target_height`. A
|
||||
missing field is *not ready* — fail closed.
|
||||
|
||||
`chain_ready()` asks the wallet RPC `get_info` and requires **`synchronized ==
|
||||
true`** with `height > 0` and `height >= target_height`. A missing field is
|
||||
*not ready* — fail closed, never a silent pass. Until then:
|
||||
Until then, **receipt verification stays `verified=0`**. An unsynced wallet
|
||||
cannot see the chain. That is an honest limit, not a UI bug.
|
||||
|
||||
- **receipt verification stays `verified=0`** (an unsynced wallet cannot see the
|
||||
tx, so a `get_transfers` miss would be a lie), and
|
||||
- **spend is refused** with `wallet is not synced — spend refused until the
|
||||
daemon reaches the chain tip`.
|
||||
Loopback management calls (`get_address`, `query_key`, create/import) get 5s.
|
||||
Calls that wait on the chain (`get_info`, `get_transfers`, `transfer`) get 60s
|
||||
(`CHAIN_RPC_TIMEOUT`).
|
||||
|
||||
`spend_ready()` is the stricter signal the spend UI reads: chain-ready *and*
|
||||
holding an unlocked balance above zero.
|
||||
|
||||
That is the honest state, not a broken flow. Unsynced or unreachable → receipts
|
||||
unverified and spend refused.
|
||||
|
||||
### Timeouts are the backend's, not a constant
|
||||
|
||||
Loopback management calls (`get_address`, `query_key`, create/import) get a 5s
|
||||
budget — the child is on the same box. Calls that wait on the chain (`get_info`,
|
||||
`get_transfers`, `transfer`) get 60s (`CHAIN_RPC_TIMEOUT`), because a first sync
|
||||
or a remote daemon legitimately outlasts a loopback round trip; a 5s cap there is
|
||||
what leaves receipts permanently unverified.
|
||||
|
||||
## Env vars
|
||||
## Env vars (migration path)
|
||||
|
||||
| Variable | Meaning |
|
||||
|---|---|
|
||||
| `ONIONWIRE_WALLET_RPC` | `http://[user:pass@]host[:port][/path]` — for an **externally run** `monero-wallet-rpc`. Unset → no wallet; chat still works and `/pay` falls back to the profile `xmr_addr`. The app-owned wallet child does not use this variable. |
|
||||
| `ONIONWIRE_WALLET_RPC_LOGIN` | `user:pass` when you do not want the password in the URL. Ignored if the URL carries userinfo. |
|
||||
| `ONIONWIRE_WALLET_NO_SPEND` | `1` / `true` / `yes` / `on` → view-only deployment: `/tip` is refused locally, before any RPC dial. `/pay` and receipt verification keep working. |
|
||||
| `ONIONWIRE_WALLET_RPC` | `http://[user:pass@]host[:port][/path]` for an **externally run** `monero-wallet-rpc`. Unset → no wallet; chat still works; `/pay` falls back to profile `xmr_addr`. The app-owned child does not use this. |
|
||||
| `ONIONWIRE_WALLET_RPC_LOGIN` | `user:pass` when the URL has no userinfo. |
|
||||
| `ONIONWIRE_WALLET_NO_SPEND` | `1` / `true` / `yes` / `on` → `/tip` refused locally before any RPC dial. |
|
||||
|
||||
These three are the **migration path**, not the only path: a config stored in
|
||||
the encrypted store wins at boot. See *Stored wallet config* below.
|
||||
Boot precedence: **stored config → env → disabled**. Stored config that cannot
|
||||
be used (non-loopback, `.onion`, missing login) is reported and falls back to
|
||||
env rather than dialling the bad endpoint.
|
||||
|
||||
`README.md` carries the operator summary; this file is the long form.
|
||||
`Store::save_wallet_config` / `Node::wallet_save_config` exist. **No TUI screen
|
||||
writes them.** There is no `F7`. The not-configured refusal still says
|
||||
`wallet not configured — open F7 to set it up, or set ONIONWIRE_WALLET_RPC`
|
||||
(`src/wallet.rs`). Live surfaces: `F6`, `F9`, or the env vars.
|
||||
|
||||
## Stored wallet config (no env required)
|
||||
`/pay` and `/tip` run `wallet_readiness` before send:
|
||||
|
||||
Editing env vars is a deployment step, not a UI step. The same three fields can
|
||||
be stored instead, so a deployment never needs env at all:
|
||||
1. not configured → the F7-worded message above
|
||||
2. `/tip` on view-only / `ONIONWIRE_WALLET_NO_SPEND` → refused **before any dial**
|
||||
3. configured but not connected → `wallet not connected — check endpoint, login, daemon`
|
||||
4. otherwise ready (`/pay` is fine on view-only)
|
||||
|
||||
| Field | Meaning |
|
||||
|---|---|
|
||||
| `rpc_url` | `http://host:port[/path]` for an **externally run** `monero-wallet-rpc`. **No** `user:pass` in the URL. Loopback only, same rule as env. |
|
||||
| `rpc_login` | `user:pass`. Never logged, never in a status line, never on disk in the clear. |
|
||||
| `no_spend` | View-only deployment. Same semantics as `ONIONWIRE_WALLET_NO_SPEND`. |
|
||||
## Android / SDK
|
||||
|
||||
`Store::save_wallet_config` / `Store::load_wallet_config` are the read/write
|
||||
pair, and `Node::wallet_save_config` re-reads the live wallet after a save so
|
||||
`configured` / the readouts follow without a restart. **No screen in this
|
||||
repository calls them yet**: the TUI wallet config screen (F7) and its endpoint
|
||||
entry, test-connection button and save path ship on
|
||||
`feat/wallet-create-import`, which is not part of this change — see
|
||||
*Starting and stopping the app-owned child* below for what this stack does
|
||||
expose. Until that lands, set the stored config programmatically (or use the env
|
||||
vars above).
|
||||
UniFFI: `set_chain_source(ChainConfig)` / `chain_source()`,
|
||||
`start_wallet_child()`, `stop_wallet_child()`, `wallet_status()` (cached read:
|
||||
no dial, for first paint) and `wallet_child_refresh()` (a live probe of the
|
||||
same record — it dials the loopback wallet RPC, and the local daemon's
|
||||
`get_info` when that RPC does not answer, so poll it on the order of seconds).
|
||||
Pass absolute paths for `wallet_rpc_bin` / `arti_bin` (`nativeLibraryDir`); the
|
||||
core never resolves a binary the caller named explicitly.
|
||||
|
||||
They live in the **encrypted SQLCipher store** (`wallet_config` table, one row:
|
||||
the URL and the flag in the clear inside the encrypted db, the login sealed with
|
||||
the store data key and a `onionwire/wallet-config/v1` AAD on top of whole-db
|
||||
encryption — the same discipline as the wallet-child creds). Save replaces the
|
||||
row; clearing the URL deletes it, which is how you turn the stored wallet off
|
||||
again.
|
||||
`ChainChoice.InProcessCuprate` is the in-process variant. Empty
|
||||
`monerod_datadir` resolves to `$ONIONWIRE_HOME/chain`. `start_wallet_child()`
|
||||
launches the node *and* the wallet child. `wallet_status()` carries
|
||||
`chain_in_process`, `node_available`, and `node_state`.
|
||||
|
||||
**Boot precedence is stored → env → disabled.** Stored config wins; the env vars
|
||||
in the table above remain the migration path (and the only path for headless
|
||||
runs). A stored config that cannot be used — non-loopback host, `.onion`,
|
||||
missing login — is reported and then **falls back to env** rather than dialling
|
||||
the bad endpoint. To override a stored config with env, clear the stored one
|
||||
first.
|
||||
|
||||
### Wallet status, and how fresh `connected` is
|
||||
|
||||
The app keeps one `WalletStatus` snapshot for the draw path —
|
||||
`configured`, `connected`, `last_error`, `balance_line`, `receive_address` —
|
||||
and the TUI only ever reads it; it never dials the wallet from the render path.
|
||||
|
||||
- `configured` is true when a stored **or** env config resolved to a usable
|
||||
wallet. Config is not reachability: a freshly booted or freshly saved wallet
|
||||
is `configured = true`, `connected = false`, with `—` readouts.
|
||||
- `connected` only ever comes from a probe. One probe is `get_address` (cheap,
|
||||
loopback, and the same call `/pay` invoices need) followed by `get_balance`
|
||||
for the readout. A success clears `last_error`; a failure sets
|
||||
`connected = false` and keeps `configured = true`. There is no background
|
||||
refresh: `connected` is whatever the **last** probe said.
|
||||
- `last_error` is display copy, not a log line: trimmed, capped at 120 chars,
|
||||
and with the RPC password redacted (`<redacted>`) if a lower layer ever put it
|
||||
in a message.
|
||||
|
||||
Two probes exist:
|
||||
|
||||
- `wallet_refresh` / the readiness guard probe the **configured** endpoint and
|
||||
update the snapshot;
|
||||
- `wallet_test_connection` probes an endpoint the caller is *currently typing*
|
||||
(`Wallet::ping`) and returns `{ok, status, error}` without touching the live
|
||||
wallet or the snapshot — testing an untyped endpoint is not the wallet the app
|
||||
is running. (The F7 screen that calls it ships on `feat/wallet-create-import`.)
|
||||
|
||||
### The pay/tip readiness guard
|
||||
|
||||
`/tip` and `/pay` run a pre-check before the send. It never dials Tor (wallet
|
||||
RPC is loopback-only), and it never dials the wallet at all when the answer is
|
||||
already known locally. The order is fixed and the copy is part of the contract:
|
||||
|
||||
1. **not configured** → `wallet not configured — open F7 to set it up, or set ONIONWIRE_WALLET_RPC`
|
||||
2. **`/tip` on a no-spend / view-only wallet** → the existing view-only message
|
||||
(`wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt
|
||||
verification still work`), refused **before any dial** — this is the same rule
|
||||
`transfer` applies, and it is the honest answer whether or not the wallet is
|
||||
reachable.
|
||||
3. **configured but not connected** → `wallet not connected — check endpoint, login, daemon`
|
||||
4. otherwise ready. `/pay` is fine on a view-only wallet.
|
||||
|
||||
The check is cheap enough to run on Enter: steps 1 and 2 are local, and step 3
|
||||
is one bounded probe (5s local budget). `wallet_readiness(is_tip)` is `async`;
|
||||
the TUI calls it from its key handler on both the `/pay` and `/tip` paths before
|
||||
it sends anything.
|
||||
|
||||
The "open F7" wording inside the not-configured message is the copy that ships
|
||||
with the F7 screen on `feat/wallet-create-import`; this stack stores the config
|
||||
and exposes the guard, but no screen writes it yet.
|
||||
|
||||
## Starting and stopping the app-owned child
|
||||
|
||||
Nothing spawns the child by accident: `Node::start_wallet_child` is the only
|
||||
start path, and it is never called at boot. The desktop TUI drives it from the
|
||||
wallet screen (F6):
|
||||
|
||||
| Key | Effect |
|
||||
|---|---|
|
||||
| `s` | Start the child, then probe it once. |
|
||||
| `x` | Stop it (idempotent) and fall back to the stored/env wallet config. |
|
||||
| `p` | Probe the running child: is its wallet RPC answering, is the chain at the tip? |
|
||||
|
||||
The state shown next to the wallet readouts is `off` / `connecting` / `syncing`
|
||||
/ `ready` / `exited`, plus the chain-source label (`receive-only`,
|
||||
`local node`, `in-process node`, `remote onion daemon`, `remote daemon`). It is
|
||||
derived from the real process (`try_wait`) and the last probe — **never** from
|
||||
env-var presence, and `ready` is never reported for a child that has died.
|
||||
|
||||
- **`off`** — nothing started (or stopped). The default state.
|
||||
- **`connecting`** — the `monero-wallet-rpc` process is alive but has not
|
||||
answered yet. This is what a fresh `s` reports; the RPC is not up the instant
|
||||
the process exists.
|
||||
- **`syncing`** — it answered but `chain_ready()` is false.
|
||||
- **`ready`** — it answered and the chain is at the tip.
|
||||
- **`exited`** — a started child has died. Stop and start again; the status is
|
||||
not stale, it is the process table.
|
||||
|
||||
The same one-liner carries the chain's own progress once a probe has read it:
|
||||
|
||||
```
|
||||
child syncing · in-process node · sync 1160/3090939
|
||||
```
|
||||
|
||||
Those are the **daemon's** height and the tip it is syncing towards — from the
|
||||
wallet RPC's `get_info` when it answers, and, when the wallet RPC is *not*
|
||||
answering (the `connecting` case, e.g. `Connection refused (os error 111)`) while
|
||||
the chain source is `local node` or `in-process node`, from that loopback daemon
|
||||
directly. `sync 0/0`, or no `sync` segment at all, means **unknown**: the child
|
||||
is off or exited, the probe failed, or the daemon reported no target — which is
|
||||
not the same as caught up, and is never a wallet-scan height. No percentage is
|
||||
ever derived from it. `WalletChildStatus` (and the UniFFI record) carries the two
|
||||
numbers as `height` / `target_height`.
|
||||
|
||||
`start` is idempotent: a live child is reported, not respawned. A start that
|
||||
cannot spawn the binary is an error and leaves no child behind.
|
||||
|
||||
**The chain source and the binaries are settings, not flags.** They live in the
|
||||
same sealed `wallet_child` record as the generated RPC creds (see *Where the RPC
|
||||
credentials live*), so they survive a restart:
|
||||
|
||||
- `src/wallet_child.rs` `ChildConfig` — `source`, `wallet_rpc_bin`, `arti_bin`,
|
||||
`wallet_filename`; validated before anything is written.
|
||||
- Core: `Node::wallet_child_config` / `Node::set_wallet_child_config`, then
|
||||
`Node::start_wallet_child` / `stop_wallet_child` / `wallet_child_status` /
|
||||
`wallet_child_refresh`.
|
||||
- Android (UniFFI): `set_chain_source(ChainConfig)` / `chain_source()`,
|
||||
`start_wallet_child()`, `stop_wallet_child()`, `wallet_status()` (the cached
|
||||
read: no dial, for first paint) and `wallet_child_refresh()` (a live probe of
|
||||
the same record — it dials the loopback wallet RPC, and the local daemon's
|
||||
`get_info` when that RPC does not answer, so poll it on the order of
|
||||
seconds). Pass absolute paths for `wallet_rpc_bin` / `arti_bin` (`nativeLibraryDir`); the
|
||||
core never resolves a binary the caller named explicitly. `ChainChoice` has a
|
||||
fourth variant, `InProcessCuprate`, for the in-process daemon: no binary path
|
||||
and, with an empty `monerod_datadir`, the SDK resolves the chain directory to
|
||||
`$ONIONWIRE_HOME/chain`. `start_wallet_child()` is the whole lifecycle for it
|
||||
(the core launches the node *and* the wallet child in that one call), and
|
||||
`wallet_status()` carries `chain_in_process` (this app's node is the source),
|
||||
`node_available` (this build has `cuprate-daemon`) and `node_state`
|
||||
(`off` / `starting` / `syncing` / `ready` / `exited`, empty for every other
|
||||
source) beside the core's own five `state` words.
|
||||
|
||||
So local mode is **available**, not wired off: a local chain source spawns
|
||||
`monerod` from the path you set, a `.onion` daemon spawns the `arti` SOCKS
|
||||
child, and everything else is unchanged. What is still missing is a *screen* to
|
||||
type those fields on the desktop — the API above is the surface until the F7
|
||||
work lands.
|
||||
Monero ships **no Android binaries**. Any vendored blob's provenance doc must
|
||||
say so. Cross-compiled is not device-proven. See `android/MONERO_BINARIES.md`.
|
||||
|
||||
## Create vs import
|
||||
|
||||
Create does **not** take a private key. `/wallet create` (TUI: F6 then `c`) asks
|
||||
the RPC to generate a new spend-capable wallet (`create_wallet`), then shows the
|
||||
seed **once** for backup (`query_key mnemonic`). Type `SPEND` to accept the
|
||||
spend-authority warning, set a passphrase, write the seed down, type `SEEN`.
|
||||
`/wallet create` (`F6` then `c`) → `create_wallet`, then seed **once**
|
||||
(`query_key mnemonic`). Type `SPEND`, set a passphrase, write the seed, type
|
||||
`SEEN`.
|
||||
|
||||
Import is the only path that takes an existing secret: `/wallet import` (F6 then
|
||||
`i`) pastes the 25-word seed into `restore_deterministic_wallet`. Do not put the
|
||||
seed on the composer line — it would sit in chat history.
|
||||
`/wallet import` (`F6` then `i`) → `restore_deterministic_wallet` from a
|
||||
25-word seed. Do not put the seed on the composer.
|
||||
|
||||
The RPC must be started with `--wallet-dir` (not only `--wallet-file`) or create
|
||||
and import fail. The in-app filename is `onionwire`.
|
||||
RPC must be started with `--wallet-dir` (not only `--wallet-file`). Filename:
|
||||
`onionwire`.
|
||||
|
||||
## Recommended topology
|
||||
## Recommended topology (view-only)
|
||||
|
||||
```
|
||||
wallet host (this machine)
|
||||
|
|
@ -419,38 +228,19 @@ and import fail. The in-app filename is `onionwire`.
|
|||
└──────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
Loopback is the only address OnionWire will dial for **wallet RPC**. `.onion`
|
||||
wallet-RPC URLs are rejected: there is no Arti dial for the wallet process, and
|
||||
a remote wallet RPC would move spend authority off the box.
|
||||
Loopback is the only address OnionWire will dial for **wallet RPC**.
|
||||
|
||||
## Create a view-only wallet
|
||||
|
||||
Either path produces a wallet file with the view key only. Keep the seed /
|
||||
spend key on a machine that is **not** running OnionWire.
|
||||
|
||||
With `monero-wallet-cli` (`--generate-from-view-key` prompts for the *standard*
|
||||
address the view key belongs to, then the secret view key):
|
||||
Keep the seed / spend key on a machine that is **not** running OnionWire.
|
||||
|
||||
```bash
|
||||
monero-wallet-cli --generate-from-view-key "$HOME/.onionwire-viewonly" \
|
||||
--daemon-address "$YOUR_MONEROD:18089" --restore-height "$BIRTH_HEIGHT"
|
||||
# Standard address: 4...
|
||||
# Secret view key: <hex>
|
||||
```
|
||||
|
||||
Or through a running RPC that was started with `--wallet-dir` (`generate_from_keys`
|
||||
without `spendkey` writes a watch-only wallet):
|
||||
|
||||
```bash
|
||||
curl -u onionwire:secret http://127.0.0.1:18083/json_rpc \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"jsonrpc":"2.0","id":"0","method":"generate_from_keys","params":{
|
||||
"filename":"viewonly","password":"walletpass",
|
||||
"address":"4...","viewkey":"<hex>","restore_height":<height>}}'
|
||||
# → "Watch-only wallet has been generated successfully."
|
||||
```
|
||||
|
||||
Then serve it:
|
||||
`18089` here is the **remote** daemon's restricted RPC, an address you type —
|
||||
not the app-owned 18081.
|
||||
|
||||
```bash
|
||||
monero-wallet-rpc --wallet-file "$HOME/.onionwire-viewonly" \
|
||||
|
|
@ -462,78 +252,36 @@ export ONIONWIRE_WALLET_RPC_LOGIN=onionwire:secret
|
|||
export ONIONWIRE_WALLET_NO_SPEND=1
|
||||
```
|
||||
|
||||
Restore the wallet from a height *at or before* its first incoming transaction
|
||||
— a view-only wallet cannot rescan cheaply from height 0.
|
||||
Restore from a height at or before the first incoming transaction.
|
||||
|
||||
## What works, what does not
|
||||
|
||||
| Feature | View-only | Spend-capable |
|
||||
|---|---|---|
|
||||
| `/pay <xmr>` invoice subaddress (`create_address`) | works | works |
|
||||
| Receipt verification (`get_transfers`) | works | works |
|
||||
| Receipt verification (`get_transfers`) | works, if daemon is synced | works, if daemon is synced |
|
||||
| Profile `xmr_addr` fallback when RPC is down | works | works |
|
||||
| `/tip <xmr>` (`transfer`) | **cannot work** | works |
|
||||
| OnionWire copies your spend key into its own process | never | never (it stays in the wallet file / RPC) |
|
||||
|
||||
With `ONIONWIRE_WALLET_NO_SPEND=1` a `/tip` is refused before the RPC is
|
||||
contacted, with:
|
||||
`ONIONWIRE_WALLET_NO_SPEND=1` refuses `/tip` before RPC with:
|
||||
|
||||
```
|
||||
wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt verification still work
|
||||
```
|
||||
|
||||
Without the flag, `/tip` against a view-only wallet fails at the wallet and
|
||||
OnionWire then asks the wallet directly whether it can spend (see below), so you
|
||||
get the same sentence instead of a raw RPC error.
|
||||
|
||||
## How OnionWire detects view-only over RPC
|
||||
|
||||
The signal people usually reach for is `query_key` with `key_type=mnemonic`. It
|
||||
works, but it is the wrong key to ask for: on a spend-capable wallet it hands
|
||||
over the whole seed (full spend ability) over loopback HTTP, and it answers
|
||||
`-43` for wallets that have no mnemonic at all. The spend key is narrower and
|
||||
just as unambiguous:
|
||||
|
||||
```
|
||||
query_key {"key_type":"spend_key"}
|
||||
spend-capable → result.key = <hex secret spend key>
|
||||
view-only → error code -29, "The wallet is watch-only. Cannot retrieve spend key."
|
||||
```
|
||||
|
||||
(`query_key key_type=mnemonic` returns `-29` for a view-only wallet too, so the
|
||||
two agree — OnionWire asks for the spend key because it is the smaller secret.)
|
||||
|
||||
- Method: [`query_key`](https://www.getmonero.org/resources/developer-guides/wallet-rpc.html#query_key)
|
||||
- `-29` is `WALLET_RPC_ERROR_CODE_WATCH_ONLY` in
|
||||
[`wallet_rpc_server_error_codes.h`](https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server_error_codes.h)
|
||||
- The view-only branch is `on_query_key` in
|
||||
[`wallet_rpc_server.cpp`](https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server.cpp)
|
||||
|
||||
OnionWire only calls this **after** a `transfer` has already failed — it never
|
||||
probes a healthy wallet — and it discards `result.key` immediately. There is no
|
||||
RPC method that reports "view-only" as a plain field; `query_key` is the
|
||||
documented signal and this is its only cost: a spend-capable wallet answers with
|
||||
its spend key over loopback HTTP, which is one more reason to run view-only.
|
||||
|
||||
Fail-closed details: if the probe cannot answer (wallet down, `--restricted-rpc`
|
||||
answers `-7 DENIED` instead), OnionWire surfaces the wallet's own error
|
||||
unchanged. It never guesses "view-only" from an unrelated failure.
|
||||
View-only detection after a failed `transfer`: `query_key` `spend_key` → `-29`
|
||||
watch-only. The spend key is discarded immediately. OnionWire never probes a
|
||||
healthy wallet for this.
|
||||
|
||||
## Why loopback still needs authentication
|
||||
|
||||
`--rpc-bind-ip 127.0.0.1` keeps the port off the network; it does **not** keep it
|
||||
away from other users or processes on the same machine. Any local process can
|
||||
`connect(127.0.0.1:18083)`.
|
||||
`--rpc-bind-ip 127.0.0.1` keeps the port off the network; it does **not** keep
|
||||
it away from other processes on the same machine.
|
||||
|
||||
- OnionWire refuses an RPC that answers HTTP 200 without a Digest challenge, and
|
||||
refuses URLs without credentials. Unset the credentials and the wallet is open
|
||||
to every local process — with a spend-capable wallet file, that is a
|
||||
one-curl drain of your balance.
|
||||
- `--rpc-login` is HTTP Digest (MD5), so the password is not sent in cleartext,
|
||||
but Digest gives no confidentiality: a local attacker who can sniff loopback
|
||||
can replay it. Treat loopback as trusted-ish, not safe.
|
||||
- Do not log the password, and do not put it in a shell history you share.
|
||||
Prefer `ONIONWIRE_WALLET_RPC_LOGIN` over userinfo in the URL.
|
||||
OnionWire refuses an RPC that answers HTTP 200 without a Digest challenge, and
|
||||
refuses URLs without credentials. Prefer `ONIONWIRE_WALLET_RPC_LOGIN` over
|
||||
userinfo in the URL. Do not log the password.
|
||||
|
||||
## The spend-authority warning
|
||||
|
||||
|
|
@ -543,27 +291,17 @@ local spend authority: any process that can read the RPC credentials (env var,
|
|||
balance, and `/tip` gives a chat peer a supported path to ask for a transfer.
|
||||
|
||||
That is why view-only plus `ONIONWIRE_WALLET_NO_SPEND=1` is the recommended
|
||||
default:
|
||||
default. If you want tips, use a **separate hot wallet with a small balance**,
|
||||
not your savings wallet.
|
||||
|
||||
- the wallet file holds no spend key, so a stolen wallet file cannot be used to
|
||||
move funds;
|
||||
- the RPC credentials grant only receive-address and history reads;
|
||||
- `/tip` fails locally with a plain message, so nothing in the UI pretends the
|
||||
spend path exists.
|
||||
## Payments are one-shot
|
||||
|
||||
If you want tips to work, understand that you are deliberately making the
|
||||
OnionWire process able to spend. Give it a **separate hot wallet with a small
|
||||
balance**, not your savings wallet.
|
||||
`/pay` and `/tip` fail when the peer onion is down. There is no queued invoice.
|
||||
File transfer is the same rule.
|
||||
|
||||
## References
|
||||
|
||||
- Monero Wallet RPC reference:
|
||||
<https://www.getmonero.org/resources/developer-guides/wallet-rpc.html>
|
||||
- `on_query_key` (view-only → `-29`):
|
||||
<https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server.cpp>
|
||||
- `WALLET_RPC_ERROR_CODE_WATCH_ONLY = -29`:
|
||||
<https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server_error_codes.h>
|
||||
- `--generate-from-view-key` (incoming-only wallet):
|
||||
<https://github.com/monero-project/monero/blob/master/src/simplewallet/simplewallet.cpp>
|
||||
- `generate_from_keys` (watch-only when `spendkey` is omitted):
|
||||
<https://www.getmonero.org/resources/developer-guides/wallet-rpc.html#generate_from_keys>
|
||||
- Monero Wallet RPC: <https://www.getmonero.org/resources/developer-guides/wallet-rpc.html>
|
||||
- `WALLET_RPC_ERROR_CODE_WATCH_ONLY = -29` in the Monero tree
|
||||
- Spike history (not operator docs): [cuprate-launch-spike.md](cuprate-launch-spike.md),
|
||||
[arti-socks-feasibility.md](arti-socks-feasibility.md)
|
||||
|
|
|
|||
Loading…
Reference in a new issue