diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt b/android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt index 1efd980..bbabf37 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt @@ -724,8 +724,6 @@ class WireViewModel(app: Application) : AndroidViewModel(app) { // an onion daemon outright while no `arti` is bundled. artiBin = expectedArtiPath(), walletFilename = WalletChildBinaries.WALLET_FILENAME, - mainnet = false, - prune = false, ), ) } @@ -754,8 +752,6 @@ class WireViewModel(app: Application) : AndroidViewModel(app) { walletRpcBin = bins.walletRpc.orEmpty(), artiBin = expectedArtiPath(), walletFilename = WalletChildBinaries.WALLET_FILENAME, - mainnet = false, - prune = false, ), ) } @@ -771,14 +767,12 @@ class WireViewModel(app: Application) : AndroidViewModel(app) { * is what launches the node *and* the wallet child (one call in the core). * * `monerodDatadir` is left empty on purpose: the SDK resolves that to - * `$ONIONWIRE_HOME/chain/{testnet,mainnet-pruned,mainnet-full}` from - * [mainnet] and [prune], so Kotlin never invents an absolute path. + * `$ONIONWIRE_HOME/chain`, the same per-identity directory a spawned `monerod` + * would use, so Kotlin never invents an absolute path. `monero-wallet-rpc` is + * still required — Cuprate has no wallet layer, so the subprocess stays, and the + * core rejects a config without it. */ - suspend fun setInProcessCuprate( - bins: WalletChildBinaryPaths, - mainnet: Boolean, - prune: Boolean, - ): Result = + suspend fun setInProcessCuprate(bins: WalletChildBinaryPaths): Result = withContext(Dispatchers.IO) { runCatching { requireWire().setChainSource( @@ -793,8 +787,6 @@ class WireViewModel(app: Application) : AndroidViewModel(app) { // clearnet, so the core never spawns the SOCKS child. artiBin = expectedArtiPath(), walletFilename = WalletChildBinaries.WALLET_FILENAME, - mainnet = mainnet, - prune = prune, ), ) } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt index 57ee94b..81befaf 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt @@ -318,8 +318,9 @@ const val STARTING_CHILD_NOTICE: String = */ const val CUPRATE_PREPRODUCTION_WARNING: String = "On-device node is Cuprate, which is pre-production: its own user book says do NOT use " + - "cuprated for any serious purposes, mainnet is unvalidated, and its monerod RPC parity " + - "is incomplete (Cuprate issue #278). Try the in-process path; do not hold funds on it." + "cuprated for any serious purposes, it runs testnet only here (mainnet is unvalidated), " + + "and its monerod RPC parity is incomplete (Cuprate issue #278). Try the in-process " + + "path; do not hold funds on it." /** * This build was compiled without the `cuprate-daemon` feature, so the stored @@ -341,36 +342,18 @@ const val CUPRATE_NOT_IN_BUILD_NOTICE: String = * measured honestly is the free space on the filesystem the fjall store grows * into, and the device can be told when that is not enough. */ -const val CHAIN_TESTNET_FLOOR_BYTES: Long = 3L * 1024 * 1024 * 1024 -const val CHAIN_MAINNET_PRUNED_FLOOR_BYTES: Long = 64L * 1024 * 1024 * 1024 -const val CHAIN_MAINNET_FULL_FLOOR_BYTES: Long = 280L * 1024 * 1024 * 1024 - -/** Testnet floor, kept so existing tests still name one constant. */ -const val CHAIN_FREE_SPACE_FLOOR_BYTES: Long = CHAIN_TESTNET_FLOOR_BYTES - -fun chainStorageFloorBytes(mainnet: Boolean, prune: Boolean): Long = when { - !mainnet -> CHAIN_TESTNET_FLOOR_BYTES - prune -> CHAIN_MAINNET_PRUNED_FLOOR_BYTES - else -> CHAIN_MAINNET_FULL_FLOOR_BYTES -} +const val CHAIN_FREE_SPACE_FLOOR_BYTES: Long = 3L * 1024 * 1024 * 1024 /** * What the chain store costs, in the user's terms: the free space this device * actually has, and what the node does *not* tell us. */ -fun chainStorageLine(freeBytes: Long?, mainnet: Boolean = false, prune: Boolean = false): String { - val kind = when { - !mainnet -> "a synced testnet store" - prune -> "a pruned mainnet store (tens of GiB)" - else -> "a full mainnet store (hundreds of GiB)" - } - return when { - freeBytes == null -> - "chain store: free space on this device could not be read." - else -> - "chain store: ${formatBytes(freeBytes)} free on this device — $kind " + - "grows into it. The node reports no size estimate of its own." - } +fun chainStorageLine(freeBytes: Long?): String = when { + freeBytes == null -> + "chain store: free space on this device could not be read." + else -> + "chain store: ${formatBytes(freeBytes)} free on this device — a synced testnet store " + + "grows into it. The node reports no size estimate of its own." } /** @@ -378,20 +361,13 @@ fun chainStorageLine(freeBytes: Long?, mainnet: Boolean = false, prune: Boolean * may. Fail-closed on an unreadable filesystem: an unknown free space is not * reported as enough. */ -fun chainStorageBlockedReason( - freeBytes: Long?, - mainnet: Boolean = false, - prune: Boolean = false, -): String? { - val floor = chainStorageFloorBytes(mainnet, prune) - return when { - freeBytes == null -> - "Free space on the chain store's filesystem could not be read, so it is not known to fit." - freeBytes < floor -> - "Not enough space for the chain store: ${formatBytes(freeBytes)} free, and the " + - "on-device node needs at least ${formatBytes(floor)}." - else -> null - } +fun chainStorageBlockedReason(freeBytes: Long?): String? = when { + freeBytes == null -> + "Free space on the chain store's filesystem could not be read, so it is not known to fit." + freeBytes < CHAIN_FREE_SPACE_FLOOR_BYTES -> + "Not enough space for the chain store: ${formatBytes(freeBytes)} free, and the " + + "on-device node needs at least ${formatBytes(CHAIN_FREE_SPACE_FLOOR_BYTES)}." + else -> null } /** diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt index e29576c..f8fcebe 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt @@ -253,10 +253,10 @@ fun WalletScreen( .onFailure { daemonError = it.message ?: it.toString() } } }, - onInProcessNode = { mainnet, prune -> + onInProcessNode = { daemonError = null scope.launch { - vm.setInProcessCuprate(bins, mainnet, prune) + vm.setInProcessCuprate(bins) .onFailure { daemonError = it.message ?: it.toString() } } }, @@ -617,7 +617,7 @@ private fun WalletChildCard( onDaemonText: (String) -> Unit, onSaveDaemon: () -> Unit, onReceiveOnly: () -> Unit, - onInProcessNode: (mainnet: Boolean, prune: Boolean) -> Unit, + onInProcessNode: () -> Unit, starting: Boolean = false, onStart: () -> Unit, onStop: () -> Unit, @@ -630,15 +630,7 @@ private fun WalletChildCard( // poller, or the user would press Start having seen neither. val inProcess = input?.chainInProcess == true || chain?.kind == ChainChoice.IN_PROCESS_CUPRATE val startWhy = startBlockedReason(bins, input, onionDaemon, starting) - ?: if (inProcess) { - chainStorageBlockedReason( - nodeFreeBytes, - mainnet = chain?.mainnet == true, - prune = chain?.prune == true, - ) - } else { - null - } + ?: if (inProcess) chainStorageBlockedReason(nodeFreeBytes) else null val stopWhy = stopBlockedReason(input) Card( @@ -739,25 +731,11 @@ private fun WalletChildCard( // reads before Start. Spacer(Modifier.height(8.dp)) OutlinedButton( - onClick = { onInProcessNode(true, true) }, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-chain-mainnet-pruned"), - ) { Text("Mainnet pruned") } - Spacer(Modifier.height(4.dp)) - OutlinedButton( - onClick = { onInProcessNode(true, false) }, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-chain-mainnet-full"), - ) { Text("Mainnet full") } - Spacer(Modifier.height(4.dp)) - OutlinedButton( - onClick = { onInProcessNode(false, false) }, + onClick = onInProcessNode, modifier = Modifier .fillMaxWidth() .testTag("wallet-chain-in-process"), - ) { Text("Testnet (experimental)") } + ) { Text("On-device node (Cuprate)") } if (inProcess) { Spacer(Modifier.height(8.dp)) @@ -771,11 +749,7 @@ private fun WalletChildCard( ) Spacer(Modifier.height(4.dp)) Text( - chainStorageLine( - nodeFreeBytes, - mainnet = chain?.mainnet == true, - prune = chain?.prune == true, - ), + chainStorageLine(nodeFreeBytes), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt index f6cec47..ddd412f 100644 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt +++ b/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt @@ -338,7 +338,7 @@ class WalletChildStatusTextTest { assertTrue("it names the software", warning.contains("Cuprate")) assertTrue("it quotes the user book", warning.contains("do NOT use cuprated")) assertTrue("it names the parity gap", warning.contains("Cuprate issue #278")) - assertTrue("it says mainnet is unvalidated", warning.contains("mainnet is unvalidated")) + assertTrue("it says testnet", warning.contains("testnet")) assertTrue("it is a sentence, not a glyph", warning.trim().endsWith(".")) assertTrue("it is long enough to be a sentence", warning.length > 80) } @@ -364,33 +364,6 @@ class WalletChildStatusTextTest { assertNull(chainStorageBlockedReason(64L * 1024 * 1024 * 1024)) } - @Test - fun mainnet_pruned_needs_more_than_testnet() { - val forty = 40L * 1024 * 1024 * 1024 - assertNull(chainStorageBlockedReason(forty, mainnet = false, prune = false)) - val why = chainStorageBlockedReason(forty, mainnet = true, prune = true) - assertNotNull(why) - assertTrue(why!!, why.contains("64.0 GiB")) - assertNull( - chainStorageBlockedReason( - CHAIN_MAINNET_PRUNED_FLOOR_BYTES, - mainnet = true, - prune = true, - ), - ) - } - - @Test - fun mainnet_full_needs_more_than_pruned() { - val why = chainStorageBlockedReason( - CHAIN_MAINNET_PRUNED_FLOOR_BYTES, - mainnet = true, - prune = false, - ) - assertNotNull(why) - assertTrue(why!!, why.contains("280.0 GiB")) - } - @Test fun the_storage_line_reports_the_measured_number() { val line = chainStorageLine(41L * 1024 * 1024 * 1024) diff --git a/crates/onionwire-sdk/src/lib.rs b/crates/onionwire-sdk/src/lib.rs index 247f284..ef014e3 100644 --- a/crates/onionwire-sdk/src/lib.rs +++ b/crates/onionwire-sdk/src/lib.rs @@ -34,7 +34,7 @@ use onionwire::node::{FlushOutcome as CoreFlushOutcome, Node}; use onionwire::outbox::{DEFAULT_MAX_ATTEMPTS, OutboxEntry, OutboxStatus}; use onionwire::pay; use onionwire::qr; -use onionwire::wallet::{ChainNetwork, ChainSource}; +use onionwire::wallet::ChainSource; use onionwire::wallet_child::{ChildConfig, WalletChildState}; uniffi::setup_scaffolding!(); @@ -742,40 +742,20 @@ fn from_core_flush(o: CoreFlushOutcome) -> FlushOutcome { /// per-identity directory the core documents for a local chain — so a Kotlin /// caller never has to invent an absolute path. Every other kind uses exactly /// what it was given (or the core's own default), unchanged. -fn cuprate_chain_dir(home: &Path, mainnet: bool, prune: bool) -> PathBuf { - let name = match (mainnet, prune) { - (true, true) => "mainnet-pruned", - (true, false) => "mainnet-full", - (false, _) => "testnet", - }; - home.join("chain").join(name) -} - fn child_config(cfg: ChainConfig, home: &Path) -> ChildConfig { let source = match cfg.kind { ChainChoice::None => ChainSource::None, ChainChoice::Local => ChainSource::Local { monerod_bin: PathBuf::from(cfg.monerod_bin), datadir: PathBuf::from(cfg.monerod_datadir), - prune: cfg.prune, }, - ChainChoice::InProcessCuprate => { - let network = if cfg.mainnet { - ChainNetwork::Mainnet + ChainChoice::InProcessCuprate => ChainSource::InProcessCuprate { + datadir: if cfg.monerod_datadir.trim().is_empty() { + home.join("chain") } else { - ChainNetwork::Testnet - }; - let prune = cfg.mainnet && cfg.prune; - ChainSource::InProcessCuprate { - datadir: if cfg.monerod_datadir.trim().is_empty() { - cuprate_chain_dir(home, cfg.mainnet, prune) - } else { - PathBuf::from(cfg.monerod_datadir) - }, - network, - prune, - } - } + PathBuf::from(cfg.monerod_datadir) + }, + }, ChainChoice::Remote => ChainSource::Remote { host: cfg.host, port: cfg.port, @@ -789,42 +769,32 @@ fn child_config(cfg: ChainConfig, home: &Path) -> ChildConfig { } } +/// And back, for the Kotlin prefill. fn chain_config(cfg: &ChildConfig) -> ChainConfig { - let (kind, host, port, monerod_bin, monerod_datadir, mainnet, prune) = match &cfg.source { + let (kind, host, port, monerod_bin, monerod_datadir) = match &cfg.source { ChainSource::None => ( ChainChoice::None, String::new(), 0, String::new(), String::new(), - false, - false, ), ChainSource::Local { monerod_bin, datadir, - prune, } => ( ChainChoice::Local, String::new(), 0, monerod_bin.display().to_string(), datadir.display().to_string(), - true, - *prune, ), - ChainSource::InProcessCuprate { - datadir, - network, - prune, - } => ( + ChainSource::InProcessCuprate { datadir } => ( ChainChoice::InProcessCuprate, String::new(), 0, String::new(), datadir.display().to_string(), - matches!(network, ChainNetwork::Mainnet), - *prune, ), ChainSource::Remote { host, port } => ( ChainChoice::Remote, @@ -832,8 +802,6 @@ fn chain_config(cfg: &ChildConfig) -> ChainConfig { *port, String::new(), String::new(), - false, - false, ), }; ChainConfig { @@ -845,8 +813,6 @@ fn chain_config(cfg: &ChildConfig) -> ChainConfig { wallet_rpc_bin: cfg.wallet_rpc_bin.display().to_string(), arti_bin: cfg.arti_bin.display().to_string(), wallet_filename: cfg.wallet_filename.clone(), - mainnet, - prune, } } @@ -1031,13 +997,6 @@ pub struct ChainConfig { pub arti_bin: String, /// Wallet file name inside `$ONIONWIRE_HOME/wallet`. pub wallet_filename: String, - /// Cuprate / local `monerod`: mainnet when true, testnet when false. - /// Ignored for Remote and None. Old records without the field stay testnet. - pub mainnet: bool, - /// Cuprate / local `monerod`: prune the chain. Ignored for Remote and None. - /// Once a Cuprate store is pruned it cannot be un-pruned — we keep pruned - /// and full in separate datadirs. - pub prune: bool, } /// One snapshot of the app-owned wallet child. @@ -1754,8 +1713,6 @@ mod tests { wallet_rpc_bin: "/data/app/nativeLibraryDir/libmonerowalletrpc.so".to_string(), arti_bin: "/data/app/nativeLibraryDir/libarti.so".to_string(), wallet_filename: "wallet".to_string(), - mainnet: false, - prune: false, } } @@ -1769,49 +1726,10 @@ mod tests { assert_eq!( child.source, ChainSource::InProcessCuprate { - datadir: sdk_home().join("chain").join("testnet"), - network: ChainNetwork::Testnet, - prune: false, + datadir: sdk_home().join("chain") } ); - assert_eq!(child.source_label(), "in-process testnet"); - } - - #[test] - fn child_config_mainnet_pruned_uses_its_own_datadir() { - let mut req = request(ChainChoice::InProcessCuprate, ""); - req.mainnet = true; - req.prune = true; - let child = child_config(req, &sdk_home()); - assert_eq!( - child.source, - ChainSource::InProcessCuprate { - datadir: sdk_home().join("chain").join("mainnet-pruned"), - network: ChainNetwork::Mainnet, - prune: true, - } - ); - assert_eq!(child.source_label(), "in-process mainnet pruned"); - let back = chain_config(&child); - assert!(back.mainnet); - assert!(back.prune); - } - - #[test] - fn child_config_mainnet_full_uses_its_own_datadir() { - let mut req = request(ChainChoice::InProcessCuprate, ""); - req.mainnet = true; - req.prune = false; - let child = child_config(req, &sdk_home()); - assert_eq!( - child.source, - ChainSource::InProcessCuprate { - datadir: sdk_home().join("chain").join("mainnet-full"), - network: ChainNetwork::Mainnet, - prune: false, - } - ); - assert_eq!(child.source_label(), "in-process mainnet full"); + assert_eq!(child.source_label(), "in-process node"); } #[test] @@ -1821,9 +1739,7 @@ mod tests { assert_eq!( child.source, ChainSource::InProcessCuprate { - datadir: PathBuf::from(given), - network: ChainNetwork::Testnet, - prune: false, + datadir: PathBuf::from(given) } ); } @@ -1860,7 +1776,7 @@ mod tests { ChainChoice::InProcessCuprate => { assert_eq!( back.monerod_datadir, - sdk_home().join("chain").join("testnet").display().to_string() + sdk_home().join("chain").display().to_string() ); assert!( back.monerod_bin.is_empty(), @@ -1899,9 +1815,7 @@ mod tests { #[test] fn node_state_names_the_apps_own_chain_for_the_in_process_source() { let source = ChainSource::InProcessCuprate { - datadir: sdk_home().join("chain").join("testnet"), - network: ChainNetwork::Testnet, - prune: false, + datadir: sdk_home().join("chain"), }; let cases = [ (WalletChildState::Off, "off"), @@ -1930,7 +1844,6 @@ mod tests { ChainSource::Local { monerod_bin: PathBuf::from("monerod"), datadir: PathBuf::from("/chain"), - prune: false, }, ChainSource::Remote { host: "peer.onion".to_string(), diff --git a/src/cuprate.rs b/src/cuprate.rs index cf4aedf..b6a4006 100644 --- a/src/cuprate.rs +++ b/src/cuprate.rs @@ -60,8 +60,8 @@ mod imp { use std::path::Path; use std::sync::mpsc; - use cuprated::config::{resolve_max_memory, Config}; use cuprated::Node; + use cuprated::config::{Config, resolve_max_memory}; /// The network this daemon runs. Testnet, deliberately — see the module /// docs. Cuprate spells this `Testnet`. @@ -107,13 +107,8 @@ mod imp { /// Blocking this thread for the duration of the launch is the same thing /// the app already does for a `.onion` chain source's SOCKS readiness /// wait. - pub fn launch( - datadir: &Path, - port: u16, - network: &str, - prune: bool, - ) -> Result { - let text = config_toml(datadir, port, network, prune); + pub fn launch(datadir: &Path, port: u16) -> Result { + let text = config_toml(datadir, port); let (tx, rx) = mpsc::channel(); std::thread::Builder::new() .name("onionwire-cuprate".into()) @@ -198,10 +193,10 @@ mod imp { /// default silently standing in for the setting that was meant. /// /// No data directory is created here — the caller owns the 0700 wallet dir. - pub fn config_toml(datadir: &Path, port: u16, network: &str, prune: bool) -> String { + pub fn config_toml(datadir: &Path, port: u16) -> String { let datadir = datadir.display(); format!( - r#"network = "{network}" + r#"network = "{NETWORK}" offline = false fast_sync = true target_max_memory = {TARGET_MAX_MEMORY} @@ -214,9 +209,6 @@ cache_directory = "{datadir}/cache" [storage] reader_threads = {READER_THREADS} -[storage.blockchain] -prune = {prune} - # The unrestricted listener: this is the one the wallet child dials, and the one # with real numbers. The restricted listener is off — its metrics are # placeholders, and nothing in this app reads them. @@ -255,13 +247,9 @@ mode = "Auto" /// between revisions is a hard error, not a silently ignored setting. #[test] fn the_config_parses_into_this_revision() { - let mut config: Config = toml::from_str(&config_toml( - Path::new("/tmp/onionwire-chain"), - 18081, - "Testnet", - false, - )) - .expect("the config must parse against the pinned cuprated revision"); + let mut config: Config = + toml::from_str(&config_toml(Path::new("/tmp/onionwire-chain"), 18081)) + .expect("the config must parse against the pinned cuprated revision"); resolve_max_memory(&mut config).expect("target_max_memory is set, so nothing to probe"); assert_eq!(format!("{:?}", config.network), NETWORK); // The fjall store is Cuprate's, under the datadir it was given — @@ -290,12 +278,7 @@ mod imp { impl CuprateNode { /// Always fails: this build has no in-process daemon. - pub fn launch( - _datadir: &Path, - _port: u16, - _network: &str, - _prune: bool, - ) -> Result { + pub fn launch(_datadir: &Path, _port: u16) -> Result { Err(super::NO_FEATURE_MSG.into()) } @@ -312,4 +295,4 @@ mod imp { pub use imp::CuprateNode; #[cfg(feature = "cuprate-daemon")] -pub use imp::{config_toml, NETWORK}; +pub use imp::{NETWORK, config_toml}; diff --git a/src/node.rs b/src/node.rs index cbad028..3ce2edd 100644 --- a/src/node.rs +++ b/src/node.rs @@ -29,7 +29,7 @@ use crate::ratelimit::TokenBucket; use crate::sanitize; use crate::session::{self, Keys}; use crate::store::{Friend, FriendProfile, Message, Payment, PaymentWrite, Store}; -use crate::wallet::{self, ChainNetwork, ChainSource, Readiness, Wallet, WalletConfig, WalletStatus}; +use crate::wallet::{self, Readiness, Wallet, WalletConfig, WalletStatus}; use crate::wallet_child::{ChildConfig, WalletChild, WalletChildState, WalletChildStatus}; pub struct RotateResult { @@ -567,10 +567,6 @@ impl Node { // ----- the app-owned wallet child (`src/wallet_child.rs`) ---------------- - pub fn home(&self) -> &Path { - &self.home - } - /// The child settings this node would spawn with: the stored record, or the /// defaults (receive-only, binaries by name) when nothing was ever set. pub fn wallet_child_config(&self) -> ChildConfig { @@ -597,30 +593,6 @@ impl Node { Ok(()) } - /// Store an in-process Cuprate source. Datadirs are split so a pruned - /// mainnet store cannot mix with a full one (Cuprate cannot un-prune). - pub fn set_in_process_cuprate( - &self, - network: ChainNetwork, - prune: bool, - ) -> Result<(), String> { - let mut cfg = self.wallet_child_config(); - if cfg.wallet_rpc_bin.as_os_str().is_empty() { - cfg.wallet_rpc_bin = PathBuf::from("monero-wallet-rpc"); - } - let name = match (network, prune) { - (ChainNetwork::Mainnet, true) => "mainnet-pruned", - (ChainNetwork::Mainnet, false) => "mainnet-full", - (ChainNetwork::Testnet, _) => "testnet", - }; - cfg.source = ChainSource::InProcessCuprate { - datadir: self.home.join("chain").join(name), - network, - prune: matches!(network, ChainNetwork::Mainnet) && prune, - }; - self.set_wallet_child_config(&cfg) - } - /// Start the app-owned wallet child and point this node's wallet at it. /// /// Idempotent: a live wallet child is reported, not respawned. Spawning is diff --git a/src/tui.rs b/src/tui.rs index a72d071..0734015 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -18,7 +18,7 @@ use crate::outbox::DEFAULT_MAX_ATTEMPTS; use crate::qr::{self, QrPayload}; use crate::sanitize; use crate::store::{Friend, FriendProfile, Message, OutboxEntry, OutboxStatus, Payment}; -use crate::wallet::{self, ChainNetwork, ChainSource}; +use crate::wallet::{self, ChainSource}; const C_ACCENT: Color = Color::Rgb(232, 165, 75); const C_TEXT: Color = Color::Rgb(196, 214, 176); @@ -1669,9 +1669,6 @@ impl App { KeyCode::Char('s') => self.wallet_child_start(), KeyCode::Char('x') => self.wallet_child_stop(), KeyCode::Char('p') => self.wallet_child_probe(), - KeyCode::Char('1') => self.set_cuprate_chain(ChainNetwork::Mainnet, true), - KeyCode::Char('2') => self.set_cuprate_chain(ChainNetwork::Mainnet, false), - KeyCode::Char('3') => self.set_cuprate_chain(ChainNetwork::Testnet, false), KeyCode::Char('c') => { self.screen = Screen::WalletSetup(WalletSetup::CreateWarn { typed: String::new(), @@ -2145,16 +2142,6 @@ impl App { self.status_note = Some(self.wallet_child_note()); } - fn set_cuprate_chain(&mut self, network: ChainNetwork, prune: bool) { - self.status_note = Some(match self.node.set_in_process_cuprate(network, prune) { - Ok(()) => format!( - "chain source: {}", - self.node.wallet_child_config().source.label() - ), - Err(e) => format!("chain source: {e}"), - }); - } - /// The child status line, or the copy that names what is missing. fn wallet_child_note(&mut self) -> String { let line = self.rt.block_on(self.node.wallet_child_refresh()).line(); @@ -3192,9 +3179,7 @@ match screen { BackupKind::Restore => "type RESTORE Esc cancel ? help", }, Screen::Passphrase { .. } => "Enter submit Esc cancel ? help", - Screen::Wallet { .. } => { - "c create i import r qr s/x child 1 pruned 2 full 3 testnet Esc back ? help" - } + Screen::Wallet { .. } => "c create i import r qr s/x child Esc back ? help", Screen::WalletSetup(WalletSetup::CreateWarn { .. }) => "type SPEND Esc cancel ? help", Screen::WalletSetup(WalletSetup::CreatePass { .. } | WalletSetup::ImportPass { .. }) => { "Enter submit Esc cancel ? help" diff --git a/src/wallet.rs b/src/wallet.rs index f404cea..4430a2d 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -19,31 +19,6 @@ impl std::fmt::Display for Error { impl std::error::Error for Error {} -/// Which Monero network an on-device daemon follows. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum ChainNetwork { - Mainnet, - Testnet, -} - -impl ChainNetwork { - /// Cuprate TOML `network = "..."` spelling (`Mainnet` / `Testnet`). - pub fn cuprate_toml(self) -> &'static str { - match self { - Self::Mainnet => "Mainnet", - Self::Testnet => "Testnet", - } - } - - /// Directory segment so mainnet and testnet stores never share a fjall dir. - pub fn dir_name(self) -> &'static str { - match self { - Self::Mainnet => "mainnet", - Self::Testnet => "testnet", - } - } -} - /// The user's choice of where the Monero daemon lives. No default remote node /// is ever implied — every `Remote` is constructed from explicit user input. /// @@ -59,21 +34,17 @@ pub enum ChainSource { monerod_bin: PathBuf, /// Data directory for the local daemon. datadir: PathBuf, - /// `monerod --prune-blockchain`. Full node when false. - prune: bool, }, /// A chain daemon **inside this process** (Cuprate), with its chain in /// `datadir`. Nothing is spawned; the wallet child still dials loopback /// RPC, so this is a [`ChainSource::Local`] with a different owner. /// - /// Cuprate is still pre-production: mainnet RPC parity is unvalidated. - /// The UI must say so. `network`/`prune` are the user's choice; old - /// stored records without those keys are testnet, unpruned. + /// Two consequences the UI has to state: the chain is on this device, and + /// the in-process daemon is **testnet-only** in this build (Cuprate is + /// pre-production and its mainnet RPC parity is unvalidated). InProcessCuprate { /// Data directory for the daemon's chain database. datadir: PathBuf, - network: ChainNetwork, - prune: bool, }, /// A daemon address the user supplied. Trust follows the address. Remote { @@ -100,22 +71,8 @@ impl ChainSource { pub fn label(&self) -> String { match self { ChainSource::None => "receive-only".to_string(), - ChainSource::Local { prune: true, .. } => "local pruned node".to_string(), - ChainSource::Local { prune: false, .. } => "local full node".to_string(), - ChainSource::InProcessCuprate { - network: ChainNetwork::Mainnet, - prune: true, - .. - } => "in-process mainnet pruned".to_string(), - ChainSource::InProcessCuprate { - network: ChainNetwork::Mainnet, - prune: false, - .. - } => "in-process mainnet full".to_string(), - ChainSource::InProcessCuprate { - network: ChainNetwork::Testnet, - .. - } => "in-process testnet".to_string(), + ChainSource::Local { .. } => "local node".to_string(), + ChainSource::InProcessCuprate { .. } => "in-process node".to_string(), ChainSource::Remote { host, .. } if is_onion_host(host) => { "remote onion daemon".to_string() } diff --git a/src/wallet_child.rs b/src/wallet_child.rs index 8769ccb..37fc404 100644 --- a/src/wallet_child.rs +++ b/src/wallet_child.rs @@ -39,7 +39,7 @@ use zeroize::Zeroizing; use crate::cuprate::CuprateNode; use crate::store::Store; -use crate::wallet::{self, ChainNetwork, ChainSource, Wallet}; +use crate::wallet::{self, ChainSource, Wallet}; /// `monerod` RPC port for a local chain source. Unrestricted RPC default; the /// wallet child is the only thing that dials it. @@ -355,7 +355,7 @@ impl WalletChild { /// for a remote source (their disk, not ours) and for receive-only. pub fn chain_datadir(source: &ChainSource) -> Option<&Path> { match source { - ChainSource::Local { datadir, .. } | ChainSource::InProcessCuprate { datadir, .. } => { + ChainSource::Local { datadir, .. } | ChainSource::InProcessCuprate { datadir } => { Some(datadir) } ChainSource::None | ChainSource::Remote { .. } => None, @@ -377,8 +377,8 @@ impl WalletChild { /// The exact argv used to spawn `monerod`. Single source of truth: `start` /// spawns this and the tests assert on it. - pub fn monerod_argv(bin: &Path, datadir: &Path, rpc_port: u16, prune: bool) -> Vec { - let mut argv = vec![ + pub fn monerod_argv(bin: &Path, datadir: &Path, rpc_port: u16) -> Vec { + vec![ bin.display().to_string(), "--non-interactive".into(), "--data-dir".into(), @@ -387,11 +387,7 @@ impl WalletChild { "127.0.0.1".into(), "--rpc-bind-port".into(), rpc_port.to_string(), - ]; - if prune { - argv.push("--prune-blockchain".into()); - } - argv + ] } /// The exact argv used to spawn `monero-wallet-rpc`. Digest login is @@ -491,11 +487,9 @@ impl WalletChild { ChainSource::Local { monerod_bin, datadir, - prune, } => { ensure_parent(datadir)?; - let argv = - Self::monerod_argv(monerod_bin, datadir, DEFAULT_MONEROD_RPC_PORT, *prune); + let argv = Self::monerod_argv(monerod_bin, datadir, DEFAULT_MONEROD_RPC_PORT); let child = spawn(&argv, "monerod")?; let mut guard = self .monerod @@ -503,11 +497,7 @@ impl WalletChild { .map_err(|e| ChildError(format!("monerod lock: {e}")))?; *guard = Some(child); } - ChainSource::InProcessCuprate { - datadir, - network, - prune, - } => self.start_in_process_daemon(datadir, *network, *prune)?, + ChainSource::InProcessCuprate { datadir } => self.start_in_process_daemon(datadir)?, ChainSource::None | ChainSource::Remote { .. } => {} } @@ -594,25 +584,15 @@ impl WalletChild { /// node answers), so this works from the TUI's blocking thread *and* from an /// SDK async context. It is the same shape as the SOCKS readiness wait /// above: no daemon, no wallet child. - fn start_in_process_daemon( - &self, - datadir: &Path, - network: ChainNetwork, - prune: bool, - ) -> Result<()> { + fn start_in_process_daemon(&self, datadir: &Path) -> Result<()> { // Feature first: in a build without it, a datadir complaint would be a // misleading answer to "why is there no daemon". if !crate::cuprate::available() { return Err(ChildError(crate::cuprate::NO_FEATURE_MSG.into())); } create_dir_700(datadir).map_err(|e| ChildError(format!("chain datadir: {e}")))?; - let node = CuprateNode::launch( - datadir, - DEFAULT_MONEROD_RPC_PORT, - network.cuprate_toml(), - prune, - ) - .map_err(|e| ChildError(format!("in-process daemon: {e}")))?; + let node = CuprateNode::launch(datadir, DEFAULT_MONEROD_RPC_PORT) + .map_err(|e| ChildError(format!("in-process daemon: {e}")))?; let mut guard = self .cuprate .lock() @@ -749,7 +729,6 @@ impl ChildConfig { ChainSource::Local { monerod_bin, datadir, - .. } => { if monerod_bin.as_os_str().is_empty() { return Err(ChildError("monerod path required for a local node".into())); @@ -760,7 +739,7 @@ impl ChildConfig { )); } } - ChainSource::InProcessCuprate { datadir, .. } => { + ChainSource::InProcessCuprate { datadir } => { if datadir.as_os_str().is_empty() { return Err(ChildError( "chain data dir required for an in-process daemon".into(), @@ -970,22 +949,14 @@ fn source_to_json(source: &ChainSource) -> serde_json::Value { ChainSource::Local { monerod_bin, datadir, - prune, } => serde_json::json!({ "kind": "local", "monerod_bin": monerod_bin.display().to_string(), "datadir": datadir.display().to_string(), - "prune": prune, }), - ChainSource::InProcessCuprate { - datadir, - network, - prune, - } => serde_json::json!({ + ChainSource::InProcessCuprate { datadir } => serde_json::json!({ "kind": "cuprate", "datadir": datadir.display().to_string(), - "network": network.dir_name(), - "prune": prune, }), ChainSource::Remote { host, port } => serde_json::json!({ "kind": "remote", @@ -1018,7 +989,6 @@ fn source_from_json(value: &serde_json::Value) -> Result { Ok(ChainSource::Local { monerod_bin: PathBuf::from(monerod_bin), datadir: PathBuf::from(datadir), - prune: value.get("prune").and_then(|v| v.as_bool()).unwrap_or(false), }) } "cuprate" => { @@ -1029,15 +999,8 @@ fn source_from_json(value: &serde_json::Value) -> Result { .ok_or_else(|| { ChildError("stored in-process chain source has no data dir".into()) })?; - let network = match value.get("network").and_then(|v| v.as_str()) { - Some("mainnet") => ChainNetwork::Mainnet, - _ => ChainNetwork::Testnet, - }; - let prune = value.get("prune").and_then(|v| v.as_bool()).unwrap_or(false); Ok(ChainSource::InProcessCuprate { datadir: PathBuf::from(datadir), - network, - prune, }) } "remote" => { @@ -1181,7 +1144,6 @@ mod tests { ChainSource::Local { monerod_bin: monerod, datadir: dir.join("monerod-data"), - prune: false, } } @@ -1627,7 +1589,6 @@ mod tests { &PathBuf::from("/usr/bin/monerod"), &datadir, DEFAULT_MONEROD_RPC_PORT, - false, ); let pairs: Vec<(&str, &str)> = argv .windows(2) @@ -1787,8 +1748,6 @@ mod tests { fn in_process_source(dir: &Path) -> ChainSource { ChainSource::InProcessCuprate { datadir: dir.join("chain"), - network: ChainNetwork::Testnet, - prune: false, } } @@ -1896,8 +1855,6 @@ mod tests { let empty = ChildConfig { source: ChainSource::InProcessCuprate { datadir: PathBuf::new(), - network: ChainNetwork::Testnet, - prune: false, }, ..ChildConfig::default() }; diff --git a/tests/wallet.rs b/tests/wallet.rs index 3007ab9..26d7168 100644 --- a/tests/wallet.rs +++ b/tests/wallet.rs @@ -1138,10 +1138,9 @@ fn chain_source_labels_name_what_the_child_dials() { ChainSource::Local { monerod_bin: PathBuf::from("/usr/bin/monerod"), datadir: PathBuf::from("/var/lib/onionwire"), - prune: false, } .label(), - "local full node" + "local node" ); assert_eq!( ChainSource::Remote { @@ -1227,7 +1226,6 @@ fn child_settings_round_trip_sealed_and_keep_the_creds() { local.source = ChainSource::Local { monerod_bin: PathBuf::new(), datadir: PathBuf::from("/var/lib/onionwire"), - prune: false, }; let err = local.validate().expect_err("a local node needs monerod"); assert!(err.to_string().contains("monerod path required"), "{err}"); @@ -1267,7 +1265,7 @@ async fn an_in_process_cuprate_node_answers_the_typed_daemon_client() { let addr = format!("127.0.0.1:{port}"); let budget = std::time::Duration::from_secs(5); - let mut node = onionwire::cuprate::CuprateNode::launch(&datadir, port, "Testnet", false) + let mut node = onionwire::cuprate::CuprateNode::launch(&datadir, port) .expect("launch the in-process testnet daemon"); // `launch` returns with the services started; the RPC listener can still be