Commit graph onionwire/tests/wallet.rs
Author SHA1 Message Date
rust-dev
35a19bc37c
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
All checks were successful
ci / test (pull_request) Successful in 4m35s
ci / sdk (pull_request) Successful in 1m12s
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.

- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
  `cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
  stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
  in-process daemon is clearnet-only, so this keeps one Tor stack in the
  process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
  (testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
  off), launches it, and owns it. Dropping the value is the teardown;
  `shutdown()` is called before the drop so the services can drain. The type
  exists in every build: without the feature `launch` fails with the feature
  name instead of silently doing nothing, so the chain-source type, its stored
  record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
  `kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
  local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
  async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
  a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
  node and drives get_info / get_height / get_block through the typed daemon
  client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
  stripped overhead, and the two limits (testnet only, no Tor in the chain
  path).

Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:29:50 -04:00
hermes-rust-dev
e6b5024ad3
wallet: typed chain-daemon client for the Cuprate parity gaps
Some checks failed
ci / test (pull_request) Failing after 1m30s
ci / sdk (pull_request) Successful in 1m16s
The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate
breaks three of its assumptions, all measured in Spike A
(`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's
`rpc-evidence/`):

1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod
   answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The
   client now parses the HTTP status once, de-chunks `Transfer-Encoding:
   chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob
   spans more than one chunk), and maps both spellings of the height failure to
   one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block`
   are height-addressed: their 5xx is the height error. `get_info` is not: its
   5xx is `WalletError::DaemonHttpStatus`.

2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while
   it downloads blocks, its restricted server answers a placeholder
   `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is
   `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so
   there is no field for a placeholder to reach the UI. The wallet screen's sync
   line is now built from block-height movement between two probes: "connected
   to P2P" needs the height to have moved, "no new blocks" is what a stalled
   daemon gets, and Cuprate's at-rest `synchronized = true` with
   `target_height = 0` reads as unknown instead of `1160/0`.

3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over
   `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which
   both daemons answer. The wallet-child routing rule is pinned too: it dials
   the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and
   whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the
   restricted one — a restricted listener answers, so a mix-up shows up as a
   wrong number rather than as an error.

Scope deviations, stated plainly:

- the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in
  `src/node.rs`; it now delegates (net -100 lines there), and the routing
  constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`,
  `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module.
- `daemon_get_block()` is **not called by anything yet**: it is the entry point
  the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has
  to survive is item 1, so the mapping lives with the client.
- the card's item 3 gives the unrestricted port as 18089 and the restricted one
  as 28089. In monerod's numbering 18089 *is* the restricted port; the app's
  local source already dials the unrestricted 18081. The rule is what is pinned,
  not those numbers.
- `docs/cuprate-launch-spike.md` merged to `main` after this branch's base
  commit, so it is not in this tree and its Recommendation bullets are not
  updated here.
