wallet: show the chain daemon's sync height/target on the child status #129

Merged
sirius merged 1 commit from onionwire/t_bd2e2cd0-onionwire-wallet-show-daemon-sync-height into main 2026-09-20 00:12:16 +00:00
Owner

What

The Android in-process Cuprate wallet showed only a phase word — connecting · in-process mainnet pruned · node starting, with wallet connect: Connection refused (os error 111) — so there was no way to see how far the chain had got. This adds the daemon's height and target to the wallet-child status, on the TUI one-liner and through UniFFI.

Line shape (prefix and node_state words unchanged):

child  connecting · in-process node · sync 1160/3090939
child  connecting · in-process node · sync 1160/3090939 · wallet connect: Connection refused (os error 111)

0/0 — or no sync segment — means unknown: child off/exited, probe failed, or the daemon reported no target. No percentage is derived (h/0 is honest), and this is never a wallet-scan height.

How

  • src/wallet_child.rs: WalletChildStatus gains height / target_height; line() appends · sync h/t when either is non-zero, error text still last. New ChildConfig::daemon_probe_addr() returns the loopback daemon address only for Local / InProcessCuprate — a remote (incl. onion) daemon is the wallet child's to dial, never probed by a status refresh.
  • src/wallet.rs: Wallet::chain_info() is the single get_info parse; chain_ready() is now chain_info().ready(), so the spend gate and the status line ask once instead of twice. ChainInfo::ready() keeps the exact predicate (synchronized explicitly true, height > 0, height >= target unless target is 0).
  • src/node.rs: child_height / child_target atomics (same shape as child_synced), read on the draw path, written only by wallet_child_refresh(). Refresh uses the wallet RPC when it answers; when it does not, and the source is local/in-process, it asks the daemon directly (3 s budget, local TCP). Start/stop/shutdown reset the probe, and an off/exited child reports 0/0 regardless of what the last probe left behind.
  • crates/onionwire-sdk/src/lib.rs: the UniFFI record carries the same two u64 fields (after node_state, before last_error), copied in child_status.
  • src/tui.rs: no change needed — the wallet screen already renders wallet_child_line() and the in-process testnet caveat after it, not instead of it. No second height widget.
  • docs/WALLET.md: one paragraph documenting the sync h/t segment and what 0/0 means.

Tests (all run)

  • src/wallet_child.rs: line with 0/0 is unchanged and contains no sync; 1160/3090939; 4549/0 with no %; error stays after the segment; only loopback sources get a probe address (Local + InProcessCuprate yes; None + onion + clearnet-remote no).
  • src/node.rs: a mock wallet RPC that answers get_address / get_balance / a syncing get_info fills 4549/0 and the line shows sync 4549/0; the 111 case — wallet RPC refused, Local source, mock daemon on 127.0.0.1:18081 — fills 1160/3090939 while the state correctly stays connecting.
  • SDK: the_daemons_height_and_target_reach_the_sdk_record (1160/3090939 round trip, state still verbatim) and an_unprobed_child_reports_an_unknown_chain_progress (0/0).

Evidence:

cargo test --locked --target x86_64-unknown-linux-gnu   -> all suites green (lib 67 passed)
cargo clippy --locked --all-targets -- -D warnings      -> exit 0
(crates/onionwire-sdk) cargo test --locked              -> 37 passed
(crates/onionwire-sdk) cargo clippy --locked --all-targets -- -D warnings -> exit 0

rustfmt --edition 2024 --check on the four touched Rust files reports the same hunk count as origin/main, so no inherited churn was added (src/node.rs and the SDK already carried 2 and 1 pre-existing hunks).

Notes / deviations

  • The daemon-fallback test binds 127.0.0.1:18081; if that port is already held (a real monerod on the dev box) the test prints a skip note and returns rather than replacing someone else's daemon. On CI and on this machine it bound and served the answer.
  • android/CUPRATE_DAEMON.md still says "No sync height. WalletChildStatus has no height field." That file is android/**, forbidden for this card (apk-dev owns it) — the UniFFI fields are in place, so a one-line doc fix there is all that is left. Flagged rather than edited out of scope.
  • No release cut.
## What The Android in-process Cuprate wallet showed only a phase word — `connecting · in-process mainnet pruned · node starting`, with `wallet connect: Connection refused (os error 111)` — so there was no way to see how far the chain had got. This adds the **daemon's** height and target to the wallet-child status, on the TUI one-liner and through UniFFI. Line shape (prefix and `node_state` words unchanged): ``` child connecting · in-process node · sync 1160/3090939 child connecting · in-process node · sync 1160/3090939 · wallet connect: Connection refused (os error 111) ``` `0/0` — or no `sync` segment — means unknown: child off/exited, probe failed, or the daemon reported no target. No percentage is derived (`h/0` is honest), and this is never a wallet-scan height. ## How - `src/wallet_child.rs`: `WalletChildStatus` gains `height` / `target_height`; `line()` appends ` · sync h/t` when either is non-zero, error text still last. New `ChildConfig::daemon_probe_addr()` returns the loopback daemon address **only** for `Local` / `InProcessCuprate` — a remote (incl. onion) daemon is the wallet child's to dial, never probed by a status refresh. - `src/wallet.rs`: `Wallet::chain_info()` is the single `get_info` parse; `chain_ready()` is now `chain_info().ready()`, so the spend gate and the status line ask once instead of twice. `ChainInfo::ready()` keeps the exact predicate (`synchronized` explicitly true, height > 0, height >= target unless target is 0). - `src/node.rs`: `child_height` / `child_target` atomics (same shape as `child_synced`), read on the draw path, written only by `wallet_child_refresh()`. Refresh uses the wallet RPC when it answers; when it does not, and the source is local/in-process, it asks the daemon directly (3 s budget, local TCP). Start/stop/shutdown reset the probe, and an off/exited child reports `0/0` regardless of what the last probe left behind. - `crates/onionwire-sdk/src/lib.rs`: the UniFFI record carries the same two `u64` fields (after `node_state`, before `last_error`), copied in `child_status`. - `src/tui.rs`: **no change needed** — the wallet screen already renders `wallet_child_line()` and the in-process testnet caveat after it, not instead of it. No second height widget. - `docs/WALLET.md`: one paragraph documenting the `sync h/t` segment and what `0/0` means. ## Tests (all run) - `src/wallet_child.rs`: line with `0/0` is unchanged and contains no `sync`; `1160/3090939`; `4549/0` with no `%`; error stays after the segment; only loopback sources get a probe address (Local + InProcessCuprate yes; None + onion + clearnet-remote no). - `src/node.rs`: a mock wallet RPC that answers `get_address` / `get_balance` / a syncing `get_info` fills `4549/0` and the line shows `sync 4549/0`; the 111 case — wallet RPC refused, `Local` source, mock daemon on `127.0.0.1:18081` — fills `1160/3090939` while the state correctly stays `connecting`. - SDK: `the_daemons_height_and_target_reach_the_sdk_record` (1160/3090939 round trip, `state` still verbatim) and `an_unprobed_child_reports_an_unknown_chain_progress` (0/0). Evidence: ``` cargo test --locked --target x86_64-unknown-linux-gnu -> all suites green (lib 67 passed) cargo clippy --locked --all-targets -- -D warnings -> exit 0 (crates/onionwire-sdk) cargo test --locked -> 37 passed (crates/onionwire-sdk) cargo clippy --locked --all-targets -- -D warnings -> exit 0 ``` `rustfmt --edition 2024 --check` on the four touched Rust files reports the same hunk count as `origin/main`, so no inherited churn was added (`src/node.rs` and the SDK already carried 2 and 1 pre-existing hunks). ## Notes / deviations - The daemon-fallback test binds `127.0.0.1:18081`; if that port is already held (a real `monerod` on the dev box) the test prints a skip note and returns rather than replacing someone else's daemon. On CI and on this machine it bound and served the answer. - `android/CUPRATE_DAEMON.md` still says "No sync height. `WalletChildStatus` has no height field." That file is `android/**`, forbidden for this card (apk-dev owns it) — the UniFFI fields are in place, so a one-line doc fix there is all that is left. Flagged rather than edited out of scope. - No release cut.
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
0a91744924
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).
sirius merged commit d203594294 into main 2026-09-20 00:12:16 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!129
No description provided.