Commit graph onionwire/src/wallet_child.rs
Author SHA1 Message Date
agent
90d982b369
deps: bump the Arti set tor-* 0.46 -> 0.49 (Arti 2.9.0)
All checks were successful
ci / test (pull_request) Successful in 31m8s
ci / sdk (pull_request) Successful in 1m34s
android-ci / android (pull_request) Successful in 18m10s
Arti publishes these in lockstep. Bumped together:
- arti-client 0.46 -> 0.49 (root + crates/onionwire-sdk, both lockfiles)
- tor-cell, tor-hsservice, tor-rtcompat 0.46 -> 0.49
- safelog 0.9 -> 0.10 (same repo; 0.49's HsId implements safelog 0.10's
  DisplayRedacted, so the old direct pin broke display_redacted)

Arti 0.49 (Arti 2.9.0, 2026-12-01) carries a medium-severity security fix
(TROVE-2026-078, custom build flags) and two low-severity fixes.

MSRV unchanged: Arti 0.49 needs rustc 1.92, the repo floor stays 1.98
(cuprate-daemon / tapes). Only docs/comments moved; src/hs.rs workarounds
rechecked against 0.49: tor-hsservice OVERALL_UPLOAD_TIMEOUT is still 5 min
(PUBLISH_WAIT 360s stands) and tor-config's Listen is still IP-only.

Verified: cargo test --locked (173 lib + all integration suites), clippy
--locked --all-targets -D warnings, SDK cargo test/clippy, live ignored
tor_hs + two_node tests, and scripts/build-android-local.sh (APK + AAR).
2026-12-02 02:37:17 -05:00
agent
625879e000
wallet: redact RPC creds everywhere and warn once on a login from env
All checks were successful
ci / test (pull_request) Successful in 19m31s
ci / sdk (pull_request) Successful in 2m3s
The app-spawned child already takes its login from the sealed store record
and only falls back to ONIONWIRE_WALLET_RPC_LOGIN; make that order explicit
in the code and name the exposure once per process when the fallback is used.

The dial URL still carries user:pass (Wallet::from_url needs it), but no
rendering path repeats it: Endpoint::redacted and WalletClient::redacted_url
print http://<redacted>:<redacted>@host:port/json_rpc, WalletClient has a
hand-written Debug, and error/status copy redacts the whole login, not just
the password half.

Residual, documented at the top of wallet_child.rs: --rpc-login is visible in
/proc/<pid>/cmdline to same-uid processes because monero-wallet-rpc has no
other credential channel.
2026-10-22 22:20:12 -04:00
agent
37690e3d48
tui: spawn the wallet-rpc binary that sits next to the app
All checks were successful
ci / test (pull_request) Successful in 14m27s
ci / sdk (pull_request) Successful in 1m26s
A bare monero-wallet-rpc name is the executable beside this binary
when that file is executable, then PATH. An absolute path is left
alone, so Android and operator overrides keep working. Remote daemon
and remote wallet RPC are unchanged.
2026-10-11 19:41:11 -04:00
agent
a466c43764
tui: the Cuprate start path answers get_info, and the Linux TUI includes it
Some checks failed
ci / test (pull_request) Failing after 2m50s
ci / sdk (pull_request) Successful in 1m23s
android-ci / android (pull_request) Successful in 12m40s
Node::start_wallet_child is the call the TUI makes. The test stores an
in-process testnet source, starts the child, and checks the typed daemon
client's get_info. It does not bootstrap Tor.

cuprate-daemon is now in the Linux TUI default, so a release build of the
onionwire bin links the daemon with no extra feature flag. A build with
--no-default-features still refuses with NO_FEATURE_MSG. cuprated keeps
default-features = false so Cuprate's arti feature cannot pull arti-client
0.44 next to OnionWire's 0.46.

Cargo.lock is unchanged: cuprated was already an optional dependency.
2026-10-08 10:59:45 -04:00
agent
6c1fc5008a
wallet_child: one contract for a start that fails part way
Settle the contract the red feature-gated test was fighting, and make the code
and both tests express it: a start that fails after the chain daemon came up is
all or nothing, the same contract
node::tests::a_missing_binary_fails_the_start_and_leaves_no_child asserts one
level up. A daemon left running behind an error has no owner (the caller gets
the error back, not the client), no handle to stop it, and holds 18081 against
the next start; what a retry reuses is the chain datadir on disk, never a
process that outlived its owner. start_with_creds already behaved that way, so
this states the contract where the stop happens rather than changing it.

in_process_source_launches_a_daemon_and_stop_shuts_it_down was red because its
fake monero-wallet-rpc never binds the port its own readiness gate probes:
start() returns that error, the test discarded it with `let _ =`, and it then
asserted the daemon had survived a failed start. It now holds the published
port the way the module's other start tests do
(test_support::PublishedPortHold) and expects the start to succeed, with every
assertion it had kept. The failure path gets its own test instead, which pins
the tear-down: neither child running, the daemon's port closed, the chain
datadir kept.
2026-09-27 23:16:30 -04:00
agent
081bdfac3e
wallet: wait for monero-wallet-rpc to accept before publishing the child 2026-09-23 20:37:13 -04:00
agent
f5e310fdf4
wallet: wait for the daemon RPC before spawning monero-wallet-rpc 2026-09-23 20:37:13 -04:00
rust-dev
052879fa39
wallet: share the loopback accept wait the SOCKS path already uses 2026-09-23 20:37:13 -04:00
agent
6edcd65e96
tests: take the restart's port from the child that dials it
All checks were successful
ci / test (pull_request) Successful in 6m3s
ci / sdk (pull_request) Successful in 1m14s
ci / fuzz (pull_request) Successful in 4m53s
android-ci / android (pull_request) Successful in 12m15s
`a_restart_opens_the_stored_wallet_file` failed on the Pi runner twice in a
row — CI run 905 job 1373 and run 901 job 1365 — and passed 3/3 on a 16-core
host:

  open the wallet with a passphrase: "wallet file onionwire-1 is not open —
  the wallet RPC never answered (wallet connect: Connection refused (os error
  111))"

The whole `WALLET_OPEN_WAIT` was burned on refusals, so the mock was bound on
a port the restarted child never dialled. Production is not the suspect:
`WalletChild::start_children` builds the child's argv and the `WalletClient`
URL from the same `pick_port` value, and `start_wallet_child_with` installs
that client in `self.wallet` before `open_child_wallet` dials it, so the client
can never carry the previous child's port.

The harness is the suspect. It learned the restarted child's port from the
*shared* argv log — a file every child writes — and cleared that file first.
A clear is not a synchronisation: on a loaded runner the killed child's write
lands after it, so the poller read the port of a child that was already dead
and bound the mock there. Reproduced deterministically with a stand-in whose
exec is late; with the old read the new test fails with the CI message, byte
for byte.

Each fake child now writes `<log>.<pid>` as well, and the shared copy lands
first, so a pid-named file implies the shared one is complete. A test that
spans two children reads the pid-named file: only that child can write it, so
the port belongs to the child that dials it. `WalletChild::wallet_rpc_pid`
(test-only) supplies the pid.

`open_wallet_blocking` already retries while the RPC is unreachable and gives
up after a bounded wait with a typed `OpenFailure::NotAnswering`, so it cannot
refuse forever against a merely slow child: no production change.

new test: node::tests::a_restart_is_not_given_the_stopped_childs_port
2026-09-22 15:37:55 -04:00
agent
8d80a4fd55
tests: write the fake child's argv log with one mv, not append-per-line
Some checks failed
android-ci / android (pull_request) Successful in 12m25s
ci / test (pull_request) Failing after 4m11s
ci / sdk (pull_request) Successful in 1m20s
ci / fuzz (pull_request) Successful in 5m28s
The wallet-child tests learn a spawned stand-in's port by polling its argv
log, and `fake_bin`/`fake_child_bin` truncated the log and then appended
one line per argument -- so a poller could read a prefix. A truncated port
is a *valid* u16 ("427" out of "42765"), so `wait_for_child_rpc_port`
happily returned a port nothing was listening on and the restart's
`open_wallet` died with `Connection refused` after its 10s budget; the
same prefix read is what `loopback_and_clearnet_remotes_carry_no_proxy...`
printed with its `--daemon-address` value missing.

Both tests failed on the first CI run of this branch (ci / test) and are
green in isolation, which is the signature of this race rather than of a
code defect. The argv now lands in the log with a single `mv`, so a reader
sees either no log or the complete one.

Measured with a tight read loop (argv-race-probe.sh): the append version
was caught mid-write 1/300 reads, the mv version 0/300.
2026-09-22 14:33:32 -04:00
rust-dev
59175f6931
wallet: the file-name picker consults the disk, not only the catalogue
Some checks failed
ci / test (pull_request) Failing after 4m25s
ci / sdk (pull_request) Successful in 1m29s
ci / fuzz (pull_request) Successful in 4m57s
android-ci / android (pull_request) Successful in 12m6s
next_wallet_filename returned <default>-<n> for the first n the SQLCipher
catalogue did not hold, and never looked at the wallet directory. monero
writes two files per wallet (<name> and <name>.keys) and refuses a create
that would collide with either, so a file whose catalogue row is gone -
Store::delete_wallet keeps the file, and a create whose record_wallet
failed leaves one - meant every attempt proposed the same taken name and
the daemon answered -21 Cannot create wallet. Already exists. for ever.

Add wallet_name_taken (src/wallet_child.rs): it lists the wallet dir and
answers whether <name> or <name>.keys is already there. next_wallet_filename
now needs the candidate free in both places, and Node::wallet_dir() is the
single source of $ONIONWIRE_HOME/wallet, used by the child spawn too.

Fail closed: an unreadable (or missing) wallet dir is an error, not a
guess. Reads only - nothing here deletes a file the catalogue does not
hold, which may be the only copy of a funded wallet.
2026-09-22 13:41:35 -04:00
agent
ed29131a67
wallet: actually open the wallet file, and remember its passphrase
All checks were successful
ci / test (pull_request) Successful in 6m14s
ci / sdk (pull_request) Successful in 1m44s
android-ci / android (pull_request) Successful in 12m56s
ci / fuzz (pull_request) Successful in 5m1s
`monero-wallet-rpc` starts with no wallet open and keeps one only for the
life of its process, so a restart, a Lock/unlock or a wallet re-point left
a live child answering `-13 No wallet file` to every read while the file
sat on disk. The app now opens the configured catalogue file itself
(`Wallet::open_wallet`, over RPC — never `--wallet-file`/`--password` on
argv, which `ps` exposes) after the child is up, and keeps the passphrase
that does it, sealed with the store data key beside the RPC creds under
its own AAD.

- core: `Wallet::open_wallet`, `WalletConfig::wallet_passphrase`
  (+ `with_wallet_passphrase`, redacted Debug, kept out of the endpoint
  config), `Error::is_unreachable` for the one retryable class (the port
  binds a moment after spawn; a timeout is not a start in progress).
- store: `wallet_config.sealed_passphrase` column (additive, AAD
  `onionwire-store-v1:wallet-passphrase`), read-modify-written so the
  endpoint/login survive; `wallet_save_config` keeps the stored one.
- node: `start_wallet_child` opens the file, `open_wallet_with_passphrase`
  opens a file with a passphrase the user just typed and seals it only
  once a live daemon accepted it, `wallet_status` grows `wallet_open` and
  `needs_passphrase`. A child the RPC refuses is stopped rather than left
  inert; an install with no stored passphrase still starts, and says so.
- tui: one-shot prompt (`WalletSetup::UnlockPass`) on a wallet that needs
  it, reachable from the saved-wallet picker and from `s`.
- sdk: `openWalletWithPassphrase`, the two status fields, README flow.
- docs: WALLET/THREAT_MODEL/README — the passphrase is kept, and the
  consequence (the store passphrase is sufficient to spend) is stated
  rather than implied.

Tests: 4 new node tests drive a real child lifecycle against a loopback
wallet RPC (open on restart, no open without a passphrase, refused
passphrase, sealed-on-success), a `tests/wallet.rs` test asserts the bytes
sent (`open_wallet` + filename + password), and `tests/store.rs` covers
the sealed column and the plaintext->encrypted upgrade with it set.
Mutation-checked: stubbing the two open paths fails all four.
2026-09-22 12:52:08 -04:00
onionwire
0a91744924
wallet: show the chain daemon's sync height and target on the child status
All checks were successful
ci / test (pull_request) Successful in 5m50s
ci / sdk (pull_request) Successful in 1m34s
ci / fuzz (pull_request) Successful in 4m54s
android-ci / android (pull_request) Successful in 12m39s
The user watching an in-process Cuprate node on Android saw only a phase
word (connecting, with 'wallet connect: Connection refused (os error
111)') and asked to see height vs tip.

- WalletChildStatus gains height / target_height, and line() appends
  'sync h/t' when a probe read either number. No percentage is invented
  when the daemon reports no target (h/0 is honest), and an off/exited
  child reports 0/0.
- Node::wallet_child_refresh fills them: one wallet-RPC get_info now
  answers both the readiness gate and the numbers (Wallet::chain_info,
  with chain_ready built on the same parse), and when the wallet RPC is
  down while the chain source is local/in-process, the loopback daemon
  is asked directly (ChildConfig::daemon_probe_addr). A refused daemon
  stays 0/0 — unknown, not caught up. Only refresh dials; the draw path
  reads two atomics.
- UniFFI WalletChildStatus carries the same two u64 fields so Android can
  show them; SDK test covers the round trip.

Tests: cargo test --locked --target x86_64-unknown-linux-gnu (all
green), clippy -D warnings clean; crates/onionwire-sdk cargo test
--locked + clippy clean (separate workspace).
2026-09-19 19:38:52 -04:00
agent
5080652e3b
feat(wallet): mainnet pruned and full on-device chain modes
All checks were successful
ci / test (pull_request) Successful in 5m45s
ci / sdk (pull_request) Successful in 1m34s
ci / fuzz (pull_request) Successful in 4m51s
android-ci / android (pull_request) Successful in 13m2s
Cuprate in-process and TUI keys 1/2/3 pick mainnet pruned, mainnet
full, or experimental testnet. Datadirs are split so a prune store
cannot mix with a full one. Android storage floors scale with the
choice. Cuprate remains pre-production; mainnet is unvalidated.
2026-09-19 12:54:35 -04:00
agent
0acf89a0b4
android: Start wallet no longer looks like a no-op while Cuprate launches
All checks were successful
ci / test (pull_request) Successful in 5m34s
ci / sdk (pull_request) Successful in 1m22s
android-ci / android (pull_request) Successful in 10m48s
ci / fuzz (pull_request) Successful in 4m52s
Tapping Start held the SQLCipher mutex for the whole in-process Node::launch
and blocked the UniFFI tokio worker, so wallet_status stayed off with no
error. Drop the store lock until creds are needed, spawn_blocking the sync
start, and show that Start is in flight.

The APK still runs Cuprate testnet only; this does not add mainnet or prune.
2026-09-19 12:03:01 -04:00
agent
ffea4bf9df
wallet: land the in-process Cuprate chain source on main
All checks were successful
ci / test (pull_request) Successful in 5m39s
ci / sdk (pull_request) Successful in 1m22s
android-ci / android (pull_request) Successful in 8m58s
ci / fuzz (pull_request) Successful in 4m45s
`ChainSource::InProcessCuprate { datadir }` is the fourth chain source: P2P,
consensus and RandomX run inside the OnionWire process instead of as a spawned
`monerod`. The wallet layer does not move — the daemon binds the same loopback
unrestricted RPC (`127.0.0.1:18081`) that `WalletChild::daemon_address` already
returns for a local source, so `wallet_rpc_argv`, the RPC client, the payment
frames and the receipt-verification path are untouched.

- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind the
  `cuprate-daemon` feature, OFF by default. `cuprated`'s own `arti` feature is
  disabled (`default-features = false`): its arti-client 0.44 cannot unify with
  this crate's 0.46, and the in-process daemon is clearnet-only. One Tor stack in
  the process. `Cargo.lock` gains the graph; a default build's
  `cargo tree --locked -e normal -i cuprated` still says "did not match any
  packages", and only `arti-client v0.46.0` is in the lock.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
  (testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
  off), launches it on a runtime it owns, and owns the node. `launch` is
  synchronous on purpose: `WalletChild::start` is sync (the TUI calls it from its
  blocking thread, UniFFI calls it from an async context) and a runtime cannot be
  started from inside a runtime, so the launch runs on a thread of its own and
  the node + its runtime come back over a channel. Dropping the value asks the
  node to shut down and `shutdown_background`s the runtime, which is the only
  exit that cannot panic when the value is dropped inside another runtime.
  The type exists in every build (feature off: `launch` fails with the feature
  name), so the chain-source type, its stored record and its copy do not fork on
  a cargo feature.
- src/wallet.rs: the variant, its label (`in-process node`), and the chain-daemon
  client the wallet line carried (typed `WalletError`, de-chunked HTTP,
  `get_height` over the URI endpoint, an above-the-tip height as one typed
  error). Cuprate answers those three differently from monerod and the
  in-process source is what makes them the *local* case.
- src/wallet_child.rs: launches/holds/stops the node, `chain_datadir` for the
  free-space/ownership question, the honest `chain_copy` line, `kind =
  "cuprate"` in the sealed record, and `ChildConfig::validate` for it.
