wallet: optional seed-offset passphrase on import
All checks were successful
ci / test (pull_request) Successful in 6m21s
ci / sdk (pull_request) Successful in 1m28s
android-ci / android (pull_request) Successful in 12m54s
ci / fuzz (pull_request) Successful in 18m31s

Monero's `restore_deterministic_wallet` takes a `seed_offset`: a second
spend secret mixed into the 25 words at restore time, so the same words
with a different offset open a different wallet. It is not the wallet-file
passphrase and must never be sealed, stored, logged or put on an argv.

- `Wallet::restore_wallet` gains `seed_offset: Option<&str>`: None, empty
  or whitespace-only leaves the field out of the JSON entirely; otherwise
  the ends are trimmed and it is sent beside the seed.
- `Node::wallet_restore` passes it through and still seals only the file
  passphrase.
- SDK: `import_wallet` keeps its signature (None) and
  `import_wallet_with_offset` is added (Kotlin `importWalletWithOffset`).
- TUI: a new `ImportOffset` step between the seed and the file passphrase
  (blank Enter skips, a real one is confirmed, a mismatch never dials), and
  `ImportOffsetSeen` after a successful import that used one -- Esc cannot
  leave it, only SEEN, and the offset is not drawn anywhere.
- Docs: WALLET.md, THREAT_MODEL.md, TUI.md, one README sentence.
This commit is contained in:
agent 2026-09-25 00:42:44 -04:00
commit f6a7daf892
No known key found for this signature in database
9 changed files with 623 additions and 34 deletions

View file

@ -958,7 +958,24 @@ impl Wallet {
/// Import an existing wallet from its 25-word seed. This is the only path
/// that takes a user-supplied secret.
pub async fn restore_wallet(&self, filename: &str, password: &str, seed: &str) -> Result<()> {
///
/// `seed_offset` is Monero's optional seed-offset passphrase: a second spend
/// secret mixed into the seed at restore time, so the same words with a
/// different offset open a different wallet. It is **not** the wallet-file
/// `password`; it is never sealed, never stored and never written to an error
/// string, and the app cannot tell a "wrong" offset from a right one — the
/// RPC succeeds and the wallet is simply a different one.
///
/// `None`, empty or whitespace-only leaves `seed_offset` out of the request
/// entirely (never `"seed_offset":""`). Otherwise the ends are trimmed and
/// the value is sent beside the seed; interior spaces are kept.
pub async fn restore_wallet(
&self,
filename: &str,
password: &str,
seed: &str,
seed_offset: Option<&str>,
) -> Result<()> {
let filename = filename.trim();
if filename.is_empty() {
return Err(Error("wallet filename required".into()));
@ -970,16 +987,16 @@ impl Wallet {
if seed.is_empty() {
return Err(Error("seed required to import a wallet".into()));
}
self.rpc(
"restore_deterministic_wallet",
serde_json::json!({
"filename": filename,
"password": password,
"seed": seed,
"language": "English"
}),
)
.await?;
let mut params = serde_json::json!({
"filename": filename,
"password": password,
"seed": seed,
"language": "English"
});
if let Some(offset) = seed_offset.map(str::trim).filter(|s| !s.is_empty()) {
params["seed_offset"] = serde_json::Value::String(offset.to_string());
}
self.rpc("restore_deterministic_wallet", params).await?;
Ok(())
}