Skip to content

Asset-lock restore safety: chain rediscovery, external lock adoption, consumed reconciliation #4254

Closed as not planned

Description

@HashEngineering

Problem. The tracked-lock table (tracked_asset_locks) is populated ONLY by (a) a local build in-process (asset_lock/build.rs:1219-1231, sole track_asset_lock call site) or (b) DB replay (apply.rs:326-345, load.rs:69-101). There is no chain-driven insertion: core_bridge.rs — the sole consumer of WalletEvent — never emits an asset-lock changeset; dash-spv has no asset-lock concept; the matcher classifies credit outputs (transaction_router/mod.rs:137-158, account_checker.rs:815-860) but the match is consumed only for address-used watermarks (core_bridge.rs:538-552).

Consequences:

  1. Seed restore on a fresh device permanently loses every pending asset lock (registration, top-up, invitation): the recovery surface is empty, resume_asset_lock returns AssetLockNotTracked, and the funds sit in the OP_RETURN burn with no local record of the credit-output key path. The funding-index watermark is also lost (build.rs:969-1030 documents the invitation bearer-key-reuse hazard).
  2. No consumed-state reconciliation: a lock consumed Platform-side but not locally marked stays "resumable" forever; every resume gets the deterministic rejection (the code comments accept this as the UX — registration.rs:274-279, platform_addresses/fund_from_asset_lock.rs:371-378 — but nothing ever self-heals the row).
  3. The one import hook that could help, asset_lock_manager_recover (rs-platform-wallet-ffi/src/asset_lock/sync.rs:164-214), has zero callers anywhere and requires the caller to already know funding_type / identity_index / the raw tx — i.e. a host-side classifier that does not exist.

Asks (in priority order).

  1. Consumed reconciliation (small): when a resume is rejected as already-consumed, mark the local row Consumed so the resumable list self-heals. Mirrors the tombstone the success path writes (tracking.rs:131-168).
  2. Rediscovery (design): wire the existing credit-output match into lock tracking — on scanning an asset-lock tx paying a known identity-funding path, insert a tracked row (IdentityTopUpNotBound + status from chain context, e.g. ChainLocked, is the natural shape per resolve_status_with_in_memory, recovery.rs:141-184). This is what makes seed restores recover pending top-ups, and it composes with Issue B (the unbound account is what legacy locks appear on).
  3. Alternatively/meanwhile — make asset_lock_manager_recover usable: document + expose it through the SDKs so a host that CAN classify (e.g. dash-wallet scanning its dashj-side topupFundingTransactions during migration) can import legacy pending locks into the SDK queue. This is the migration path for dash-wallet's legacy checkTopUps retirement.

Wallet impact. Until 2+3 exist, dash-wallet must keep its legacy dashj top-up recovery path alive behind the cutover flag for all pre-cutover pending top-ups, and seed restores lose SDK-pending top-ups (funds recoverable only by re-running discovery on a device that still has the DB).


Context: dashpay/dash-wallet#1520 (SDK cutover Phase 1B, asset-lock sends) / MO-998. Findings verified against integration/kotlin-sdk-stack + rust-dashcore dev @ 9c87ccb3.

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