- src/tui.rs: the wallet screen's chain line carries the testnet caveat when the
  configured source is the in-process one. It computes the line at draw time, so
  `Screen::Wallet`'s shape (which tests construct) does not change.
- docs/WALLET.md, docs/THREAT_MODEL.md, docs/cuprate-android-spike.md: the
  feature flag and how to enable it, where the (fjall) chain store lives, the
  **measured** +11.8 MiB delta, the pre-production/testnet caveat, and the
  in-repo aarch64-linux-android proof with exit codes.

Scope deviations, stated plainly:
- `src/cuprate.rs` and its one `src/lib.rs` module line are not in the card's
  allowed list; the card's own deliverable describes the module's behaviour.
- `crates/onionwire-sdk/src/lib.rs` is forbidden, but adding a variant to a
  `pub enum` that the SDK matches exhaustively breaks the SDK workspace, and the
  root CI `sdk` job runs on every PR. One variant plus two match arms land here
  so the SDK keeps compiling (`cargo test --locked` + clippy clean); the SDK card
  owns the rest — feature passthrough, the config field's semantics, the label
  and its tests, and the Android check.
- `tests/wallet.rs` carries the launch test. `tests/tui_frames.rs` is untouched:
  main has no `ChainChoice` to pin (the chain-source picker is the unmerged F7
  work, and `docs/WALLET.md` says so rather than describing a picker that does
  not exist).

Proof (all on this tree):
- Default build: `cargo test --locked --target x86_64-unknown-linux-gnu` → 345
  passed / 0 failed across 33 suites, exit 0; `cargo clippy --locked
  --all-targets --target x86_64-unknown-linux-gnu -- -D warnings` exit 0.
- Feature on: `cargo test --locked --features cuprate-daemon --target
  x86_64-unknown-linux-gnu` → 347 passed / 0 failed, exit 0; same clippy with
  `--features cuprate-daemon` exit 0. The two extra tests are the real thing:
  `wallet_child::tests::in_process_source_launches_a_daemon_and_stop_shuts_it_down`
  and `tests/wallet.rs::an_in_process_cuprate_node_answers_the_typed_daemon_client`
  — the latter launches the node, drives `get_info` / `get_height` / `get_block`
  through the typed client, checks the above-the-tip 500 maps to
  `DaemonHeightOutOfRange`, checks the chain store is under the chain datadir,
  and checks the listener dies with the node.
- aarch64: `cargo check --locked --release --target aarch64-linux-android
  --features cuprate-daemon` exit 0 (1m 50s), and the full link exit 0
  (`cargo rustc ... --bin onionwire -- <NDK C++ runtime / compiler-rt link
  args>`) producing `ELF 64-bit LSB pie executable, ARM aarch64, for Android 26,
  built by NDK r28c`.
- Size: stripped aarch64 release binary, 24,725,704 bytes without the feature and
  37,053,472 with it — +12,327,768 bytes (≈ +11.8 MiB), the figure
  `docs/WALLET.md` now quotes.
2026-09-18 13:45:59 -04:00
agent
440a37caf0
wallet: wire the app-owned child into the node and TUI
The module was dead code: nothing started the child, so the payment spines
could only ever see an env-configured monero-wallet-rpc. Now:

- Node::start_wallet_child / stop_wallet_child / wallet_child_status /
  wallet_child_refresh / wallet_child_config / set_wallet_child_config. The
  start path honours the configured absolute binary path, points the node's
  wallet at the child, and shutdown() stops the child rather than orphaning
  a spend-capable RPC behind a loopback socket.
- The status is derived from the real process (try_wait) and the last probe:
  off / connecting / syncing / ready / exited, plus the chain-source label.
  A dead child is never reported ready.
- ChildConfig (source, wallet_rpc_bin, arti_bin, wallet_filename) persists in
  the sealed wallet_child record next to the generated creds; the record is a
  read-modify-write so first-start creds never clobber a saved config.
- TUI: F6 gains s (start) / x (stop) / p (probe) and a child status row, and
  the /pay and /tip key handlers now call the core readiness guard before
  sending.
2026-09-18 09:28:11 -04:00
agent
11a021acb3
chore: wallet child lifecycle + chain source + SOCKS proxy (t_1bcecf90) 2026-09-18 09:28:11 -04:00
agent
bcf7ec31c1
wallet: app-owned child lifecycle + user-chosen ChainSource
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-18 09:28:11 -04:00