wallet: actually open the wallet file, and remember its passphrase
`monero-wallet-rpc` starts with no wallet open and keeps one only for the life of its process, so a restart, a Lock/unlock or a wallet re-point left a live child answering `-13 No wallet file` to every read while the file sat on disk. The app now opens the configured catalogue file itself (`Wallet::open_wallet`, over RPC — never `--wallet-file`/`--password` on argv, which `ps` exposes) after the child is up, and keeps the passphrase that does it, sealed with the store data key beside the RPC creds under its own AAD. - core: `Wallet::open_wallet`, `WalletConfig::wallet_passphrase` (+ `with_wallet_passphrase`, redacted Debug, kept out of the endpoint config), `Error::is_unreachable` for the one retryable class (the port binds a moment after spawn; a timeout is not a start in progress). - store: `wallet_config.sealed_passphrase` column (additive, AAD `onionwire-store-v1:wallet-passphrase`), read-modify-written so the endpoint/login survive; `wallet_save_config` keeps the stored one. - node: `start_wallet_child` opens the file, `open_wallet_with_passphrase` opens a file with a passphrase the user just typed and seals it only once a live daemon accepted it, `wallet_status` grows `wallet_open` and `needs_passphrase`. A child the RPC refuses is stopped rather than left inert; an install with no stored passphrase still starts, and says so. - tui: one-shot prompt (`WalletSetup::UnlockPass`) on a wallet that needs it, reachable from the saved-wallet picker and from `s`. - sdk: `openWalletWithPassphrase`, the two status fields, README flow. - docs: WALLET/THREAT_MODEL/README — the passphrase is kept, and the consequence (the store passphrase is sufficient to spend) is stated rather than implied. Tests: 4 new node tests drive a real child lifecycle against a loopback wallet RPC (open on restart, no open without a passphrase, refused passphrase, sealed-on-success), a `tests/wallet.rs` test asserts the bytes sent (`open_wallet` + filename + password), and `tests/store.rs` covers the sealed column and the plaintext->encrypted upgrade with it set. Mutation-checked: stubbing the two open paths fails all four.
This commit is contained in:
parent
c5725856ad
commit
ed29131a67
12 changed files with 1262 additions and 54 deletions
|
|
@ -892,12 +892,49 @@ impl WalletChildState {
|
|||
}
|
||||
}
|
||||
|
||||
/// Whether the wallet **file** the child is pointed at is open in the running
|
||||
/// `monero-wallet-rpc`.
|
||||
///
|
||||
/// This is not the same question as "is the RPC up": the daemon starts with no
|
||||
/// wallet open, so a live child that answers every call with `-13 No wallet
|
||||
/// file` is `NeedsPassphrase`, not a start failure.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum ChildWalletState {
|
||||
/// Nothing to open, or nothing attempted yet: no catalogue wallet under the
|
||||
/// configured file name, or no child.
|
||||
#[default]
|
||||
Unknown,
|
||||
/// The wallet file is open (`open_wallet` succeeded, or this process just
|
||||
/// created it).
|
||||
Open,
|
||||
/// A wallet file the catalogue holds is not open, and this install holds no
|
||||
/// passphrase that could open it. Not an error: the user supplies it once.
|
||||
NeedsPassphrase,
|
||||
}
|
||||
|
||||
impl ChildWalletState {
|
||||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
ChildWalletState::Unknown => "unknown",
|
||||
ChildWalletState::Open => "open",
|
||||
ChildWalletState::NeedsPassphrase => "needs-passphrase",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One snapshot of the child. Cheap to read: no dial, no lock held across work.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct WalletChildStatus {
|
||||
pub state: WalletChildState,
|
||||
/// A child process is alive right now.
|
||||
pub running: bool,
|
||||
/// The wallet file the child is pointed at is open in its RPC. `false` is
|
||||
/// the honest answer for an off/exited child and for one whose
|
||||
/// `open_wallet` has not succeeded.
|
||||
pub wallet_open: bool,
|
||||
/// A catalogue wallet is configured but not open, so a passphrase is needed
|
||||
/// before any read can work. Distinct from a failed start.
|
||||
pub needs_passphrase: bool,
|
||||
/// A chain source is configured (not receive-only), whether or not it runs.
|
||||
pub configured: bool,
|
||||
/// The chain-source label: `receive-only` / `local node` /
|
||||
|
|
@ -921,6 +958,9 @@ impl WalletChildStatus {
|
|||
return String::new();
|
||||
}
|
||||
let mut line = format!("child {} · {}", self.state.as_str(), self.chain_source);
|
||||
if self.needs_passphrase {
|
||||
line.push_str(" · wallet locked");
|
||||
}
|
||||
// A probe that read nothing says nothing: the line is unchanged until a
|
||||
// daemon (or the wallet's daemon) actually reported numbers. No
|
||||
// percentage is derived — `target_height == 0` is "the daemon told us
|
||||
|
|
@ -1997,6 +2037,8 @@ mod tests {
|
|||
WalletChildStatus {
|
||||
state,
|
||||
running: true,
|
||||
wallet_open: true,
|
||||
needs_passphrase: false,
|
||||
configured: true,
|
||||
chain_source: "in-process node".to_string(),
|
||||
height,
|
||||
|
|
|
|||
Loading…
Reference in a new issue