tui: F7 becomes the node-setup screen, and F6 goes back to being the wallet #169
6 changed files with 1796 additions and 80 deletions
12
README.md
12
README.md
|
|
@ -200,15 +200,19 @@ payload can contain `?`).
|
|||
| `F3` | Paste a friend's invite |
|
||||
| `F4` | Rotate **onion** (locator only) |
|
||||
| `F5` | Selected friend's profile (`/who`) |
|
||||
| `F6` | Wallet (receive QR, create/import, child, chain source) |
|
||||
| `F6` | Wallet (receive QR, balance, transfers, create/import) |
|
||||
| `F7` | Node & wallet setup (wallet RPC endpoint, chain source, start/stop, live node state) |
|
||||
| `F8` | Rotate **prekey** (hard cut: every friend re-pastes the invite) |
|
||||
| `F9` | Wallets & settings menu (`/settings`) |
|
||||
| Enter | Send chat to the selected friend, or run a `/command` |
|
||||
| `Esc` | Close overlay / back to Main / clear composer |
|
||||
| `Ctrl-Q` | Quit: type `CLEAR`+Enter to wipe history, `QUIT`+Enter to leave it, Esc to stay |
|
||||
|
||||
There is **no `F7`**. The not-configured wallet error still says “open F7”; the
|
||||
live screens are `F6` (wallet) and `F9` (settings). Full map: [docs/TUI.md](docs/TUI.md).
|
||||
`F7` is where the Monero side is set up: the wallet RPC endpoint and login, the
|
||||
chain source (receive-only, a local `monerod`, a remote daemon, or the in-process
|
||||
Cuprate node), the chain datadir, and `Ctrl-S`/`Ctrl-X` to start and stop it. It
|
||||
is also what the “open F7” wallet error points at. Full map:
|
||||
[docs/TUI.md](docs/TUI.md).
|
||||
|
||||
Composer `/commands` (`src/tui.rs` `parse_cmd`): `/wipe`, `/wipe-all`, `/profile`,
|
||||
`/who`, `/pay <xmr> [memo]`, `/tip <xmr> [memo]`, `/backup /path`, `/restore /path`,
|
||||
|
|
@ -425,7 +429,7 @@ Do not run `cargo publish`; `publish = false`.
|
|||
| Blank / broken TUI | Real terminal emulator, not `nohup` / systemd without a TTY. |
|
||||
| Two chats, same laptop | Separate `ONIONWIRE_HOME` per process. |
|
||||
| Friend cannot find you after F4 | Expected if they were offline. They F3-paste the new invite. |
|
||||
| Wallet error says “open F7” | There is no F7. Use `F6` / `F9`, or set `ONIONWIRE_WALLET_RPC`. |
|
||||
| Wallet error says “open F7” | `F7` is the node & wallet setup screen: set the RPC endpoint there, or set `ONIONWIRE_WALLET_RPC`. |
|
||||
|
||||
## Not in v1
|
||||
|
||||
|
|
|
|||
114
docs/TUI.md
114
docs/TUI.md
|
|
@ -22,16 +22,17 @@ ASCII chrome.
|
|||
| `Wipe` | `/wipe` or `/wipe-all` | Type `WIPE` or `WIPEALL` |
|
||||
| `Profile` | `/profile` | Edit name, bio, optional Monero address |
|
||||
| `ConfirmKeys` / `Passphrase` | `/backup`, `/restore` | Type `BACKUP`/`RESTORE`, then passphrase |
|
||||
| `Wallet` | `F6` | Receive QR, balance, transfers, child, chain source |
|
||||
| `Wallet` | `F6` | Receive QR, balance, transfers |
|
||||
| `WalletSelect` | `F6` `w` | Saved wallets, pick one or create one |
|
||||
| `WalletSetup` | `F6` `c` / `i`, or `/wallet create` / `import` | Spend warning, seed, optional seed-offset passphrase, import |
|
||||
| `WalletsSettings` | `F9` or `/settings` | Discovery menu (does not replace F-keys) |
|
||||
| `WalletSetupConfig` | `F7` | Node & wallet setup: RPC endpoint, chain source, start/stop, live node state |
|
||||
| `PeerPayments` | F9 then `p` | Peer-scoped `/pay` / `/tip` history |
|
||||
| `Quit` | `Ctrl-Q` | Type `CLEAR` or `QUIT` |
|
||||
|
||||
Help (`?`) is an overlay, not a screen. `/who` / `F5` is an overlay on Main.
|
||||
|
||||
There is **no `F7`**. Function keys that fire from Main, the settings menu, and
|
||||
Function keys that fire from Main, the settings menu, and
|
||||
peer-payments are:
|
||||
|
||||
| Key | `FunctionKey` | Action |
|
||||
|
|
@ -41,11 +42,13 @@ peer-payments are:
|
|||
| `F4` | Rotate | Onion locator |
|
||||
| `F5` | Who | Selected friend's profile |
|
||||
| `F6` | Wallet | Wallet screen |
|
||||
| `F7` | Setup | Node & wallet setup: RPC endpoint, chain source, start/stop |
|
||||
| `F8` | RotatePrekey | Prekey hard cut |
|
||||
| `F9` | OpenMenu | Wallets & settings |
|
||||
|
||||
`F9` is live on Main, the settings menu, and peer-payments so a printed shortcut
|
||||
never no-ops there. Other screens handle their own keys (Esc back, typed
|
||||
never no-ops there, and `F7` joins it for the same reason: `/settings` points at
|
||||
the setup screen. Other screens handle their own keys (Esc back, typed
|
||||
confirms).
|
||||
|
||||
## Main
|
||||
|
|
@ -53,16 +56,21 @@ confirms).
|
|||
Focus starts on the composer. Footer hints (`main_footer_hints`):
|
||||
|
||||
```
|
||||
Tab F2 F3 F4 F5 F6 F9 ? help Ctrl-Q
|
||||
Tab F2 F3 F4 F5 F6 F7 F9 ? help Ctrl-Q
|
||||
```
|
||||
|
||||
Pane-specific (`pane_footer_hints`):
|
||||
|
||||
| Pane | Hint |
|
||||
|---|---|
|
||||
| Roster | `j k select F3 add F6 wallet F9 settings ? help` |
|
||||
| Chat | `j k scroll g G ends F4 rotate F9 settings ? help` |
|
||||
| Composer | `Enter send / commands F9 settings ? help` |
|
||||
| Roster | `j k F3 add F6 wallet F7 setup F9 ? help` |
|
||||
| Chat | `j k g G ends F4 rotate F7 setup F9 ? help` |
|
||||
| Composer | `Enter send / commands F7 setup F9 ? help` |
|
||||
|
||||
The status line is drawn from the focused pane's hint, and the compactor drops
|
||||
tokens from the front until the line fits, so a key that only appears in
|
||||
`main_footer_hints` never reaches an 80-column terminal. `F7` is therefore named
|
||||
in both, and the `F9` beside it is left bare so the whole hint still fits at 80.
|
||||
|
||||
| Key | Action |
|
||||
|---|---|
|
||||
|
|
@ -107,10 +115,14 @@ Pane-specific (`pane_footer_hints`):
|
|||
|
||||
## Wallet (`F6`)
|
||||
|
||||
The wallet, not the node: receive, balance, transfers, and create/import. Chain
|
||||
and node configuration is `F7` (`Configures the wallet RPC endpoint and the
|
||||
chain source`), named in the footer so the key is findable from here.
|
||||
|
||||
Footer:
|
||||
|
||||
```
|
||||
c create i import r qr w wallets s/x child 1 pruned 2 full 3 testnet Esc back ? help
|
||||
c create i import r qr w wallets F7 node Esc back ? help
|
||||
```
|
||||
|
||||
| Key | Effect |
|
||||
|
|
@ -119,14 +131,14 @@ c create i import r qr w wallets s/x child 1 pruned 2 full 3 testnet Esc
|
|||
| `w` | Saved wallets (`WalletSelect`) |
|
||||
| `c` | Create wallet (`SPEND` then seed once, type `SEEN`) |
|
||||
| `i` | Import 25-word seed |
|
||||
| `s` | Start app-owned wallet child |
|
||||
| `x` | Stop child (idempotent) |
|
||||
| `p` | Probe child (RPC answering? chain at tip?) |
|
||||
| `1` | In-process Cuprate **mainnet pruned** (unvalidated) |
|
||||
| `2` | In-process Cuprate **mainnet full** (unvalidated) |
|
||||
| `3` | In-process Cuprate **testnet** |
|
||||
| `F7` | Node & wallet setup (`WalletSetupConfig`) |
|
||||
| Esc | Back to Main |
|
||||
|
||||
The child's state and the chain source are shown here (and on `F9`), but they are
|
||||
**set** on `F7`: the start/stop/probe keys and the `1`/`2`/`3` in-process picker
|
||||
that used to live on this screen are gone, so there is one place that configures
|
||||
the chain.
|
||||
|
||||
The chain line for an in-process source always carries
|
||||
`testnet only — mainnet is unvalidated` (`cuprate::TESTNET_ONLY`). Starting
|
||||
Cuprate needs `--features cuprate-daemon`; without it, start fails with that
|
||||
|
|
@ -168,11 +180,66 @@ stored identity and locator are catalogue columns, not session state: a locator
|
|||
rotates (`F4`) and identity is the roster key the node already holds, so the
|
||||
live header keeps reading them from the node.
|
||||
|
||||
## Node & wallet setup (`F7`)
|
||||
|
||||
Footer: `Esc back Enter save Ctrl-T test` (plus the status line's own `? help`).
|
||||
The compactor drops tokens from the front, and at 80 columns the status line
|
||||
leaves about 25 cells, so the tail is what the default terminal shows. `Tab` and
|
||||
`?` are universal; the node's own keys (`ctrl-s`, `ctrl-x`, `ctrl-r`) and
|
||||
`Ctrl-U` are named in the body, on the row they act on.
|
||||
Live from Main, the `F9` settings menu, and peer payments; the menu's `endpoint`
|
||||
row names `F7` as the key that edits it. Body is `WalletSetupConfigState`, a
|
||||
snapshot taken when the screen opens — the render path never reads the store.
|
||||
|
||||
This is the only screen that sets up the chain: the wallet RPC endpoint, and the
|
||||
node that serves it.
|
||||
|
||||
| Row | Kind | Notes |
|
||||
|---|---|---|
|
||||
| `url` | text | the wallet RPC endpoint |
|
||||
| `login` | text | `user:pass`. Never rendered back: the row reads `hidden · set` or `(none)` |
|
||||
| `view-only` | toggle | `no_spend`; `/tip` is refused before any dial |
|
||||
| `chain` | picker | `space` cycles receive-only, local node, remote daemon, in-process |
|
||||
| `daemon` | text | `host:port`, for the remote daemon |
|
||||
| `monerod` | text | the binary this box spawns for a local node |
|
||||
| `datadir` | text | where the chain is stored. Prefilled with the path already in use; an empty one is refused rather than silently defaulted |
|
||||
| `prune` | toggle | local and in-process sources |
|
||||
| `network` | picker | in-process source: `space` cycles mainnet (`unvalidated`) and testnet |
|
||||
|
||||
Under them, a `NODE` section: the live `Node::wallet_child_status` line (state,
|
||||
chain source, `sync h/t` once a daemon reports numbers, the last error) and the
|
||||
last save/test answer. The live row is the node's answer, never the draft above
|
||||
it, and it is re-read by `Ctrl-R`.
|
||||
|
||||
`Enter` saves and answers on the status row: `saved · not dialled yet — ctrl-s
|
||||
starts it, ctrl-t tests the endpoint`, or the node's own refusal in its own
|
||||
words. The endpoint is validated by `Node::wallet_save_config` — loopback host,
|
||||
login required — and a rejected form is rejected **before** it is written:
|
||||
nothing in the sealed record moves and a running wallet is not re-dialled.
|
||||
`Ctrl-T` dials the endpoint and answers with the sanitized `PingResult` line
|
||||
(never the password). `Ctrl-U` clears the focused field, which is how a hidden
|
||||
login gets replaced.
|
||||
|
||||
`Ctrl-S` saves and then starts the wallet child — the daemon and, for a local
|
||||
source, `monerod` — so the setup screen is also the key that brings the node up.
|
||||
A start that lands on a wallet file with no stored passphrase moves the app to
|
||||
the unlock prompt. `Ctrl-X` stops the child. Both go through the same
|
||||
`Node::start_wallet_child` / `stop_wallet_child` the app's own lifecycle uses.
|
||||
|
||||
The chain row is written only when it was changed. An untouched row leaves the
|
||||
stored source alone, so opening `F7` to fix a port cannot silently undo an
|
||||
in-process Cuprate choice or move a chain datadir. Picking a remote daemon says
|
||||
so in the same frame — `a daemon you do not run sees this wallet's chain
|
||||
traffic` — because that is the pick that moves chain trust off this box. The
|
||||
address must parse as `host:port` first.
|
||||
|
||||
Esc is the single exit and wipes the login buffer (`Zeroizing<String>`).
|
||||
|
||||
## Wallets & settings (`F9` / `/settings`)
|
||||
|
||||
Discovery layer, not a replacement. Function keys stay live on this screen.
|
||||
Rows name the shortcut they sit beside (`F6 c`, `F6 i`, `F6 r`, `F6 s/x`,
|
||||
`F6 p`, `/profile`, `/backup`, `/wipe`, …).
|
||||
Rows name the shortcut they sit beside (`F6 c`, `F6 i`, `F6 r`, `/profile`,
|
||||
`/backup`, `/wipe`, …).
|
||||
|
||||
- **No credentials** on this screen. Login, seed, and passphrase are never
|
||||
passed into the menu snapshot.
|
||||
|
|
@ -180,14 +247,15 @@ Rows name the shortcut they sit beside (`F6 c`, `F6 i`, `F6 r`, `F6 s/x`,
|
|||
- `p` opens peer payment history for the selected friend (`Node::list_payments`).
|
||||
- Esc back to Main.
|
||||
|
||||
The menu **shows** endpoint state; it does not edit a stored RPC URL. The error
|
||||
copy for an unconfigured wallet still says “open F7” (`src/wallet.rs`); that
|
||||
key does not exist. Set `ONIONWIRE_WALLET_RPC` or use `F6` create/import and
|
||||
the child.
|
||||
The menu **shows** endpoint state; it does not edit it. The `endpoint` row names
|
||||
`F7`, which is the key that opens `WalletSetupConfig` and the key the “open F7”
|
||||
copy in `src/wallet.rs` now points at — that error is no longer advice for a key
|
||||
that does not exist.
|
||||
|
||||
Chain source (binaries, remote host) is stored via `Node::set_wallet_child_config`.
|
||||
The desktop TUI's in-process picker is `F6` keys `1`/`2`/`3`. There is no
|
||||
on-screen editor for an external RPC URL or a remote daemon host.
|
||||
Chain source is stored via `Node::set_wallet_child_config`. `F7` is the one
|
||||
screen that sets any of the four sources — receive-only, a local `monerod`, a
|
||||
remote daemon, or the in-process Cuprate node — along with the external RPC URL
|
||||
and the chain datadir.
|
||||
|
||||
## Peer payments (`F9` then `p`)
|
||||
|
||||
|
|
|
|||
|
|
@ -89,14 +89,17 @@ The child is stopped rather than left answering `-13`, and the status reports
|
|||
(`open_wallet_with_passphrase`, or the TUI/Android prompt) and it is remembered.
|
||||
|
||||
Nothing spawns the child at boot. `Node::start_wallet_child` is the only start
|
||||
path. The desktop TUI drives it from `F6`:
|
||||
path. The desktop TUI drives it from `F7` (`Ctrl-S` / `Ctrl-X`), which is also
|
||||
the screen that picks the chain source:
|
||||
|
||||
| Key | Effect |
|
||||
|---|---|
|
||||
| `s` | Start the child, then probe it once. A child whose wallet file needs a passphrase opens the passphrase prompt instead of leaving every read at `-13`. |
|
||||
| `x` | Stop it (idempotent). |
|
||||
| `p` | Probe: is wallet RPC answering, is the chain at the tip? |
|
||||
| `1` / `2` / `3` | Store in-process Cuprate as mainnet-pruned / mainnet-full / testnet. |
|
||||
| `Ctrl-S` | Save the form, then start the child and probe it once. A child whose wallet file needs a passphrase opens the passphrase prompt instead of leaving every read at `-13`. |
|
||||
| `Ctrl-X` | Stop it (idempotent). |
|
||||
| `Ctrl-R` | Re-read the live node line (`off` / `connecting` / `syncing` / `ready` / `exited`). |
|
||||
| `Enter` | Save the endpoint and chain source without dialling or starting anything. |
|
||||
| `chain` row + `space` | Receive-only / local `monerod` / remote daemon / in-process Cuprate. |
|
||||
| `network` row + `space` | In-process network: mainnet (unvalidated) or testnet. |
|
||||
|
||||
State shown: `off` / `connecting` / `syncing` / `ready` / `exited`, plus a
|
||||
chain-source label, plus `wallet locked` while a catalogue wallet is configured
|
||||
|
|
@ -149,9 +152,10 @@ cargo build --release --features cuprate-daemon
|
|||
`this build has no in-process chain daemon — rebuild with --features cuprate-daemon`.
|
||||
- **Pre-production.** Cuprate's own user book says do not use `cuprated` for
|
||||
serious purposes. RPC parity is incomplete (`docs/cuprate-launch-spike.md`).
|
||||
- **Mainnet is unvalidated.** The TUI can store mainnet-pruned (`F6` `1`) or
|
||||
mainnet-full (`F6` `2`) or testnet (`F6` `3`). Every in-process surface still
|
||||
prints `testnet only — mainnet is unvalidated` (`cuprate::TESTNET_ONLY`).
|
||||
- **Mainnet is unvalidated.** The TUI stores the in-process network on `F7`'s
|
||||
`network` row (mainnet or testnet) and the store's shape on its `prune` row.
|
||||
Every in-process surface still prints `testnet only — mainnet is unvalidated`
|
||||
(`cuprate::TESTNET_ONLY`).
|
||||
Cross-compiled is not device-proven. Pointing a mainnet wallet at it is not
|
||||
something this build claims to do.
|
||||
- **No Tor on the chain path.** Cuprate's `arti` feature is off (arti-client
|
||||
|
|
@ -207,10 +211,16 @@ Boot precedence: **stored config → env → disabled**. Stored config that cann
|
|||
be used (non-loopback, `.onion`, missing login) is reported and falls back to
|
||||
env rather than dialling the bad endpoint.
|
||||
|
||||
`Store::save_wallet_config` / `Node::wallet_save_config` exist. **No TUI screen
|
||||
writes them.** There is no `F7`. The not-configured refusal still says
|
||||
`Store::save_wallet_config` / `Node::wallet_save_config` exist, and the `F7`
|
||||
screen (`WalletSetupConfig`) writes them: the endpoint, its login, the chain
|
||||
source, and (for a local node) its datadir and network. It is also the only
|
||||
screen that starts and stops the child (`Ctrl-S` / `Ctrl-X`). `F6` and `F9`
|
||||
show state, the env vars are the headless path. The not-configured refusal says
|
||||
`wallet not configured — open F7 to set it up, or set ONIONWIRE_WALLET_RPC`
|
||||
(`src/wallet.rs`). Live surfaces: `F6`, `F9`, or the env vars.
|
||||
(`src/wallet.rs`), and that key is real.
|
||||
|
||||
A save validated by `Node::wallet_save_config` (loopback host, login required)
|
||||
re-points the wallet without a restart; a rejected form writes nothing.
|
||||
|
||||
`/pay` and `/tip` run `wallet_readiness` before send:
|
||||
|
||||
|
|
|
|||
245
src/node.rs
245
src/node.rs
|
|
@ -669,6 +669,75 @@ impl Node {
|
|||
self.set_wallet_child_config(&cfg)
|
||||
}
|
||||
|
||||
/// Point the wallet child at a chain daemon the user runs elsewhere.
|
||||
/// Same shape as [`Self::set_in_process_cuprate`]: read-modify-write on the
|
||||
/// stored settings, an empty `wallet_rpc_bin` filled in, and validation
|
||||
/// before anything is written. A `.onion` host needs no special case here —
|
||||
/// the child pulls in the SOCKS proxy for it (`ChainSource::is_onion`).
|
||||
pub fn set_remote_daemon(&self, host: &str, port: u16) -> 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");
|
||||
}
|
||||
cfg.source = ChainSource::Remote {
|
||||
host: host.trim().to_string(),
|
||||
port,
|
||||
};
|
||||
self.set_wallet_child_config(&cfg)
|
||||
}
|
||||
|
||||
/// 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: datadir.to_path_buf(),
|
||||
prune,
|
||||
};
|
||||
self.set_wallet_child_config(&cfg)
|
||||
}
|
||||
|
||||
/// Back to zero: no wallet child, no daemon, no spend. The way out of a
|
||||
/// misconfigured chain source.
|
||||
pub fn set_receive_only(&self) -> Result<(), String> {
|
||||
let mut cfg = self.wallet_child_config();
|
||||
cfg.source = ChainSource::None;
|
||||
self.set_wallet_child_config(&cfg)
|
||||
}
|
||||
|
||||
/// Start the app-owned wallet child, point this node's wallet at it, and
|
||||
/// **open its wallet file**.
|
||||
///
|
||||
|
|
@ -3585,6 +3654,182 @@ pub(crate) mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
/// The F7 screen's three chain-source choices each round-trip through the
|
||||
/// sealed record, and `receive-only` is the way back to zero.
|
||||
#[tokio::test]
|
||||
async fn the_setup_screen_persists_each_chain_source() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let home = dir.path().join("child");
|
||||
let node = offline_node(&home, Arc::new(NoDial));
|
||||
assert_eq!(
|
||||
node.wallet_child_config().source,
|
||||
ChainSource::None,
|
||||
"a fresh install is receive-only"
|
||||
);
|
||||
|
||||
node.set_remote_daemon("127.0.0.1", 18089)
|
||||
.expect("remote daemon");
|
||||
let remote = node.wallet_child_config();
|
||||
assert_eq!(
|
||||
remote.source,
|
||||
ChainSource::Remote {
|
||||
host: "127.0.0.1".into(),
|
||||
port: 18089,
|
||||
}
|
||||
);
|
||||
assert!(!remote.source.is_onion());
|
||||
assert_eq!(
|
||||
remote.wallet_rpc_bin,
|
||||
PathBuf::from("monero-wallet-rpc"),
|
||||
"an empty binary is filled in, like the in-process source"
|
||||
);
|
||||
|
||||
node.set_remote_daemon("peer.onion", 18089)
|
||||
.expect("onion daemon");
|
||||
assert!(
|
||||
node.wallet_child_config().source.is_onion(),
|
||||
"a .onion host is the source's own SOCKS case, not a special one"
|
||||
);
|
||||
|
||||
node.set_local_monerod(Path::new("/opt/monerod"), true)
|
||||
.expect("local node");
|
||||
assert_eq!(
|
||||
node.wallet_child_config().source,
|
||||
ChainSource::Local {
|
||||
monerod_bin: PathBuf::from("/opt/monerod"),
|
||||
datadir: home.join("chain").join("mainnet-pruned"),
|
||||
prune: true,
|
||||
}
|
||||
);
|
||||
|
||||
node.set_receive_only().expect("receive-only");
|
||||
assert_eq!(node.wallet_child_config().source, ChainSource::None);
|
||||
|
||||
// The last write is what a restart sees.
|
||||
node.set_local_monerod(Path::new("/opt/monerod"), false)
|
||||
.expect("local node");
|
||||
drop(node);
|
||||
let node = offline_node(&home, Arc::new(NoDial));
|
||||
assert_eq!(
|
||||
node.wallet_child_config().source,
|
||||
ChainSource::Local {
|
||||
monerod_bin: PathBuf::from("/opt/monerod"),
|
||||
datadir: home.join("chain").join("mainnet-full"),
|
||||
prune: false,
|
||||
},
|
||||
"the source outlives the process"
|
||||
);
|
||||
}
|
||||
|
||||
/// A chain source the user typed wrong is rejected before it is written, so
|
||||
/// a bad form never points the child at nothing.
|
||||
#[tokio::test]
|
||||
async fn a_rejected_setup_chain_source_is_not_persisted() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let node = offline_node(&dir.path().join("child"), Arc::new(NoDial));
|
||||
node.set_remote_daemon("127.0.0.1", 18089)
|
||||
.expect("remote daemon");
|
||||
let saved = node.wallet_child_config();
|
||||
|
||||
let err = node
|
||||
.set_remote_daemon(" ", 18089)
|
||||
.expect_err("an empty host is refused");
|
||||
assert!(err.contains("daemon host required"), "{err}");
|
||||
let err = node
|
||||
.set_remote_daemon("127.0.0.1", 0)
|
||||
.expect_err("port 0 is refused");
|
||||
assert!(err.contains("daemon port required"), "{err}");
|
||||
let err = node
|
||||
.set_local_monerod(Path::new(""), false)
|
||||
.expect_err("an empty binary path is refused");
|
||||
assert!(err.contains("monerod path required"), "{err}");
|
||||
assert_eq!(
|
||||
node.wallet_child_config(),
|
||||
saved,
|
||||
"a rejected source leaves the stored one alone"
|
||||
);
|
||||
}
|
||||
|
||||
/// The F7 screen's save round-trips through the sealed record, and a save
|
||||
/// can never lock the wallet out of itself: the file passphrase the screen
|
||||
/// does not carry is preserved.
|
||||
#[tokio::test]
|
||||
async fn a_screen_save_round_trips_and_keeps_the_wallet_passphrase() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let node = offline_node(&dir.path().join("child"), Arc::new(NoDial));
|
||||
assert!(
|
||||
node.wallet_config().is_none(),
|
||||
"a fresh install has stored nothing"
|
||||
);
|
||||
|
||||
node.wallet_save_config(&WalletConfig::new(
|
||||
"http://127.0.0.1:18083/json_rpc",
|
||||
"ow:hunter2",
|
||||
false,
|
||||
))
|
||||
.expect("save");
|
||||
let read = node.wallet_config().expect("the save is readable");
|
||||
assert_eq!(read.rpc_url, "http://127.0.0.1:18083/json_rpc");
|
||||
assert_eq!(read.rpc_login.as_str(), "ow:hunter2");
|
||||
assert!(!read.no_spend);
|
||||
assert_eq!(read.wallet_passphrase.as_str(), "");
|
||||
assert!(
|
||||
node.wallet_status().configured(),
|
||||
"the live snapshot follows the save"
|
||||
);
|
||||
|
||||
// The file passphrase is sealed by the open path, not by this screen.
|
||||
node.seal_wallet_passphrase("wallet-file-pass")
|
||||
.expect("seal");
|
||||
assert_eq!(
|
||||
node.wallet_config().expect("stored").wallet_passphrase.as_str(),
|
||||
"wallet-file-pass"
|
||||
);
|
||||
|
||||
// A screen save (which never holds the file passphrase) keeps the stored
|
||||
// one instead of blanking it — a save can never lock the wallet out of
|
||||
// itself. A passphrase a caller hands `wallet_save_config` is ignored
|
||||
// for the same reason: the file's passphrase is not the screen's.
|
||||
let mut screen_save =
|
||||
WalletConfig::new("http://127.0.0.1:18083/json_rpc", "ow:hunter2", true);
|
||||
screen_save.wallet_passphrase = Zeroizing::new("not-the-files".to_string());
|
||||
node.wallet_save_config(&screen_save).expect("resave");
|
||||
let read = node.wallet_config().expect("the resave is readable");
|
||||
assert!(read.no_spend, "the view-only toggle reached the store");
|
||||
assert_eq!(read.wallet_passphrase.as_str(), "wallet-file-pass");
|
||||
}
|
||||
|
||||
/// A rejected form leaves the stored config exactly as it was. The node is
|
||||
/// the validator — the screen does not reimplement it.
|
||||
#[tokio::test]
|
||||
async fn a_rejected_wallet_config_is_not_persisted() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let node = offline_node(&dir.path().join("child"), Arc::new(NoDial));
|
||||
node.wallet_save_config(&WalletConfig::new(
|
||||
"http://127.0.0.1:18083/json_rpc",
|
||||
"ow:hunter2",
|
||||
false,
|
||||
))
|
||||
.expect("save");
|
||||
let before = node.wallet_config().expect("stored");
|
||||
|
||||
for bad in [
|
||||
WalletConfig::new("", "ow:hunter2", false),
|
||||
WalletConfig::new("http://192.0.2.10:18083/json_rpc", "ow:hunter2", false),
|
||||
WalletConfig::new("http://127.0.0.1:18083/json_rpc", "", false),
|
||||
] {
|
||||
let err = node
|
||||
.wallet_save_config(&bad)
|
||||
.expect_err("a bad form is refused");
|
||||
assert!(!err.is_empty());
|
||||
assert_eq!(
|
||||
node.wallet_config().expect("stored"),
|
||||
before,
|
||||
"the stored config is intact"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// `shutdown` stops the processes the app owns: an exit must not orphan a
|
||||
/// spend-capable wallet RPC behind a loopback socket.
|
||||
#[tokio::test]
|
||||
|
|
|
|||
1463
src/tui.rs
1463
src/tui.rs
File diff suppressed because it is too large
Load diff
|
|
@ -1030,11 +1030,13 @@ fn wallets_settings_menu_lists_both_groups_and_every_key() {
|
|||
);
|
||||
}
|
||||
// Every actionable row names the key or command that fires it, including the
|
||||
// F6 wallet screen's own keys, so the menu teaches the shortcuts it sits
|
||||
// beside instead of hiding them.
|
||||
// keys that now live on F7, so the menu teaches the shortcuts it sits beside
|
||||
// instead of hiding them. A row must never name a key that no longer works:
|
||||
// `F6 s/x` and `F6 p` moved to `F7 ctrl-s/x` and `F7 ctrl-r` with the node
|
||||
// screen, and naming the dead keys here is how they would keep looking live.
|
||||
for key in [
|
||||
"F6 s/x",
|
||||
"F6 p",
|
||||
"F7 ctrl-s/x",
|
||||
"F7 ctrl-r",
|
||||
"c copy F6 r",
|
||||
"F6 c",
|
||||
"F6 i",
|
||||
|
|
|
|||
Loading…
Reference in a new issue