Skip to content

feat(migration): add legacy wallet migration package and SDK support#348

Merged
CharlVS merged 4 commits intodevfrom
feat/legacy-wallet-migrator
May 2, 2026
Merged

feat(migration): add legacy wallet migration package and SDK support#348
CharlVS merged 4 commits intodevfrom
feat/legacy-wallet-migrator

Conversation

@CharlVS
Copy link
Copy Markdown
Collaborator

@CharlVS CharlVS commented Apr 13, 2026

Status

READY

Description

Adds end-to-end support for migrating legacy native-app wallets into KDF-managed wallets.

New package: komodo_legacy_wallet_migration

  • Platform-abstracted discovery of legacy wallets (secure storage, shared preferences, metadata files)
  • Argon2-based legacy password verification using pure-Dart pointycastle (WASM-compatible, replaces dargon2_flutter)
  • Models for LegacyWalletRecord, LegacyWalletSecrets, LegacyWalletCleanupResult, and migration exceptions
  • Orchestrator that prepares migrations, extracts seed phrases, and cleans up legacy data on completion
  • Comprehensive unit tests (533+ lines)

komodo_defi_sdk

  • New ZhtlcRecurringSyncPolicy type and persistence — separates persisted recurring sync preferences from one-shot sync overrides so reactivations use the correct policy without accidental rewinds
  • ActivationConfigService gains recurring-policy CRUD, one-shot consume/take semantics, and migration-aware config promotion
  • ZHTLC activation strategy now applies one-shot sync params once and omits sync_params on subsequent activations
  • New unit tests for ActivationConfigService and ZhtlcActivationStrategy one-shot behavior

komodo_defi_framework

  • Harden KDF start/stop readiness checks: native-status polling (no HTTP during shutdown), bounded version-probe timeouts, and resetHttpClient() after stop to drop stale keep-alive sockets
  • isRunning() gains allowVersionFallback parameter to avoid HTTP probes during shutdown verification

komodo_defi_local_auth

  • Auth registration now returns the KdfUser directly instead of requiring a post-register read
  • _waitUntilKdfRpcReady() replaces _waitUntilKdfRpcIsUp() with stricter two-phase readiness (status + version probe) and configurable timeouts
  • New _runStartupSensitiveRpc() retry wrapper that resets the HTTP client and re-waits for RPC readiness on transport failures
  • Detailed per-phase stopwatch logging throughout register, restart, and authentication flows

komodo_defi_types

  • AuthExceptionType.legacyWalletAlreadyMigrated variant and convenience constructor

komodo_defi_rpc_methods

  • Updated sync_params doc comments to clarify client-optional / backend-resume semantics

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • 🧹 Code refactor

CharlVS added 3 commits April 2, 2026 14:50
- persist recurring ZHTLC sync policy while keeping one-shot
  sync overrides transient during activation
- harden KDF start/stop readiness checks and auth retries to
  recover from stale RPC sockets during wallet flows
…mpat

dargon2_flutter's web plugin uses JS interop APIs incompatible with
Flutter WASM builds. Replaced with pointycastle's pure-Dart Argon2
implementation which works on all platforms. Removes 7 transitive
dargon2 packages from the dependency tree.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 49b4c15561

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +194 to +197
final version = await _kdfFramework.version().timeout(
KdfAuthService._kdfRpcProbeTimeout,
onTimeout: () => null,
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Retry readiness probe when version check throws

When startup is in a transitional state, kdfMainStatus() can report rpcIsUp before the RPC listener is actually reachable, so version() may still throw a transport error. This method currently lets that exception escape, which aborts sign-in/register startup immediately instead of continuing to poll until the timeout window. Catch transient probe errors here and continue the loop (like the timeout path) to avoid intermittent auth failures during KDF warm-up.

Useful? React with 👍 / 👎.

Comment on lines +60 to +64
Future<LegacyWalletSecrets> readWalletSecrets({
required LegacyWalletRecord wallet,
required String password,
}) async {
try {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard secret reads on unsupported platforms

readWalletSecrets skips the platform gate used by listLegacyWallets/deleteLegacyWalletData and immediately attempts legacy storage access. On unsupported runtimes (web/desktop), this can surface adapter/plugin failures as storageAccessError instead of the dedicated unsupported-platform outcome, making caller handling inconsistent and harder to recover from. Add an early isSupportedPlatform check in this entrypoint as well.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 13, 2026

Visit the preview URL for this PR (updated for commit af9c5b7):

https://komodo-playground--pr348-feat-legacy-wallet-m-e8aljoec.web.app

(expires Mon, 20 Apr 2026 09:37:17 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 2bfedd77fdea45b25ba7c784416e81f177aa5c47

Catch transient transport errors (SocketException, HttpException,
HandshakeException) during the version probe in _waitUntilKdfRpcReady
so the polling loop continues instead of aborting the auth flow when
kdfMainStatus reports rpcIsUp before the listener is fully reachable.

Add isSupportedPlatform guard to readWalletSecrets, consistent with
listLegacyWallets and deleteLegacyWalletData, so unsupported runtimes
get the dedicated unsupportedPlatform exception instead of a generic
storageAccessError.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af9c5b7140

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +195 to +198
final version = await _kdfFramework.version().timeout(
KdfAuthService._kdfRpcProbeTimeout,
onTimeout: () => null,
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Catch timeout probe failures in RPC readiness loop

The readiness loop can still abort prematurely during normal KDF warm-up because _kdfFramework.version() now has its own 2s timeout and may throw TimeoutException, but this method only retries on socket/HTTP/handshake errors. In that case, _waitUntilKdfRpcReady exits immediately instead of continuing to poll until the overall readiness timeout, which can cause intermittent startup/sign-in/register failures on slower devices or cold starts.

Useful? React with 👍 / 👎.

@CharlVS CharlVS merged commit 4a17aec into dev May 2, 2026
2 of 5 checks passed
@CharlVS CharlVS deleted the feat/legacy-wallet-migrator branch May 2, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant