Skip to content

SwiftExampleApp: Load Identity on a wallet-held identity rebuilds its key rows without signing metadata #6074

Open

Description

@QuantumExplorer

Found while reviewing #6054. Pre-existing; #6054 does not change LoadIdentityView.

Problem: in SwiftExampleApp, Identities → Load Identity accepts the id of an identity a wallet already holds. LoadIdentityView.loadIdentity() keeps the existing PersistentIdentity (and its wallet), unlinks its key rows with publicKeys.removeAll() without deleting them, and attaches new rows built from the fetched JSON. The new rows:

  • carry no walletId or identityDerivationPath, so a mnemonic-only signer can no longer sign with those keys;
  • carry no contract bounds;
  • are tagged with the hex identity id, while the wallet's persister tags rows with Base58;
  • leave the old rows in the store, unlinked.

Since #6054 the wallet's persister finds a key row through its parent identity first, so later wallet upserts reach the attached row. But the metadata the rebuild dropped is not restored until a wallet upsert carries it, and the orphans stay.

Fix: for an identity a wallet holds, Load Identity should refuse, or route through the wallet's proved refresh (ManagedPlatformWallet.refreshIdentity), as IdentityKeyRefresher does since #6054. Rows for identities no wallet holds can keep the current rebuild.

Activity

  1. QuantumExplorer commented on Nov 22, 2026

    @QuantumExplorer
    MemberAuthor

    Same hazard in a second caller: the no-wallet branch of IdentityKeyRefresher.refreshBalanceAndKeys (SwiftExampleApp) rebuilds key rows on the main-actor context. Wallet discovery can claim the identity and commit its rows from the persister's background context, off the main actor, between that refresh's fetch and its save. #6054 re-checks identity.wallet after the fetch, which narrows the window but does not close it.

    Fix for both callers: run the plain rebuild through the persistence handler's serial queue, with the wallet-ownership check and the row replacement in one onQueue block. Test: a claim committed between fetch and write leaves the wallet's rows, and their walletId and identityDerivationPath, intact.

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