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