You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
platform-wallet: a shielded Clear cannot keep a removed identity's tip account when the host snapshot does not load or does not list the wallet #6314
Since #5934 a shielded Clear keeps the numbers of a wallet's identity (tip) accounts in Rust's shielded store, so the account of an identity removed from the device keeps scanning after the Clear has the host wipe its viewing key rows. For a wallet that has not registered on that store yet, the Clear takes the numbers from the host: it calls PlatformWalletPersistence::load() before the wipe and reads shielded.viewing_keys.
That read is the whole host snapshot, so two cases still lose the account:
The snapshot does not load. On Android one viewing key blob of the wrong length makes the Room load fail as a whole, healthy rows included. The Clear goes on (it is the recovery for unreadable rows) and the wipe deletes the rows by wallet id, without decoding them.
The snapshot loads without the rows.FFIPersister::load does not call the viewing key loader when the wallet list callback is not wired or returns no entry. Room leaves a wallet with no stored account xpub out of that list, and a C host can wire viewing key persistence and the wipe without wallet restore.
A retryable load failure (a busy database) is not one of them: the Clear stops with ErrorPersisterLoadTransient and nothing reset.
Impact
As in #6306: no funds are lost. The account is derived from the seed and is bound again, and scanned from zero, once its identity is back on the device. It needs a removed identity whose profile still publishes the address, a wallet that has not bound since the store began keeping the numbers, and one of the two cases above, together with a Clear.
Proposed fix
A narrow host read that needs no key bytes and no wallet list: the (wallet_id, account_index) pairs of the viewing key rows in the wipe's scope.
A new PlatformWalletPersistence method and capability, with the FFI slot, the JNI bridge method and the Swift, Kotlin and SQLite implementations (a SELECT wallet_id, account_index over the rows the wipe would delete).
NetworkShieldedCoordinator::keep_host_identity_accounts uses it instead of load(); which accounts are identity accounts stays decided in Rust.
Tests: a malformed key blob beside a readable retired account, and a populated key table with an empty restore list.
A third case from the review of #5934 (#5934 (comment)), to fix with the narrow read: the mobile bridges do not classify a failed read. Since #5934 a read the host reports as retryable stops the Clear with ErrorPersisterLoadTransient and nothing reset. But the JNI load helper (with_bridge_load) clears the Java exception and its trampolines return code 1, and the Swift handler's fetch failures return 1 too, so a locked Room or SwiftData store reads as a permanent failure and the Clear goes on to the wipe. The narrow read should return a retryable code (-2) for a lock or busy error on each host, so the decision to stop stays in Rust.
Two host-side items for the Clear's pre-wipe host read move here from #5934, so the fix for this issue covers them:
A busy database reported as permanent. The Kotlin and Swift load callbacks should pass known retryable storage errors (a busy or locked database) through as the transient code (-2). Today a busy read is reported as permanent, so the Clear goes on instead of stopping as ErrorPersisterLoadTransient.
Sync after a Clear stopped by a retryable read. Clear stops the sync loop before that read, and a transient failure returns before anything is reset (manager/mod.rs, the clear_shielded doc). A host that does not retry the Clear right away should start sync again. It must not override a Stop the user asked for while the Clear was in flight, and it must not restart after a permanent failure or a successful Clear, where the re-bind starts sync. This applies only once the first item makes the transient code reachable from the mobile hosts.
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
Two more parts of this limitation, from the review of #5934:
Clear reads the host's whole load(), so a failure in an unrelated slot also drops the kept identity accounts.
On iOS, inNetworkWalletIds() swallows its fetch error ((try? …) ?? [] in PlatformWalletPersistenceHandler.swift), so the load "succeeds" with nothing to keep.
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
Activity
QuantumExplorer commentedon Nov 26, 2026
A third case from the review of #5934 (#5934 (comment)), to fix with the narrow read: the mobile bridges do not classify a failed read. Since #5934 a read the host reports as retryable stops the Clear with
ErrorPersisterLoadTransientand nothing reset. But the JNI load helper (with_bridge_load) clears the Java exception and its trampolines return code 1, and the Swift handler's fetch failures return 1 too, so a locked Room or SwiftData store reads as a permanent failure and the Clear goes on to the wipe. The narrow read should return a retryable code (-2) for a lock or busy error on each host, so the decision to stop stays in Rust.PastaPastaPasta commentedon Nov 27, 2026
Two host-side items for the Clear's pre-wipe host read move here from #5934, so the fix for this issue covers them:
-2). Today a busy read is reported as permanent, so the Clear goes on instead of stopping asErrorPersisterLoadTransient.manager/mod.rs, theclear_shieldeddoc). A host that does not retry the Clear right away should start sync again. It must not override a Stop the user asked for while the Clear was in flight, and it must not restart after a permanent failure or a successful Clear, where the re-bind starts sync. This applies only once the first item makes the transient code reachable from the mobile hosts.🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
PastaPastaPasta commentedon Dec 4, 2026
Two more parts of this limitation, from the review of #5934:
load(), so a failure in an unrelated slot also drops the kept identity accounts.inNetworkWalletIds()swallows its fetch error ((try? …) ?? []inPlatformWalletPersistenceHandler.swift), so the load "succeeds" with nothing to keep.🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.