feat(wallet): mainnet pruned and full on-device chain modes
Cuprate in-process and TUI keys 1/2/3 pick mainnet pruned, mainnet full, or experimental testnet. Datadirs are split so a prune store cannot mix with a full one. Android storage floors scale with the choice. Cuprate remains pre-production; mainnet is unvalidated.
This commit is contained in:
parent
0acf89a0b4
commit
5080652e3b
11 changed files with 397 additions and 77 deletions
30
src/node.rs
30
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, Readiness, Wallet, WalletConfig, WalletStatus};
|
||||
use crate::wallet::{self, ChainNetwork, ChainSource, Readiness, Wallet, WalletConfig, WalletStatus};
|
||||
use crate::wallet_child::{ChildConfig, WalletChild, WalletChildState, WalletChildStatus};
|
||||
|
||||
pub struct RotateResult {
|
||||
|
|
@ -567,6 +567,10 @@ 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 {
|
||||
|
|
@ -593,6 +597,30 @@ 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
|
||||
|
|
|
|||
Loading…
Reference in a new issue