Skip to content

platform-wallet: register a wallet's shielded accounts again after Clear in one Rust operation #6194

Backlog

Description

@QuantumExplorer

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.

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 under shielded_config_lock in both bind entry points. bind_shielded already has a locked body (bind_shielded_locked_unfenced); bind_shielded_from_persisted does 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.rs that follows platform_wallet_manager_bind_shielded's persisted keys, resolver, seed sequence.
  • JNI, Kotlin and Swift callers: Android's fleet pass after Clear and iOS's manualSync rebind pass. platform_wallet_manager_shielded_ordinary_accounts and 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:

  1. Load two wallets, A (the mirror) and B, and bind B through ShieldedService.bindEngine with accounts [1, 2].
  2. Run ShieldedService.clearLocalState.
  3. While its fleet pass is between reading B's accounts and binding B, call PlatformWalletManager.bindShielded(B, listOf(0)) directly.
  4. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions