sdk: expose a live wallet-child probe over UniFFI (wallet_child_refresh) #132

Merged
sirius merged 3 commits from wt/t_0a355a62 into main 2026-09-20 04:32:39 +00:00
Owner

Why

The Android wallet screen polls Wire::wallet_status() every 2s, and that call is the cheap cached read (Node::wallet_child_status, "no dial"). state / height / target_height are written only by Node::wallet_child_refresh, which over UniFFI was reachable from exactly one place: inside start_wallet_child. So the sync h/t segment only moved when a chain-mode tap happened to re-start the child.

What

One additive export, in the same impl Wire block as the other wallet-child calls:

pub async fn wallet_child_refresh(&self) -> WResult<WalletChildStatus> {
    let node = self.node()?;
    let source = node.wallet_child_config().source;
    Ok(child_status(node.wallet_child_refresh().await, &source))
}
  • Reuses the existing child_status mapper, so the record is the same shape as wallet_status() — no new UniFFI record, no new field, no new crate.
  • Reuses the existing core probe (Node::wallet_child_refresh) as the only probe path. src/ is untouched, and wallet_status() keeps its documented cheap, non-dialing semantics (Kotlin uses it for first paint).
  • Doc comment states the dial (loopback wallet RPC; the local daemon's get_info when the wallet RPC does not answer), that it never spawns or starts a child, that it is safe from a refresh loop but not free (poll on the order of seconds), and the honest limit: with no live child the core short-circuits and returns the cached off / exited snapshot, so it cannot invent ready.
  • docs/WALLET.md enumerates the SDK wallet-child surface, so its Android bullet now names the probe and labels wallet_status() as the cached read.

Tests

crates/onionwire-sdk has no offline Node: open_wire is the only constructor of Wire and it bootstraps Arti and publishes an onion service. The card's literal case ("a node with no child") therefore cannot be assembled in the SDK's own test crate. What is covered here is what this crate owns:

  • an_unprobed_child_is_off_whichever_read_reports_it — the unprobed snapshot maps to the same off record for both exported reads. The expected record is an exhaustive struct literal, so adding a field to WalletChildStatus stops the test compiling (the additive-only requirement, enforced by the compiler).
  • wallet_child_refresh_on_a_stopped_handle_is_stopped_error — the new export goes through the same node() accessor, so a shut-down handle is a typed WireError.Stopped, not a panic.
  • The existing an_unprobed_child_reports_an_unknown_chain_progress and the rest of the module stay green.

The core-side short-circuit (wallet_child is None implies return the cached snapshot) is exercised by src/node.rs's own tests, which cannot be reached from this crate.

Local gate (SDK is its own workspace; a root cargo test never builds it):

cd crates/onionwire-sdk
TMPDIR=/home/lancelot/.hermes/tmp/ow-sdk CARGO_TARGET_DIR=/home/lancelot/.hermes/tmp/ow-sdk-target cargo test --locked
  39 passed; 0 failed (lib) + 1 + 1 integration tests
cargo clippy --locked --all-targets -- -D warnings
  exit 0

crates/onionwire-sdk/Cargo.lock is unchanged (no dependency change). crates/onionwire-sdk/src/lib.rs carries only the one rustfmt hunk inherited from main (same diff count against git show HEAD:crates/onionwire-sdk/src/lib.rs).

Generated bindings prove the surface: uniffi-bindgen generate --library target/debug/libonionwire_sdk.so --language kotlin emits

suspend fun `walletChildRefresh`(): WalletChildStatus

which is exactly what the Android polling card consumes.

## Why The Android wallet screen polls `Wire::wallet_status()` every 2s, and that call is the cheap cached read (`Node::wallet_child_status`, "no dial"). `state` / `height` / `target_height` are written only by `Node::wallet_child_refresh`, which over UniFFI was reachable from exactly one place: inside `start_wallet_child`. So the `sync h/t` segment only moved when a chain-mode tap happened to re-start the child. ## What One additive export, in the same `impl Wire` block as the other wallet-child calls: ```rust pub async fn wallet_child_refresh(&self) -> WResult<WalletChildStatus> { let node = self.node()?; let source = node.wallet_child_config().source; Ok(child_status(node.wallet_child_refresh().await, &source)) } ``` - Reuses the existing `child_status` mapper, so the record is the same shape as `wallet_status()` — no new UniFFI record, no new field, no new crate. - Reuses the existing core probe (`Node::wallet_child_refresh`) as the only probe path. `src/` is untouched, and `wallet_status()` keeps its documented cheap, non-dialing semantics (Kotlin uses it for first paint). - Doc comment states the dial (loopback wallet RPC; the local daemon's `get_info` when the wallet RPC does not answer), that it never spawns or starts a child, that it is safe from a refresh loop but not free (poll on the order of seconds), and the honest limit: with no live child the core short-circuits and returns the cached `off` / `exited` snapshot, so it cannot invent `ready`. - `docs/WALLET.md` enumerates the SDK wallet-child surface, so its Android bullet now names the probe and labels `wallet_status()` as the cached read. ## Tests `crates/onionwire-sdk` has no offline `Node`: `open_wire` is the only constructor of `Wire` and it bootstraps Arti and publishes an onion service. The card's literal case ("a node with no child") therefore cannot be assembled in the SDK's own test crate. What is covered here is what this crate owns: - `an_unprobed_child_is_off_whichever_read_reports_it` — the unprobed snapshot maps to the same `off` record for both exported reads. The expected record is an exhaustive struct literal, so adding a field to `WalletChildStatus` stops the test compiling (the additive-only requirement, enforced by the compiler). - `wallet_child_refresh_on_a_stopped_handle_is_stopped_error` — the new export goes through the same `node()` accessor, so a shut-down handle is a typed `WireError.Stopped`, not a panic. - The existing `an_unprobed_child_reports_an_unknown_chain_progress` and the rest of the module stay green. The core-side short-circuit (`wallet_child` is `None` implies return the cached snapshot) is exercised by `src/node.rs`'s own tests, which cannot be reached from this crate. Local gate (SDK is its own workspace; a root `cargo test` never builds it): ``` cd crates/onionwire-sdk TMPDIR=/home/lancelot/.hermes/tmp/ow-sdk CARGO_TARGET_DIR=/home/lancelot/.hermes/tmp/ow-sdk-target cargo test --locked 39 passed; 0 failed (lib) + 1 + 1 integration tests cargo clippy --locked --all-targets -- -D warnings exit 0 ``` `crates/onionwire-sdk/Cargo.lock` is unchanged (no dependency change). `crates/onionwire-sdk/src/lib.rs` carries only the one rustfmt hunk inherited from `main` (same diff count against `git show HEAD:crates/onionwire-sdk/src/lib.rs`). Generated bindings prove the surface: `uniffi-bindgen generate --library target/debug/libonionwire_sdk.so --language kotlin` emits ```kotlin suspend fun `walletChildRefresh`(): WalletChildStatus ``` which is exactly what the Android polling card consumes.
sdk: expose wallet_child_refresh — a live wallet-child probe over UniFFI
All checks were successful
ci / test (pull_request) Successful in 5m16s
ci / sdk (pull_request) Successful in 1m17s
android-ci / android (pull_request) Successful in 13m18s
ci / fuzz (pull_request) Successful in 18m36s
db12f4838b
Wire::wallet_status() is the cheap cached read (no dial); only
Node::wallet_child_refresh() writes state/height/target_height, and it was
reachable over UniFFI from exactly one place — start_wallet_child. An Android
refresh loop polling wallet_status() therefore shows a frozen sync line.

Add the additive export, reusing the existing child_status mapper so the record
is the same shape as wallet_status(), and the core probe as the only probe
path. Docs: one sentence in docs/WALLET.md, which enumerates the SDK
wallet-child surface.

Tests: SDK-level (a Wire cannot be built offline in this crate — open_wire
bootstraps Arti): the unprobed child maps to the same 'off' record both reads
report, pinned with an exhaustive record literal; and the probe on a stopped
handle is a typed WireError.Stopped.
Audit the operator docs against the source: pin downloads to v0.14.0,
document the real CLI/flags/env/F-keys (including F9, no F7), keep 18081
as the app-owned daemon port, describe the local chat outbox vs a
server-side one, and stop implying SECURITY_AUDIT.md is a third-party
audit. Spike reports stay; they get a status header only.
Merge pull request 'docs: rewrite README + docs to match main (audit in PR body)' (#133) from onionwire/t_96d3bd1a-docs-audit-the-onionwire-source-against into wt/t_0a355a62
All checks were successful
android-ci / android (pull_request) Successful in 12m13s
ci / test (pull_request) Successful in 5m16s
ci / sdk (pull_request) Successful in 1m6s
ci / fuzz (pull_request) Successful in 4m54s
803567635f
Reviewed-on: #133
sirius merged commit fa0e4b2f6c into main 2026-09-20 04:32:39 +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!132
No description provided.