syncFromBlockchain

suspend fun syncFromBlockchain(address: String, dustSeed: ByteArray, maxBlocks: Int = 100, onProgress: suspend (eventsProcessed: Int, totalEvents: Int) -> Unit? = null): Boolean

Sync dust from blockchain (query events and replay into local state).

Production Method: This is the main entry point for dust synchronization. Call this when loading balances to ensure dust is up-to-date.

Process:

  1. Query dust events from indexer (scans recent blocks)

  2. Create or load DustLocalState

  3. Replay events into state (using dust secret key)

  4. Sync tokens from state to database cache

  5. Save updated state to persistent storage

Requirements:

  • Dust must be registered on-chain (via Lace or dApp)

  • Dust secret key must be derived from wallet seed at m/44'/2400'/0'/2/0

Return

true if sync succeeded, false if no dust registered or sync failed

Parameters

address

Wallet address to sync dust for

dustSeed

32-byte dust secret key (derived at role 2, index 0)

maxBlocks

Number of recent blocks to scan (default: 100)