onionwire-sdk: expose the on-device Cuprate chain source (choice, lifecycle, node status) #111

Owner

What this does

Part 2 of "cuprated built in": makes the in-process Cuprate chain source reachable from Kotlin. Stacked on #110 (onionwire/t_04975420-..., base main) — retarget to main when #110 merges.

Three things, all in crates/onionwire-sdk/:

  1. ChainChoice.InProcessCuprate (Kotlin ChainChoice.IN_PROCESS_CUPRATE) — the core variant the parent card landed, with the SDK's feature passthrough (cuprate-daemon = ["onionwire/cuprate-daemon"]). Selecting it needs no binary path on either side.
  2. No invented path. monerod_datadir for that kind defaults to $ONIONWIRE_HOME/chain when the string is empty (the per-identity chain directory docs/WALLET.md already pins). A Kotlin caller that does not know a path passes "" and gets the same directory a spawned monerod would use. An explicit path is taken as given. None / Local / Remote behave exactly as before.
  3. Node-visible status. wallet_status() now carries, beside the core's own five words and the in-process node label:
    • chain_in_process — the configured source is this app's node, not a spawned/monitored daemon;
    • node_available — this build has cuprate-daemon (grey the option out rather than start-and-catch);
    • node_state — off / starting / syncing / ready / exited for the in-process source, empty for every other source.

The lifecycle stays the core's: start_wallet_child() is one call (the core launches the node and the wallet child in it), stop_wallet_child() shuts both down, both idempotent. The SDK is a pass-through, not a second state machine.

