Builder
Builder for MidnightSdk.
Required: network, seed. Optional: accountIndex (default 0), provingMode (default LOCAL), proofServerUrl (default null → network's local-dev proof server).
Functions
Set the HD wallet account index (default 0).
Optional cross-device backup of host app state (≤2 KB). The factory is invoked once during build with the wallet seed (so the coordinator derives its seed-based encryption key — no per-backup biometric). The resulting AppStateCloudBackup is wired into the wallet for silent automatic backup/restore. Omit it (default) and app-state backup is absent. Sibling of dustCloudBackupFactory.
Build the SDK. This is a blocking operation on first launch:
Optional cross-device dust backup. The factory is invoked once during build with the derived address + dust seed (so the coordinator can derive its encryption key); the resulting DustCloudBackup is wired into both the dust-sync cold-start (restore) and the wallet (upload). Omit it (the default) and dust backup is simply absent.
Optional restore gate awaited ONCE before the first dust sync that finds no local checkpoint (a fresh install / new device / new network). The host's chance to obtain Drive consent so the cloud-checkpoint restore can succeed instead of the sync silently replaying from genesis. The SDK hands the gate the restored RestoredAppState (prefs + host payload, null when nothing is in the cloud) — the gate can fire during build, before the host holds any SDK handle, so it can't fetch that itself. Must resolve promptly (grant, decline, or nothing-to-do) and must NOT call back into wallet sync APIs (it runs inside the dust-sync critical section). Omit it (the default) and behavior is unchanged. Registered as a builder option — not a post-build property — because the proactive dust sync starts at build time and would otherwise race past the gate into genesis.
Set the Midnight network (PREPROD, PREVIEW, UNDEPLOYED).
Keep dust pre-synced in the background (#235). When enabled, the SDK runs a live tip-advance dust subscription so a transaction never waits on a cold sync; progress is observable via MidnightWallet.syncStatus (and surfaced by the foreground-service Live-Update notification). Off by default — opt in for wallet-first apps. Delta only; the first cold sync is still O(chain) but now runs ahead of need.
Override the proof-server URL used when provingMode is REMOTE. Null (default) means "use the network's default proof-server URL" (NetworkConfig.forNetwork(network).proofServerUrl, which points at a local proof server on localhost:6300 for every network the SDK supports). Pass an explicit URL to point at a hosted prover.
Pick how transactions are proved. Defaults to ProvingMode.LOCAL — on-device proving with cached keys, no network round-trip per tx.