Repository navigation
Description
Expected Behavior
After a shielded Clear, a host registers a wallet on the coordinator again with one call, and Rust chooses the accounts (the ordinary accounts the wallet handle already holds, or the default when it holds none) under shielded_config_lock, in the same step as the registration. No other bind can change the wallet's accounts between that choice and the registration, and no host passes an account list back to Rust.
Current Behavior
A Clear drops every wallet's registration on the coordinator and the host registers the loaded wallets again.
- Android, from fix: keep each wallet's shielded accounts when an Android Clear registers it again #6171:
ShieldedService.clearLocalStatereadsPlatformWalletManager.shieldedOrdinaryAccounts(walletId)and passes the list tobindShielded, inside the service's own lock. These are two native calls. A bind made directly on the publicPlatformWalletManager.bindShieldedbetween them is outside that lock, and is replaced by the list read just before it. Nothing in this repository binds that way (both Kotlin call sites are in the service), and the wallet's next bind puts it right. - iOS:
ShieldedService.manualSyncregisters the other wallets after a Clear with the default account[0], whatever they had. Every SwiftExampleApp caller binds[0], so nothing is lost today. - Before fix: keep each wallet's shielded accounts when an Android Clear registers it again #6171 Android bound every other wallet with
[0]unconditionally (Kotlin shielded Clear re-registers other wallets with account [0], replacing their account lists #5989).
Possible Solution
A Rust operation "bind again with the accounts this wallet holds":
packages/rs-platform-wallet/src/wallet/platform_wallet.rs: choose the accounts undershielded_config_lockin both bind entry points.bind_shieldedalready has a locked body (bind_shielded_locked_unfenced);bind_shielded_from_persisteddoes not, so its body has to be extracted first. Skip a wallet that is still bound on the coordinator (ensure_shielded_bound_on).- One FFI export in
packages/rs-platform-wallet-ffi/src/shielded_sync.rsthat followsplatform_wallet_manager_bind_shielded's persisted keys, resolver, seed sequence. - JNI, Kotlin and Swift callers: Android's fleet pass after Clear and iOS's
manualSyncrebind pass.platform_wallet_manager_shielded_ordinary_accountsand its JNI and Kotlin wrappers can then go, unless something else reads them.
This touches the bind entry points that #5934 (v5.2-dev, Clear ownership) restructures, so it is best done on top of, or together with, that work.
Steps to Reproduce (for bugs)
Android SDK consumer, not KotlinExampleApp:
- Load two wallets, A (the mirror) and B, and bind B through
ShieldedService.bindEnginewith accounts[1, 2]. - Run
ShieldedService.clearLocalState. - While its fleet pass is between reading B's accounts and binding B, call
PlatformWalletManager.bindShielded(B, listOf(0))directly. - The direct bind succeeds and the pass then registers B with
[1, 2].
Found in review of #6171. Not reproduced: the window is between two consecutive native calls.
Context
Deferred from #6171: #6171 (comment) and #6171 (comment). #6171 fixes #5989 (wallets coming back with [0]) by making Rust the source of the list; this issue is the remaining step, where Rust also makes the choice and the registration together.
🤖 Generated with Claude Code
Activity