Compare commits

..
Author SHA1 Message Date
agent
b45dbf95be
wallet: app-owned child lifecycle + user-chosen ChainSource
All checks were successful
ci / test (pull_request) Successful in 4m23s
ci / sdk (pull_request) Successful in 1m16s
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 18:55:12 -04:00

View file

@ -110,7 +110,10 @@ impl WalletChild {
/// is reaped here so a later `stop` is a no-op.
pub fn running(&self) -> bool {
let _ = self.reap_exited();
self.monerod.lock().map(|g| g.is_some()).unwrap_or(false)
self.monerod
.lock()
.map(|g| g.is_some())
.unwrap_or(false)
|| self.wallet_rpc.lock().map(|g| g.is_some()).unwrap_or(false)
}
@ -451,8 +454,10 @@ mod tests {
use std::io::Write;
fn tmp_dir(tag: &str) -> PathBuf {
let dir =
std::env::temp_dir().join(format!("onionwire-child-{tag}-{}", std::process::id()));
let dir = std::env::temp_dir().join(format!(
"onionwire-child-{tag}-{}",
std::process::id()
));
let _ = fs::remove_dir_all(&dir);
dir
}
@ -467,12 +472,8 @@ mod tests {
let mut f = fs::File::create(&path).unwrap();
writeln!(f, "#!/bin/sh").unwrap();
writeln!(f, ": > '{}'", log.display()).unwrap();
writeln!(
f,
"for a in \"$@\"; do printf '%s\\n' \"$a\" >> '{}'; done",
log.display()
)
.unwrap();
writeln!(f, "for a in \"$@\"; do printf '%s\\n' \"$a\" >> '{}'; done", log.display())
.unwrap();
writeln!(f, "sleep 30").unwrap();
drop(f);
let mut perms = fs::metadata(&path).unwrap().permissions();
@ -571,10 +572,7 @@ mod tests {
.collect();
assert!(pairs.contains(&("--rpc-bind-ip", "127.0.0.1")), "{argv:?}");
assert!(pairs.contains(&("--rpc-bind-port", "39127")), "{argv:?}");
assert!(
pairs.contains(&("--rpc-login", "owuser:owpass")),
"{argv:?}"
);
assert!(pairs.contains(&("--rpc-login", "owuser:owpass")), "{argv:?}");
assert!(
pairs.contains(&("--wallet-dir", dir.to_str().unwrap())),
"{argv:?}"
@ -642,10 +640,7 @@ mod tests {
);
let rpc_argv = wait_for_argv(&rpc_log);
assert!(
rpc_argv.iter().any(|a| a == "--rpc-bind-ip"),
"{rpc_argv:?}"
);
assert!(rpc_argv.iter().any(|a| a == "--rpc-bind-ip"), "{rpc_argv:?}");
assert!(rpc_argv.iter().any(|a| a == "127.0.0.1"), "{rpc_argv:?}");
assert!(rpc_argv.iter().any(|a| a == "--rpc-login"), "{rpc_argv:?}");
assert!(rpc_argv.iter().any(|a| a == "--wallet-dir"), "{rpc_argv:?}");
@ -670,10 +665,7 @@ mod tests {
.expect("login");
let (user, pass) = login_arg.split_once(':').expect("user:pass");
assert_ne!(user, pass, "user and password must be independent");
assert!(
url.contains(user) && url.contains(pass),
"{url} vs {login_arg}"
);
assert!(url.contains(user) && url.contains(pass), "{url} vs {login_arg}");
// Creds live sealed in the store, and nothing in the wallet dir holds
// them in the clear.
@ -683,7 +675,9 @@ mod tests {
let path = entry.unwrap().path();
let body = fs::read(&path).unwrap_or_default();
assert!(
!body.windows(pass.len()).any(|w| w == pass.as_bytes()),
!body
.windows(pass.len())
.any(|w| w == pass.as_bytes()),
"{} holds the RPC password in the clear",
path.display()
);