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

@ -1473,13 +1473,25 @@ impl Node {
/// Import a wallet from an existing 25-word seed. This is the only path
/// that takes a user-supplied secret — and, like a create, it is remembered
/// in the catalogue under its own file name.
pub async fn wallet_restore(&self, password: &str, seed: &str) -> Result<WalletRecord, String> {
///
/// `seed_offset` is Monero's optional seed-offset passphrase (a second spend
/// secret mixed into the seed at restore time, not the file passphrase). It
/// is forwarded to the RPC and nothing else: never sealed, never stored,
/// never logged, never on the argv, and a wrong one is not an error — the
/// RPC succeeds and the wallet is a different one. Only `password` is sealed
/// here, into the same record the next start opens the file with.
pub async fn wallet_restore(
&self,
password: &str,
seed: &str,
seed_offset: Option<&str>,
) -> Result<WalletRecord, String> {
let w = self.wallet_snapshot();
if !w.configured() {
return Err(wallet::NOT_CONFIGURED_MSG.into());
}
let filename = self.next_wallet_filename()?;
w.restore_wallet(&filename, password, seed)
w.restore_wallet(&filename, password, seed, seed_offset)
.await
.map_err(|e| e.to_string())?;
let record = self
@ -3700,7 +3712,7 @@ pub(crate) mod tests {
);
let imported = node
.wallet_restore("hunter2", "lumber tacit lemon ivory risk")
.wallet_restore("hunter2", "lumber tacit lemon ivory risk", None)
.await
.expect("restore wallet");