tui: F7 becomes the node-setup screen, and F6 goes back to being the wallet
The chain source was reachable from three places and configured from none of them properly: `F6`'s inline `1`/`2`/`3` picker wrote only the in-process choice, the `F9` menu showed the state and named keys that edited it, and `Node::set_local_monerod` / `set_remote_daemon` / `set_receive_only` — the only way to point the app at a Monero node — had **no TUI caller at all** (Kotlin only). `wallet::NOT_CONFIGURED_MSG` told users to "open F7" and there was no F7. F7 (`WalletSetupConfig`) is now the one screen that sets up the node: - The `datadir` row is new and editable. `Node::set_local_monerod_at` takes the path; `set_local_monerod` delegates with the derived default, so an existing install keeps the store it already has. An empty datadir is refused rather than silently replaced — a store that moved unasked looks like a vanished chain and resyncs somewhere the user did not choose. - The `network` row is new: it carries the Cuprate mainnet/testnet choice that `F6`'s `1`/`2`/`3` used to own, so deleting those keys loses nothing. Mainnet reads `unvalidated` before it is picked. - A `NODE` section shows the live `Node::wallet_child_status` line (state, chain source, `sync h/t`, last error) and the last save/test answer. It is the node's answer, never the draft above it, and `Ctrl-R` re-reads it. - `Ctrl-S` saves and starts the child (the daemon, and `monerod` for a local source); `Ctrl-X` stops it. Both go through the same `Node::start_wallet_child` / `stop_wallet_child` the app's own lifecycle uses, so a start that lands on a wallet with no stored passphrase still reaches the unlock prompt. F6 loses the chain picker and the `s`/`x`/`p` child keys — it is the wallet again (receive, balance, transfers, create/import) — and its footer points at `F7 node`. The `F9` menu's `child`/`sync` rows now name `F7 ctrl-s/x` and `F7 ctrl-r` instead of keys that no longer exist on F6. `set_cuprate_chain` and the `p` probe handler are deleted rather than left dead. The node's own keys are named in the body, on the section they act on: at 80 columns the footer has room for one group and the status line already spends half the width, which is the same reason the login row names `Ctrl-U`. Tests: six new cases in `src/tui.rs`'s `wallet_setup_config_tests` drive the real key path and the real node — the typed datadir reaching `ChainSource::Local`, an empty one being refused with nothing written, the live row on open, `Ctrl-S` saving then reporting the node's own refusal, the in-process network pick reaching the store, and F6 no longer owning keys it does not handle. `tests/tui_spec.rs`'s menu-key check now asserts the F7 keys; the F6 keys it asserted before no longer work.
This commit is contained in:
parent
a37712f3af
commit
5cdfbacf10
6 changed files with 509 additions and 106 deletions
34
src/node.rs
34
src/node.rs
|
|
@ -689,16 +689,42 @@ impl Node {
|
|||
/// Spawn a local `monerod`. Datadirs are split exactly as they are for the
|
||||
/// in-process daemon so a pruned store cannot mix with a full one.
|
||||
pub fn set_local_monerod(&self, monerod_bin: &Path, prune: bool) -> Result<(), String> {
|
||||
let datadir = self.local_chain_datadir(prune);
|
||||
self.set_local_monerod_at(monerod_bin, &datadir, prune)
|
||||
}
|
||||
|
||||
/// The chain datadir a local node uses when the user did not name one.
|
||||
/// Split by prune mode exactly as it always was, so an existing install
|
||||
/// keeps the store it already has.
|
||||
pub fn local_chain_datadir(&self, prune: bool) -> PathBuf {
|
||||
self.home
|
||||
.join("chain")
|
||||
.join(if prune { "mainnet-pruned" } else { "mainnet-full" })
|
||||
}
|
||||
|
||||
/// [`Self::set_local_monerod`], with the chain datadir spelled out — the
|
||||
/// shape the F7 screen saves when the user typed one.
|
||||
///
|
||||
/// An empty datadir is refused rather than silently replaced with the
|
||||
/// default: a store that moved without the user saying so looks exactly
|
||||
/// like a chain that vanished, and a silent rewrite would resync the whole
|
||||
/// chain into a directory they did not choose.
|
||||
pub fn set_local_monerod_at(
|
||||
&self,
|
||||
monerod_bin: &Path,
|
||||
datadir: &Path,
|
||||
prune: bool,
|
||||
) -> Result<(), String> {
|
||||
if datadir.as_os_str().is_empty() {
|
||||
return Err("chain datadir required for a local node".into());
|
||||
}
|
||||
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");
|
||||
}
|
||||
cfg.source = ChainSource::Local {
|
||||
monerod_bin: monerod_bin.to_path_buf(),
|
||||
datadir: self
|
||||
.home
|
||||
.join("chain")
|
||||
.join(if prune { "mainnet-pruned" } else { "mainnet-full" }),
|
||||
datadir: datadir.to_path_buf(),
|
||||
prune,
|
||||
};
|
||||
self.set_wallet_child_config(&cfg)
|
||||
|
|
|
|||
Loading…
Reference in a new issue