- based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon
  client has no home on `main`. Retarget to `main` when that line lands.

Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked
--all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no
hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/
`tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:30:31 -04:00
rust-dev
d7e91f850a
wallet: stored config (F7), WalletStatus snapshot, pay/tip readiness guard
All checks were successful
ci / test (pull_request) Successful in 4m22s
ci / sdk (pull_request) Successful in 1m15s
The only input path for the wallet was env. Add the same three remote-mode
fields as stored config so the F7 screen can set them and headless runs read
one source of truth:

- `wallet_config` table in the encrypted store (one row; the login is sealed
  with the store data key under `onionwire/wallet-config/v1`, on top of
  SQLCipher). Empty URL clears it. `Store::load_wallet_config` /
  `save_wallet_config`.
- `WalletConfig { rpc_url, rpc_login: Zeroizing<String>, no_spend }` with a
  redacting `Debug`; `Wallet::from_config`, and `Wallet::for_boot` which
  prefers stored config, falls back to env, and refuses to dial a bad stored
  endpoint. Node::start* now reads the store before constructing the wallet.
- `WalletStatus { configured, connected, last_error, balance_line,
  receive_address }`: `connected` only ever comes from a probe
  (`Wallet::status`, get_address + get_balance); config alone leaves it false.
  `Node::wallet_status` is the cheap draw-path read, `wallet_refresh` the
  probe that folds into it.
- One-shot `Wallet::ping(rpc_url, rpc_login) -> PingResult { ok, status,
  error }` for the Test-connection button: same loopback/digest rules, errors
  redacted and capped.
- `readiness(configured, connected, no_spend, is_tip) -> Readiness` plus
  `Node::wallet_readiness` (async, block_on-friendly): not configured →
  NOT_CONFIGURED_MSG; /tip on a no-spend wallet → VIEW_ONLY_MSG before any
  dial; configured but not connected → NOT_CONNECTED_MSG; else ready.
- `Node::wallet_save_config` persists, validates first, then re-reads so the
  live wallet and snapshot follow a Save without a restart.
- `Node::wallet` is now a Mutex<Wallet> (cloned out before each await) so the
  wallet can be re-pointed mid-session.

Local-mode fields stay reserved: the child lifecycle is t_69ce8e46 and is not
wired here. docs/WALLET.md documents the stored config, boot precedence and
the exact guard copy.

Tests: 38 in tests/wallet.rs including exact-refusal-copy, boot precedence,
sealed-on-disk login, ping sanitization and connected-only-after-probe.
2026-09-14 23:39:57 -04:00
agent
8331a2dde6
wallet: app-owned child lifecycle + user-chosen ChainSource
All checks were successful
ci / test (pull_request) Successful in 4m1s
ci / sdk (pull_request) Successful in 1m2s
The app now owns monero-wallet-rpc (and monerod when the chain source is
local) instead of requiring the user to start them and export
ONIONWIRE_WALLET_RPC.

- ChainSource enum: None / Local { monerod_bin, datadir } / Remote { host,
  port }. No default remote node; Remote is only constructed from explicit
  user input. A .onion Remote is refused without a SOCKS proxy (separate
  card).
- WalletChild in src/wallet_child.rs spawns monero-wallet-rpc with
  --rpc-bind-ip 127.0.0.1, a random free loopback port, generated
  --rpc-login, and --wallet-dir /wallet; monerod too for a
  local source. --trusted-daemon is never passed.
- Generated RPC creds are sealed in the encrypted SQLCipher store
  (wallet_child table, AEAD on top of whole-db encryption), never a
  plaintext file. The Wallet client is built from the generated loopback
  URL, not from_env.
- Readiness predicate: chain_ready() requires synchronized==true, height>0,
  height>=target_height; can_spend() and can_verify_receipts() gate on it.
  Unsynced -> receipts stay verified=0, spend refused with a clear message.
- Backend-aware timeouts: local management calls keep 5s; chain-dependent
  calls (get_info, get_transfers, transfer) get 60s (CHAIN_RPC_TIMEOUT),
  because a first sync or a remote daemon outlasts 5s and a 5s cap there
  is what left receipts permanently unverified.
- node.rs ingest_receipt gates on can_verify_receipts() instead of
  configured() alone.
- docs/WALLET.md rewritten for the child lifecycle + chain source.

Base: feat/wallet-create-import (PR #66). Do not rebase onto main.

Co-Authored-By: Hermes Agent <agent@local>
2026-09-14 19:57:21 -04:00
Lance Walters
cf0a517cd2
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.
2026-09-13 23:25:25 -04:00
Sirius DevOps
323100b162
wallet: no-spend mode + view-only detection over RPC
All checks were successful
ci / test (pull_request) Successful in 4m11s
/tip needs monero-wallet-rpc `transfer`, which a view-only wallet cannot do.
With ONIONWIRE_WALLET_NO_SPEND=1 (`1`/`true`/`yes`/`on`) `Wallet::transfer`
refuses locally, before any RPC dial, and /pay + receipt verification are
unchanged.

When a transfer does fail, ask the documented signal before surfacing the raw
wallet error: `query_key` key_type=spend_key answers
WALLET_RPC_ERROR_CODE_WATCH_ONLY (-29) on a view-only wallet
(wallet_rpc_server.cpp on_query_key). Both paths return one sentence —
"wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt
verification still work". Fail closed: if the probe cannot answer, the wallet's
own error stands; no fabricated detection.

New docs/WALLET.md: --generate-from-view-key / generate_from_keys watch-only
setup, --rpc-login Digest, why loopback still needs auth, the local
spend-authority warning, and the detection trade-off (a spend-capable wallet
answers the probe with its spend key, which is discarded). Linked from
docs/THREAT_MODEL.md.
2026-09-12 15:41:33 -04:00
Sirius DevOps
08ced86a34
Merge F5 wallet digest RPC onto audit bundle
All checks were successful
ci / test (pull_request) Successful in 3m33s
Keep sha3 (F4 checksums) and md-5 (HTTP Digest). Threat model: digest login
plus conjunctive verified receipts. Wallet tests: F1 matcher fixtures plus
F5 digest/cap coverage.
2026-09-10 20:36:10 -04:00
Sirius DevOps
125aafb816
[verified] feat(wallet): require RPC digest login and cap reads
All checks were successful
ci / test (pull_request) Successful in 3m8s
Refuse unauthenticated ONIONWIRE_WALLET_RPC, speak HTTP Digest like
monero-wallet-rpc --rpc-login, cap responses at 1 MiB, and reject
.onion RPC URLs instead of half-dialing them over TCP.
2026-09-10 20:17:25 -04:00
Sirius DevOps
bfd28fce6b
fix(ci): serialize Pi jobs; valid XMR fixture after F4
All checks were successful
ci / test (pull_request) Successful in 2m49s
Overlapping Actions used a fixed docker name onionwire-ci (Conflict)
and OOM-killed with 137. Unique run_id names + one-at-a-time
concurrency. F1 ingest test still used 8+B*94 which F4 checksums reject.
2026-09-10 20:12:41 -04:00
Sirius DevOps
1a465581c2
[verified] fix(wallet): conjunctive receipt verify
Some checks failed
ci / test (pull_request) Failing after 35s
Require non-empty txid AND amount AND address against one
get_transfers row. Signed rcp alone never sets verified=1.
2026-09-10 19:29:39 -04:00
Sirius DevOps
1a9b54d138
feat: Monero invoice/receipt frames, wallet RPC, /pay /tip
All checks were successful
ci / test (push) Successful in 2m50s
Signed inv/rcp codecs keyed by identity, payments table with unverified
incoming receipts, optional JSON-RPC sidecar (loopback/.onion HTTP only),
and TUI /pay /tip. OnionWire still holds no spend keys.
2026-09-10 14:37:43 -04:00