MidnightWallet

Embedded wallet that handles transaction balancing and submission on-device.

Implements TransactionBalancer so it can be plugged into com.midnight.kuira.core.compact.MidnightConfig as a drop-in replacement for the remote DAppConnectorClient.

Uses DustSyncManager for session-scoped caching. Handles error 170 (InvalidDustSpendProof) by auto-retrying with a fresh dust sync.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Bech32m address this wallet receives NIGHT at. Exposed for dApps that want to display / share it.

Functions

Link copied to clipboard
suspend fun backupDustToCloud()

Snapshot the current dust checkpoint and hand it to the cloud backup coordinator (e.g. Google Drive) for cross-device recovery. No-op when no coordinator is wired or there's no checkpoint yet. The coordinator hash-guards redundant uploads, so this is cheap to call after every sync.

Link copied to clipboard
suspend fun balance(): WalletBalance

Current snapshot of every balance the SDK tracks for this wallet — unshielded NIGHT, shielded NIGHT, DUST, and the registration flag.

Link copied to clipboard
open suspend override fun balanceAndSubmit(provenTxHex: String, onProgress: suspend (BalanceProgress) -> Unit?)
Link copied to clipboard

Observable balance — emits a fresh WalletBalance whenever the wallet's unshielded OR shielded NIGHT changes. Both are driven by background indexer subscriptions, so externally-received funds (an airdrop, an incoming shielded or unshielded transfer) surface automatically without a manual refresh. Each emission also re-reads dust.

Link copied to clipboard
open suspend override fun balanceTransaction(provenTxHex: String): String
Link copied to clipboard
fun close()
Link copied to clipboard
suspend fun refresh(): Any

Force a fresh resync of both shielded and dust state.

Link copied to clipboard
open suspend override fun submitTransaction(balancedTxHex: String)
Link copied to clipboard
suspend fun syncDust(onProgress: suspend (eventsProcessed: Int, totalEvents: Int) -> Unit? = null)

Sync dust state from the blockchain.

Link copied to clipboard
suspend fun waitForFunding(minNight: BigInteger, pollIntervalMs: Long, timeoutMs: Long = DEFAULT_FUNDING_TIMEOUT_MS): WalletBalance

Suspend until the wallet's NIGHT balance reaches minNight or timeoutMs elapses.