Honesty notes

  • node_state is a projection of the core's real child state (connecting -> starting), never a timer, env var, file, or outbox row.
  • Limit, stated rather than papered over: the core exposes no separate liveness signal for the in-process node (it is a value the app owns, not a pid), so a daemon that dies after its wallet child came up reads as syncing, never ready — it cannot be reported exited. Documented on node_state itself.
  • Cuprate stays labelled as what it is: in-process node, testnet only, pre-production (the doc comments carry it; the core's ChainSource::label() is the string rendered).

Evidence (this tree, commit 64a1f29)

check result
SDK cargo test --locked (feature off) exit 0 — 33 lib + 2 integration passed
SDK cargo clippy --locked --all-targets -- -D warnings (feature off) exit 0
SDK cargo test --locked --features cuprate-daemon exit 0 — 33 passed (cuprated graph compiled)
SDK cargo clippy --locked --all-targets --features cuprate-daemon -- -D warnings exit 0
SDK cargo check --locked --release --target aarch64-linux-android --features cuprate-daemon exit 0, 1m26s, 0 warnings (randomx-rs + cuprated compiled)
root cargo test --locked --target x86_64-unknown-linux-gnu exit 0 — 345 passed, 0 failed
crates/onionwire-sdk/Cargo.lock regenerated (+1480 lines: cuprated @ 4f8fcd1b and its graph)

New tests (6): datadir default / explicit passthrough, all four choices round-tripping through the SDK mapping, the five-state node projection, empty node_state for non-in-process sources, and node_available matching onionwire::cuprate::available().

Not proven here: a real node launch through the SDK. Wire is only constructible via open_wire (Arti bootstrap, network), so the SDK's own tests cannot drive start_wallet_child() end to end; the launch path is the parent card's, already proven in the core (tests/wallet.rs). SDK-side start/stop are pass-throughs to that.

Scope deviations

  • docs/WALLET.md: SDK-facing lines only (the chain-source label list, the "Selecting it" paragraph, and the UniFFI bullet).
  • Nothing in src/**, root manifests, android/**, or the workflows was touched.

Kotlin-visible names

enum class ChainChoice { NONE, LOCAL, IN_PROCESS_CUPRATE, REMOTE }
data class ChainConfig(kind, monerodBin, monerodDatadir, host, port, walletRpcBin, artiBin, walletFilename)
data class WalletChildStatus(state, running, configured, chainSource, chainInProcess, nodeAvailable, nodeState, lastError)

wire.setChainSource(ChainConfig(kind = ChainChoice.IN_PROCESS_CUPRATE, monerodDatadir = "", ...))
wire.startWalletChild()
wire.walletStatus()   // e.g. chainSource = "in-process node", nodeState = "syncing"

Generated with uniffi-bindgen --library libonionwire_sdk.so --language kotlin against this branch's cdylib.

PR #110 must merge first; this branch already contains it.

## What this does Part 2 of "cuprated built in": makes the in-process Cuprate chain source reachable from Kotlin. Stacked on **#110** (`onionwire/t_04975420-...`, base `main`) — retarget to `main` when #110 merges. Three things, all in `crates/onionwire-sdk/`: 1. **`ChainChoice.InProcessCuprate`** (Kotlin `ChainChoice.IN_PROCESS_CUPRATE`) — the core variant the parent card landed, with the SDK's feature passthrough (`cuprate-daemon = ["onionwire/cuprate-daemon"]`). Selecting it needs **no binary path** on either side. 2. **No invented path.** `monerod_datadir` for that kind defaults to `$ONIONWIRE_HOME/chain` when the string is empty (the per-identity chain directory `docs/WALLET.md` already pins). A Kotlin caller that does not know a path passes `""` and gets the same directory a spawned `monerod` would use. An explicit path is taken as given. `None` / `Local` / `Remote` behave exactly as before. 3. **Node-visible status.** `wallet_status()` now carries, beside the core's own five words and the `in-process node` label: - `chain_in_process` — the configured source is this app's node, not a spawned/monitored daemon; - `node_available` — this build has `cuprate-daemon` (grey the option out rather than start-and-catch); - `node_state` — `off` / `starting` / `syncing` / `ready` / `exited` for the in-process source, **empty** for every other source. The lifecycle stays the core's: `start_wallet_child()` is one call (the core launches the node *and* the wallet child in it), `stop_wallet_child()` shuts both down, both idempotent. The SDK is a pass-through, not a second state machine. ## Honesty notes - `node_state` is a **projection of the core's real child state** (connecting -> starting), never a timer, env var, file, or outbox row. - **Limit, stated rather than papered over:** the core exposes no separate liveness signal for the in-process node (it is a value the app owns, not a pid), so a daemon that dies after its wallet child came up reads as `syncing`, never `ready` — it cannot be reported `exited`. Documented on `node_state` itself. - Cuprate stays labelled as what it is: `in-process node`, testnet only, pre-production (the doc comments carry it; the core's `ChainSource::label()` is the string rendered). ## Evidence (this tree, commit 64a1f29) | check | result | |---|---| | SDK `cargo test --locked` (feature off) | exit 0 — 33 lib + 2 integration passed | | SDK `cargo clippy --locked --all-targets -- -D warnings` (feature off) | exit 0 | | SDK `cargo test --locked --features cuprate-daemon` | exit 0 — 33 passed (cuprated graph compiled) | | SDK `cargo clippy --locked --all-targets --features cuprate-daemon -- -D warnings` | exit 0 | | SDK `cargo check --locked --release --target aarch64-linux-android --features cuprate-daemon` | exit 0, 1m26s, 0 warnings (`randomx-rs` + `cuprated` compiled) | | root `cargo test --locked --target x86_64-unknown-linux-gnu` | exit 0 — 345 passed, 0 failed | | `crates/onionwire-sdk/Cargo.lock` | regenerated (+1480 lines: cuprated @ 4f8fcd1b and its graph) | New tests (6): datadir default / explicit passthrough, all four choices round-tripping through the SDK mapping, the five-state node projection, empty `node_state` for non-in-process sources, and `node_available` matching `onionwire::cuprate::available()`. **Not proven here:** a real node launch through the SDK. `Wire` is only constructible via `open_wire` (Arti bootstrap, network), so the SDK's own tests cannot drive `start_wallet_child()` end to end; the launch path is the parent card's, already proven in the core (`tests/wallet.rs`). SDK-side `start`/`stop` are pass-throughs to that. ## Scope deviations - `docs/WALLET.md`: SDK-facing lines only (the chain-source label list, the "Selecting it" paragraph, and the UniFFI bullet). - Nothing in `src/**`, root manifests, `android/**`, or the workflows was touched. ## Kotlin-visible names ``` enum class ChainChoice { NONE, LOCAL, IN_PROCESS_CUPRATE, REMOTE } data class ChainConfig(kind, monerodBin, monerodDatadir, host, port, walletRpcBin, artiBin, walletFilename) data class WalletChildStatus(state, running, configured, chainSource, chainInProcess, nodeAvailable, nodeState, lastError) wire.setChainSource(ChainConfig(kind = ChainChoice.IN_PROCESS_CUPRATE, monerodDatadir = "", ...)) wire.startWalletChild() wire.walletStatus() // e.g. chainSource = "in-process node", nodeState = "syncing" ``` Generated with `uniffi-bindgen --library libonionwire_sdk.so --language kotlin` against this branch's cdylib. PR #110 must merge first; this branch already contains it.
sdk: expose the on-device Cuprate chain source (choice, lifecycle, node status)
All checks were successful
ci / test (pull_request) Successful in 5m8s
ci / sdk (pull_request) Successful in 1m12s
android-ci / android (pull_request) Successful in 9m43s
ci / fuzz (pull_request) Successful in 4m41s
64a1f29e9e
ChainChoice gains InProcessCuprate, the SDK passes the core's cuprate-daemon
feature through as its own, and an empty monerod_datadir for that kind resolves
to $ONIONWIRE_HOME/chain so Kotlin never invents a path. wallet_status now
carries chain_in_process / node_available / node_state beside the core's five
state words; no second state machine, no timer, no env var.

start/stop stay the core's pass-through: one call launches the node and the
wallet child, one stops both, both idempotent.
sirius merged commit 574e59fef0 into onionwire/t_04975420-cuprate-land-the-in-process-chain-source 2026-09-18 18:50:11 +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!111
No description provided.