From 7ba07f84ea39a297ff035a6e261debf37daf88c4 Mon Sep 17 00:00:00 2001 From: agent Date: Wed, 16 Sep 2026 22:46:45 -0400 Subject: [PATCH] docs: add Cuprate in-process daemon exploration to payment plan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds §7a documenting the alternative approach of embedding Cuprate's crates directly into the OnionWire binary instead of spawning monerod as a subprocess. Includes PoC results (cargo check passed with both arti-client 0.44 and 0.46), the wallet-layer gap, dependency bloat assessment, and exploration card titles. Does not change any locks — the subprocess wrapper model remains the default path. See references/cuprate-integration.md for full test log. --- docs/payment-integration-plan.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/payment-integration-plan.md b/docs/payment-integration-plan.md index 3d3fe0e..a1d026d 100644 --- a/docs/payment-integration-plan.md +++ b/docs/payment-integration-plan.md @@ -198,6 +198,29 @@ Keep the UniFFI surface honest about wallet state: running/not running, balance, --- +## 7a. Alternative: in-process Cuprate daemon (rust-dev exploration) + +A rust-dev card may explore baking a Monero chain daemon directly into the OnionWire binary via [Cuprate](https://github.com/Cuprate/cuprate)'s internal crates, instead of spawning `monerod` as a subprocess. This is an **exploration**, not a commitment. Key facts that decide whether it's viable: + +- **Cuprate crates are not published to crates.io** — every `cuprate-*` crate is a `0.0.0-placeholder` name reservation. Using them requires a git dependency on `https://github.com/Cuprate/cuprate` at a specific commit, pinning a pre-1.0 project. The root `Cargo.toml` declares no versions on workspace members (path deps only). +- **`cuprated`'s `Node::launch(config)` API** (`binaries/cuprated/src/lib.rs`) is the in-process entry point. It takes a `Config`, opens the database (fjall), starts consensus, P2P, RPC servers, and the sync loop. A `Node` handle is returned with `blockchain`, `txpool`, `clearnet`/`tor` network interfaces, and a `task_executor` for shutdown. This is a real embeddable API — not CLI-only. +- **Tor is already integrated** via `arti-client` (0.44), `tor-hsservice`, `tor-rtcompat` — the same crates OnionWire uses. Config has a `[tor]` section with `mode = Auto|Daemon|Arti` and onion service settings. OnionWire already uses `arti-client` 0.46, so a version-resolution conflict is a real risk. +- **Cuprate is pre-production** — the user book says `do NOT use cuprated for any serious purposes`. RPC parity with `monerod` is tracked in [issue #278](https://github.com/Cuprate/cuprate/issues/278) and is not complete. +- **No wallet layer in Cuprate.** Cuprate replaces only the `monerod` daemon (chain + P2P + consensus). `monero-wallet-rpc` is still required for wallet operations (`create_address`, `get_transfers`, `get_balance`, `transfer`). On Android, the wallet-rpc subprocess survives but the chain daemon is in-process — so the binary-spawning problem is **halved, not eliminated**. +- **Dependency bloat.** `cuprated`'s `Cargo.toml` pulls in `axum`, `hyper`, `tower-http`, `rayon`, `fjall`, `clap`, `tokio-socks`, plus RandomX and CryptoNight bindings. The combined dependency tree would significantly increase binary size and build time. `axum`/`hyper` are not currently in OnionWire's graph. +- **Database is fjall** (an embedded key-value store, not LMDB or SQLCipher), which means a separate chain data store alongside OnionWire's SQLCipher store. + +**Exploration card (confirmed feasible via cargo check):** + +- **`rust-dev`: Spike — embed `cuprated` (git dep) alongside `arti-client` 0.46, verify `Node::launch(Config).await` compiles and the documented usage (`node.blockchain.context().chain_height`) type-checks.** PROOF OF CONCEPT: `cargo check` passed (exit 0) with 575 packages; `arti-client` 0.44 (Cuprate) and 0.46 (OnionWire) coexisted. `cuprated::Node::launch(config: impl Into>) -> Result` is accessible. `Node` fields: `blockchain`, `txpool`, `clearnet`, `tor`, `config`, `task_executor`; implements `Drop` → `shutdown()`. Config is at `cuprated::config::Config`. See `references/cuprate-integration.md` for full test log. + +- **`rust-dev`: If spike passes, actually launch Node::launch on testnet/fakchain, verify sync starts and monerod-compatible JSON-RPC (get_info, get_height) responds with the chain data OnionWire needs for receipt verification.** +- **`rust-dev`: If launch spike passes, assess wallet gap.** Since Cuprate has no wallet layer, determine whether to (a) keep `monero-wallet-rpc` as a subprocess and point it at the in-process Cuprate daemon (halves Android binary spawning), or (b) also adopt `monero-oxide`/`monero-wallet` as an in-process wallet to eliminate all subprocesses. + +This card does **not** pre-empt the existing subprocess-based cards in §9 — those remain the default path until Cuprate proves itself in-process. + +--- + ## 8. Key risks to flag in the card descriptions - **Arti SOCKS feasibility on Android** — backend 2 on Android depends on it. Verify before committing the Android remote-daemon path. @@ -219,6 +242,9 @@ Keep the UniFFI surface honest about wallet state: running/not running, balance, - `apk-dev`: Bundle monerod per Android ABI + local-node opt-in with storage gate + sync controls (full on-device node) - `apk-dev`: Android receive-address QR for wallet screen (separate from messenger invite QR) - `ci`: Native binary build + bundle + verification pipeline for monerod and monero-wallet-rpc (TUI assets + Android ABIs) +- `rust-dev`: Spike — embed `cuprated` (git dep) alongside `arti-client` 0.46, verify `Node::launch(Config).await` compiles and the documented usage (`node.blockchain.context().chain_height`) type-checks** — PoC PASSED +- `rust-dev`: If spike passes, actually launch Node::launch on testnet/fakchain, verify sync starts and monerod-compatible JSON-RPC (get_info, get_height) responds +- `rust-dev`: If launch spike passes, assess wallet gap — keep `monero-wallet-rpc` subprocess (daemon in-process only) or also adopt `monero-oxide`/`monero-wallet` - `docs`: Update WALLET.md + THREAT_MODEL.md for the new backends, SOCKS path, prune-window boundary, spend opt-in, Android lifecycle Cut releases manually and batched as the repo policy already requires — don't let a payment feature land push a release. CI for the native binaries is part of the work, not a follow-up.