wallet: expose an on-demand seed accessor over core + UniFFI
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:
parent
3769bd9a42
commit
145036fda8
4 changed files with 116 additions and 0 deletions
|
|
@ -594,6 +594,17 @@ impl Wire {
|
|||
.map_err(WireError::new)
|
||||
}
|
||||
|
||||
/// Re-read this wallet's 25-word seed so the UI can offer a "back up seed"
|
||||
/// action after creation. Dials the wallet child's RPC (`query_key
|
||||
/// mnemonic`), so it is cheap but not free, and it needs a wallet the child
|
||||
/// has open. The result is a spend key: call this only from an explicit
|
||||
/// user action, show it, and do not persist or log it.
|
||||
///
|
||||
/// The Kotlin binding is `Wire.walletSeed()`.
|
||||
pub async fn wallet_seed(&self) -> WResult<String> {
|
||||
self.node()?.wallet_seed().await.map_err(WireError::new)
|
||||
}
|
||||
|
||||
/// Import a wallet from an existing 25-word seed. This is the only path
|
||||
/// that takes a user-supplied secret.
|
||||
pub async fn import_wallet(&self, password: String, seed: String) -> WResult<()> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue