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
12
src/node.rs
12
src/node.rs
|
|
@ -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> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue