wallet: create/import in-app (no key paste on create) + opt-in spend
All checks were successful
ci / test (pull_request) Successful in 4m15s
ci / sdk (pull_request) Successful in 1m12s

/ wallet create generates a wallet on the RPC and shows the 25-word seed
once for backup; /wallet import is the only path that takes an existing
seed, and it is collected on a dedicated screen so it never reaches the
composer line or chat history.

Threat model now states the real policy: payments are opt-in, default is
no spend key, spend is a local authority at create/restore, and the chain
source is the user's choice (spawned local monerod or a daemon address
they supply). WALLET.md and README follow.

Tests: canned-RPC create/restore, slash parse, help overlay.
This commit is contained in:
Lance Walters 2026-09-13 23:25:25 -04:00
commit cf0a517cd2
No known key found for this signature in database
12 changed files with 758 additions and 48 deletions

View file

@ -69,21 +69,61 @@ The queue is bounded in scope: chat only. File transfer and `rcp` frames are one
A signed `prf` frame is shown to people who already have a session with you. Apply only for existing friends. There is still no name lookup, DHT, or public profile server. Anyone who already has a Noise session can see the profile you send them; that is not confidentiality against that friend.
## Monero sidecar is not a wallet
## Payments are opt-in; spend is a local authority
OnionWire never holds spend keys. Optional `ONIONWIRE_WALLET_RPC` talks HTTP Digest to a user-hosted `monero-wallet-rpc` on loopback (`--rpc-login` required; open RPC is refused). A Noise friend can sign any `rcp`; the signature proves who sent the claim, not that a payment happened. `verified=1` only after a conjunctive RPC match: one `get_transfers` row with the same non-empty `txid`, `amount`, and `address`. Incoming `rcp` stays `verified=0` if RPC is down, errors, or no exact row. Subaddress reuse is the user’s wallet policy.
Chat does not need a wallet. Payment frames (`inv`, `rcp`, `tip`) are signed
claims over Noise: a signature proves which friend sent the claim, not that
money moved. `verified=1` only after a conjunctive match — one `get_transfers`
row with the same non-empty `txid`, `amount`, and `address`. RPC down, error, or
no exact row → stay `verified=0`. Subaddress reuse is the user’s wallet policy.
Run it **view-only** (recommended). `/pay` and receipt verification need only
`create_address`/`get_transfers`, which a wallet without a spend key serves
fine; `ONIONWIRE_WALLET_NO_SPEND=1` disables `/tip` locally, before any RPC
dial, and a view-only wallet is detected over RPC (`query_key`
`key_type=spend_key` → `-29`, `WALLET_RPC_ERROR_CODE_WATCH_ONLY`) so `/tip` says
so plainly instead of failing with a raw wallet error. The trade-off is
explicit: an OnionWire instance pointed at a **spend-capable** wallet is a local
spend authority — any process that can read the RPC credentials can move the
balance, and `/tip` gives a chat peer a supported way to ask for a transfer.
Loopback binding is not an authorization boundary. Full setup, view-only wallet
creation, and the credential/loopback reasoning: [WALLET.md](WALLET.md).
**Default: no spend.** No seed and no spend key on the device. Receive can use
the profile `xmr_addr`, or a view-only wallet (`create_address` /
`get_transfers` only). `/tip` is off (`ONIONWIRE_WALLET_NO_SPEND`, or a
watch-only wallet detected over RPC via `query_key spend_key` → `-29`).
**Spend is opt-in**, at wallet create or restore, not a hidden default. A
seed-backed spend-capable wallet makes OnionWire a **local spend authority**
for that file: anyone with the wallet passphrase or the wallet-RPC credentials
can move the balance, and `/tip` is a supported way for a chat peer to get paid.
The spend-authority warning is unavoidable at that create/restore step. Loopback
binding is not an authorization boundary. Back up the seed; do not leave a
spend-capable wallet on a device you do not trust; a separate hot wallet with a
small balance is the sane spend shape, not savings.
The app talks to `monero-wallet-rpc` over **loopback HTTP Digest** only
(`--rpc-login` required; open RPC refused). That process may be one the user
already runs, or one the app spawns. Wallet RPC is never dialed over clearnet or
over `.onion` — a remote wallet RPC would move spend authority off the box
through a channel the messenger’s `--password` gate does not cover.
### Chain source is the user’s choice
Scan, receipt verification, and spend need a Monero daemon. The user picks one;
the app does not pick a public remote node for them.
1. **Spawn a local `monerod`** (pruned is the on-device target). Chain traffic
stays on the device. The user accepts disk (tens of GB for a pruned mainnet
node), first-sync time, and — on Android — process kills: the daemon is not
always running. A pruned node is not an archive. Seed restore of deep history
can degrade; once the wallet has scanned, its own cache is the history.
Unsynced or not running is an honest “not ready” / unverified state, not a
fake success.
2. **A daemon address they supply.** The wallet child points `--daemon-address`
at that host. Trust follows the address:
- **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.
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.
The ISP sees Monero-node traffic; the daemon operator sees addresses. Show
that trust shift before using the address.
Remote daemons are untrusted (`--trusted-daemon` off). Setup, view-only vs
spend, and RPC credentials: [WALLET.md](WALLET.md).
## Backup file is the identity
@ -96,12 +136,23 @@ Incoming rendezvous accepts are token-bucket limited (30/60s, burst 10). Excess
## Network (UDP / clearnet)
The application does not open UDP sockets and does not resolve friends via
system DNS. Peer dials are Arti `connect((onion, 80))` only. The one
intentional clearnet socket is optional `monero-wallet-rpc` on **loopback TCP**
(numeric loopback preferred; `localhost` still does `getaddrinfo`).
system DNS. Peer dials are Arti `connect((onion, 80))` only.
Do not add STUN/ICE/WebRTC, a DHT, SOCKS/C-tor fallback, or “direct TCP when
the onion is slow.” Those are the Tox-over-Tor leak class.
Wallet **RPC** (HTTP Digest to `monero-wallet-rpc`) is loopback TCP only
(numeric `127.0.0.1` / `::1` preferred; `localhost` still does `getaddrinfo`).
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
clearnet daemon address is an explicit user choice — a clearnet socket they
asked for — not the messenger path and not a hidden default.
Do not add STUN/ICE/WebRTC, a DHT, SOCKS/C-tor fallback for **peer dials**, or
“direct TCP when the onion is slow.” Those are the Tox-over-Tor leak class. A
SOCKS listener used only by the wallet child to reach a user-chosen `.onion`
daemon is not that class.
## Peer text is untrusted display data

View file

@ -1,14 +1,23 @@
# OnionWire + monero-wallet-rpc
OnionWire is not a wallet. It never holds a seed, a spend key, or a view key.
It talks optional JSON-RPC to a `monero-wallet-rpc` that **you** run, on
loopback, only to:
Chat does not require a wallet. A wallet is opt-in.
**Default: no spend.** No seed and no spend key on the device. Receive uses the
profile `xmr_addr`, or a view-only wallet for invoices (`create_address`) and
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).
The app talks to `monero-wallet-rpc` over loopback HTTP Digest only, whether
that process is one you already run or one the app spawns:
- 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 let it — spend for `/tip` (`transfer`).
- and — only if you opted into spend — `/tip` (`transfer`).
**Run it view-only, and switch `/tip` off explicitly.** Everything else in this
**Prefer view-only until you actually want `/tip`.** Everything else in this
document explains why, and what breaks when you do.
## Env vars
@ -21,6 +30,20 @@ document explains why, and what breaks when you do.
`README.md` carries the operator summary; this file is the long form.
## 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`.
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.
The RPC must be started with `--wallet-dir` (not only `--wallet-file`) or create
and import fail. The in-app filename is `onionwire`.
## Recommended topology
```
@ -34,9 +57,26 @@ document explains why, and what breaks when you do.
└──────────────────────────────────────────────────────────────┘
```
Loopback is the only address OnionWire will dial. `.onion` RPC URLs are
rejected: there is no Arti dial for the wallet, and a remote wallet would move
your key material off the box.
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.
## 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.
1. **Spawn a local `monerod`** (pruned on-device). Chain traffic stays on the
box. You accept disk, first sync, and (on Android) the daemon not always
running.
2. **A daemon address you supply** — `--daemon-address` on the wallet child.
Loopback if you already run `monerod`. `.onion` if you want chain traffic
over Tor (wallet child `--proxy` to a localhost SOCKS listener; the daemon
operator still sees addresses). Clearnet only if you type it — ISP sees
Monero-node traffic; not a default.
Remote daemons are untrusted (`--trusted-daemon` off). Unsynced or unreachable
→ receipts stay unverified and spend is refused. That is the honest state.
## Create a view-only wallet
@ -88,7 +128,7 @@ Restore the wallet from a height *at or before* its first incoming transaction
| Receipt verification (`get_transfers`) | works | works |
| Profile `xmr_addr` fallback when RPC is down | works | works |
| `/tip <xmr>` (`transfer`) | **cannot work** | works |
| OnionWire learns your spend key | never | never (it stays in the wallet) |
| 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: