wallet: expose an on-demand seed accessor over core + UniFFI
All checks were successful
ci / test (pull_request) Successful in 5m43s
ci / sdk (pull_request) Successful in 1m21s
android-ci / android (pull_request) Successful in 11m53s
ci / fuzz (pull_request) Successful in 4m53s

Wallet::create_wallet returned the 25-word seed exactly once and nothing
could reach it afterwards, so a seed that was never backed up at creation
was unrecoverable. Add Wallet::mnemonic() (one query_key mnemonic call on
the open wallet file), Node::wallet_seed() mirroring wallet_create, and the
additive UniFFI export Wire::wallet_seed() -> Kotlin Wire.walletSeed().

No existing signature changes. The refusals stay leak-free: an unconfigured
wallet gets NOT_CONFIGURED_MSG without a dial, a watch-only wallet keeps the
RPC's -29 view-only mapping, and no error string carries the RPC login.

Tests (tests/wallet.rs) drive the per-connection Digest mock: the words come
back verbatim, a JSON-RPC error surfaces without the login or endpoint, a
rejected digest refusal does not leak the password, and an unconfigured
wallet is refused without dialing.
This commit is contained in:
agent 2026-09-20 11:53:19 -04:00
commit 145036fda8
No known key found for this signature in database
4 changed files with 116 additions and 0 deletions

View file

@ -1179,6 +1179,18 @@ impl Node {
.map_err(|e| e.to_string())
}
/// Re-read the seed of the wallet file the child has open. `create_wallet`
/// returns it once; after that this is the only path to it. The seed is a
/// spend key, so the caller must only show it on an explicit user action
/// and must not log or store it.
pub async fn wallet_seed(&self) -> Result<String, String> {
let w = self.wallet_snapshot();
if !w.configured() {
return Err(wallet::NOT_CONFIGURED_MSG.into());
}
w.mnemonic().await.map_err(|e| e.to_string())
}
/// Import a wallet from an existing 25-word seed. This is the only path
/// that takes a user-supplied secret.
pub async fn wallet_restore(&self, password: &str, seed: &str) -> Result<(), String> {