DustDao

interface DustDao

DAO for dust token operations.

Provides methods to:

  • Insert dust tokens (from DustLocalState sync)

  • Update token state (AVAILABLE → PENDING → SPENT)

  • Query available dust (for fee payment)

  • Calculate current balance (time-based generation)

  • Handle transaction failures (PENDING → AVAILABLE)

Relationship to DustLocalState: This table caches dust token data from the serialized DustLocalState. Always sync this table when DustLocalState changes.

Functions

Link copied to clipboard
abstract suspend fun count(): Int

Count total dust tokens (for debugging).

Link copied to clipboard
abstract suspend fun countAvailable(address: String): Int

Count available dust tokens for an address (for debugging).

Link copied to clipboard
abstract suspend fun deleteAll()

Delete all dust tokens.

Link copied to clipboard
abstract suspend fun deleteTokensForAddress(address: String)

Delete all dust tokens for an address.

Link copied to clipboard
abstract suspend fun getAvailableTokens(address: String): List<DustTokenEntity>

Get all available dust tokens for an address.

Link copied to clipboard
abstract suspend fun getAvailableTokensSorted(address: String): List<DustTokenEntity>

Get all available dust tokens for an address, sorted by value (smallest first).

Link copied to clipboard
abstract suspend fun getTokenByNullifier(nullifier: String): DustTokenEntity?

Get dust token by nullifier.

Link copied to clipboard
abstract suspend fun getTokensByNightUtxo(nightUtxoId: String): List<DustTokenEntity>

Get all tokens backed by a specific Night UTXO.

Link copied to clipboard
abstract suspend fun insertToken(token: DustTokenEntity)

Insert single dust token.

Link copied to clipboard
abstract suspend fun insertTokens(tokens: List<DustTokenEntity>)

Insert dust tokens into database.

Link copied to clipboard
abstract suspend fun markAsAvailable(nullifier: String)

Mark dust token as available (unlock).

abstract suspend fun markAsAvailable(nullifiers: List<String>)

Mark multiple dust tokens as available.

Link copied to clipboard
abstract suspend fun markAsPending(nullifier: String)

Mark dust token as pending (locked for fee payment).

abstract suspend fun markAsPending(nullifiers: List<String>)

Mark multiple dust tokens as pending.

Link copied to clipboard
abstract suspend fun markAsSpent(nullifier: String)

Mark dust token as spent.

abstract suspend fun markAsSpent(nullifiers: List<String>)

Mark multiple dust tokens as spent.

Link copied to clipboard
abstract fun observeAvailableTokens(address: String): Flow<List<DustTokenEntity>>

Observe all available dust tokens for an address.

Link copied to clipboard
abstract fun observePendingTokens(address: String): Flow<List<DustTokenEntity>>

Observe all pending dust tokens for an address (locked in pending transactions).