sdk: expose the wallet catalogue, the open wallet's keys, and the self profile over UniFFI #145
Loading…
Reference in a new issue
No description provided.
Delete branch "onionwire/t_c9e48c46-onionwire-sdk-expose-the-wallet-catalogu"
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?
What
Extends the UniFFI surface so the Android app can (a) list the saved wallets, select one, and read the open wallet's recovery phrase and private keys, and (b) read/edit its own profile and push it to friends. All the core work already existed; the SDK exposed none of it except the seed.
Base:
origin/main@a9117b8(PR #144).state=openwas 0 PRs when this card started, so nothing is stacked.New symbols
Core (
src/wallet.rs,src/node.rs):Wallet::keys(&self) -> Result<WalletKeys>— twoquery_keycalls (view_key, thenspend_key) against the file the RPC has open. A view-only wallet's-29becomesspend_key: None, not an error.WalletKeyshas a hand-written redactingDebug.Node::wallet_keys(&self) -> Result<wallet::WalletKeys, String>— mirrorswallet_create/wallet_seed; refuses locally withNOT_CONFIGURED_MSGbefore any dial.Node::active_wallet_filename(&self) -> Result<Option<String>, String>— the file the child is pointed at (ChildConfig.wallet_filename);Noneuntil a wallet-child settings record exists (a fresh install), andNonefor a creds-only record written before the settings were persisted.SDK (
crates/onionwire-sdk/src/lib.rs):pub struct WalletRow(Record):id: i64,name: Option<String>,wallet_filename: String,onion_locator: String,identity_pubkey_hex: String,created_at: i64pub struct WalletKeys(Record):view_key: String,spend_key: Option<String>(redactingDebug, noDebugderive)pub struct SelfProfile(Record):display_name: String,bio: String,xmr_addr: Stringpub async fn wallets(&self) -> WResult<Vec<WalletRow>>pub async fn open_wallet(&self, filename: String) -> WResult<()>pub async fn active_wallet_filename(&self) -> WResult<Option<String>>pub async fn wallet_keys(&self) -> WResult<WalletKeys>pub async fn self_profile(&self) -> WResult<SelfProfile>pub async fn set_self_profile(&self, display_name: String, bio: String, xmr_addr: String) -> WResult<()>pub async fn push_self_profile(&self, pubkey_hex: String) -> WResult<()>Every new
pub fncarries the file's existing doc-comment discipline: what it dials, what it refuses, what it returns.crates/onionwire-sdk/Cargo.tomlandCargo.lockare untouched (no dependency changed).The rule the clients must express
The seed and the private keys come from
query_keyagainst the wallet file the child has open, so they always belong to the rowactive_wallet_filename()names. There is deliberately no accessor that reads another catalogue wallet's seed or keys without opening it:open_wallet(...)first, and the UI says which wallet it is showing. A Kotlin picker pairs the two calls —wallets()for the list,activeWalletFilename()to mark the open row,openWallet(row.walletFilename)to switch (which may restart a running wallet child), thenwalletSeed()/walletKeys().Kotlin reachability (generated, not assumed)
cargo build --libthenuniffi-bindgen generate --library libonionwire_sdk.so --language kotlinproduces:Tests
Core (
tests/wallet.rs, mock wallet RPC over loopback):keys_returns_the_view_and_spend_keys_of_the_open_wallet— twoquery_keycalls, in order.keys_of_a_view_only_wallet_have_no_spend_key_and_no_error—-29becomesspend_key: None.keys_surfaces_an_rpc_error_that_is_not_the_view_only_answer— any other error is surfaced, and the RPC login does not ride along.keys_on_an_unconfigured_wallet_is_a_refusal_not_a_dial.wallet_keys_debug_never_prints_a_private_key.Core (
src/node.rs#[cfg(test)] mod tests;tests/*.rscannot build aNode):active_wallet_filename_is_none_until_the_child_has_been_pointed—Noneon a fresh install,Nonefor a creds-only record,Nonefor a catalogue row alone,Someafteropen_wallet.wallet_keys_without_a_wallet_refuses_without_dialing.wallet_keys_of_a_view_only_wallet_returns_no_spend_key— the node-level path a Kotlin caller takes.SDK (own
#[cfg(test)] mod tests):WireError.Stoppedtest per new async accessor, mirroringwallet_receive_address_on_stopped_handle_is_stopped_error;push_self_profile_rejects_a_pubkey_that_is_not_hex_before_any_work;wallet_rows_carry_the_catalogue_verbatim(store-backed: two rows throughWalletRow, labelNonevs named, empty locator, pubkey hex);keys_mapping_carries_both_halves_and_the_view_only_answer,wallet_keys_debug_never_prints_a_private_key,self_profile_mapping_carries_the_three_editable_fields.open_walletwith a filename outside the catalogue being refused is already covered onmainbyopen_wallet_refuses_a_file_the_catalogue_does_not_hold(src/node.rs); the SDK accessor is a one-line delegation of that call, and the SDK cannot build aNode(its only constructor bootstraps Arti over the network), so it is covered at the core and by the stopped-handle test at the SDK.Docs (same commit)
docs/WALLET.md: the catalogue accessors and which wallet is open, a new "Secrets belong to the open wallet" section, and two rows in the view-only/spend-capable table.docs/THREAT_MODEL.md: a new "The recovery phrase and the private keys are displayable on demand" section — the phone screen is now one of the places a spending secret can be read from; the values are never logged, never persisted, and shown only from an explicit action; a shoulder-surfer, a screen recorder or a screenshot is not stopped by any of that.crates/onionwire-sdk/README.md: the Kotlin snippet for the catalogue + active wallet + keys + profile.Verification run here
Root:
cargo test --locked --target x86_64-unknown-linux-gnuandcargo clippy --locked --all-targets --target x86_64-unknown-linux-gnu -- -D warnings— both green.SDK (separate workspace, own target dir):
cargo test --locked(51 + 2 integration tests pass) andcargo clippy --locked --all-targets -- -D warnings— both green.TMPDIRand bothCARGO_TARGET_DIRs are on/home(the host root fs is at 99%).Not verified: nothing runs on a device/emulator here — the Android cards consume these generated names, and the AAR build (Gradle + NDK) is theirs; no NDK build was run.
No core trust boundary changed: the private keys and the seed travel only over the existing loopback Digest RPC to the wallet child, which is the only source for them.
The Android wallet/profile screens had nothing to call: the core could list wallets, switch the child onto one, read its keys and read/write the self profile, but none of it crossed UniFFI. Core: - Wallet::keys() -> WalletKeys { view_key, spend_key: Option<String> }: two query_key calls against the file the RPC has open. A view-only wallet's -29 is spend_key: None, not an error. WalletKeys' Debug redacts both halves. - Node::wallet_keys() mirrors wallet_create/wallet_seed; refuses locally when no wallet is configured. - Node::active_wallet_filename() -> Option<String>: the file the child is pointed at, None until wallet-child settings exist, so a client can mark the open row. SDK (UniFFI): - records WalletRow / WalletKeys / SelfProfile, and Wire::{wallets, open_wallet, active_wallet_filename, wallet_keys, self_profile, set_self_profile, push_self_profile}. - The rule the clients must express is in the docs: the seed and the private keys come from the OPEN wallet, so there is deliberately no accessor that reads another saved wallet's secrets without opening it. docs/WALLET.md (catalogue + 'secrets belong to the open wallet'), docs/THREAT_MODEL.md (the new on-demand-display exposure surface) and the SDK README are updated in the same commit.