wallet: expose an on-demand seed accessor over core + UniFFI #138
Loading…
Reference in a new issue
No description provided.
Delete branch "onionwire/t_2142490d-wallet-seed-expose-an-on-demand-seed-acc"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Expose the wallet's BIP39 seed on demand so the Android wallet screen can offer a "Back up seed" action and re-show the seed of an already-open wallet.
Wallet::create_walletreturned the seed exactly once; after that it was unreachable.What landed
src/wallet.rs—pub async fn mnemonic(&self) -> Result<String>: onequery_key mnemoniccall on the wallet file the RPC has open, returning the words verbatim. Doc-commented as the only recovery path, and as a secret that must never be logged, stored, or put in an error string.src/node.rs—pub async fn wallet_seed(&self) -> Result<String, String>, mirroringwallet_create:NOT_CONFIGURED_MSGwith no dial when unconfigured,.map_err(|e| e.to_string())otherwise.crates/onionwire-sdk/src/lib.rs— additivepub async fn wallet_seed(&self) -> WResult<String>.Kotlin-visible binding name (for the apk-dev child card)
Verified by generating the bindings from the built cdylib (
cargo build --lib, thenuniffi-bindgen generate --library .../libonionwire_sdk.so --language kotlin); the generatedonionwire_sdk.ktdeclaressuspend fun walletSeed(): kotlin.String. That is the 0.32 UniFFI camelCase ofwallet_seed.Strictly additive: no existing SDK signature changed shape, and
crates/onionwire-sdk/Cargo.lockis untouched (no new dependencies).Failure shapes (all without leaking the login)
NOT_CONFIGURED_MSG, no dial;-29still maps to the existing view-only refusal (sameparse_json_rpcpath asview_only());Tests (TDD: RED first,
no method named mnemonicat all four call sites, then GREEN)tests/wallet.rs, on the existing per-connection Digest mock (serve_one_conn/serve_rpc_conns), no new mock:mnemonic_returns_the_words_the_rpc_answers— the 25 words come back verbatim, and the mock panics if any method other thanquery_keyis dialed;mnemonic_surfaces_an_rpc_error_without_leaking_the_login— the RPC message surfaces; the error carries neither the password norhttp://;mnemonic_refuses_a_rejected_digest_without_leaking_the_login— the 401 refusal names the login in prose but never the credential;mnemonic_on_an_unconfigured_wallet_is_a_refusal_not_a_dial—Wallet::disabled()gets exactlyNOT_CONFIGURED_MSG.Verification (real output)
Root:
SDK (separate workspace, own target dir):
Scope
Only
src/wallet.rs,src/node.rs,tests/wallet.rs,crates/onionwire-sdk/src/lib.rs. TUI, android, docs, Cargo.toml and CI untouched. rustfmt hunk counts on all four files equal theirHEADcounts (inherited churn only; no new formatting diffs).Base:
main(3769bd9). PR body braces are written with parens/dashes because Forgejo's template parser eats{{ }}.