wallet: wait for listeners before treating connect refusal as an error #155
Loading…
Reference in a new issue
No description provided.
Delete branch "onionwire/t_c8fe0549-onionwire-wallet-start-waits-for-the-dae"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements Task 1, 2, 3, 4 and 7 of
/home/lancelot/.hermes/plans/2026-09-23_193050-stabilize-cuprate-wallet-startup.md(Rust half + one doc sentence). Task 5/6 (Android Kotlin) are a separateapk-devcard; Task 8's end-to-end verification is the follow-up verification card.What changed
Start waits for the listeners.
monero-wallet-rpcis not spawned until127.0.0.1:18081accepts a TCP connection (5s budget,DAEMON_LISTENER_TIMEOUT). Only the sources that bind that port are waited on —ChainSource::LocalandChainSource::InProcessCuprate; a remote or receive-only source has no loopback daemon to dial.--rpc-bind-portaccepts (5s,WALLET_RPC_LISTENER_TIMEOUT), sostart_wallet_child_withcannot publish a client whose port is still closed.WalletChild::poll_loopback) that the SOCKS path already had;socks_listener_readykeeps its existing error text byte-for-byte. The new gate's message names the port and what did not accept (chain daemon RPC on 127.0.0.1:18081 did not accept ... — not continuing startup against a closed port).creds()call is still the onlyStoremutex instart_childrenand still runs after the daemon is up, andWalletChildStatus::line()and the SOCKS error string are untouched.open_wallet_blocking's 10s retry is untouched. TCP accept is not "HTTP is servingopen_wallet".A connect refusal while the child is coming up is not a status error.
wallet::error_is_unreachable(msg)is now the one rule (the oldError::is_unreachablewas inlined and could drift from the row's copy).node::probe_error(connected, probed, previous)stores the probe's error only when it is the RPC's own answer.wallet connect:/wallet write:while the row is not connected leaves the row's previous real error in place instead of flashing the string and clearing it on the next tick.-13,No wallet file, a refused passphrase, and the same connect text once the child has been answering (so a child that accepted once and then died still shows), because the filter is keyed on the probe result, not on the string alone.Scope note: the lib test harness had to learn to present the port
src/node.rsandsrc/wallet_child.rs's test modules are inside the card's allow-list, and they needed changes — ashfake cannot bind a port. Without them 13 start-path tests failed at the new gate, which is exactly what the gate should do to a fake.#[cfg(test)] wallet_child::test_support::PublishedPortHold: watches a fake child's argv log and holds the--rpc-bind-portit publishes, releasing it when the gate's own probe connects (so a dial after the gate still sees the child's real state, never a stand-in). A rewrite of the log is a new publication, so a restart whose argv is identical is held again.<argv.log>.<pid>on disk (wait_for_restarted_rpc_port, pid-shaped names only — a child killed between its shared write and its own leaves a.writingtemp that still names the old port) and bind their mock before the gate's probe.a_restart_is_not_given_the_stopped_childs_port's stale-shared-log premise is asserted at the moment it is true, with a fake that lands its own log first and the shared path 2s later.Not done here
main.Evidence
cargo test --locked --target x86_64-unknown-linux-gnu --lib -- --test-threads=8Named tests:
cargo check --locked --target x86_64-unknown-linux-gnu— exit 0.cargo clippy --locked --target x86_64-unknown-linux-gnu --all-targets -- -D warnings— clean.rustfmt --edition 2024 --checkonsrc/wallet.rs(0 diffs) andsrc/node.rs(3 diffs, all inherited at HEAD: lines 31/647/723).git diff --stat origin/main..HEAD:docs/WALLET.md,src/node.rs,src/wallet.rs,src/wallet_child.rs— the four allowed files only.e683d092e22f3d5d69c3