UnshieldedUtxoDao

DAO for unshielded UTXO operations.

Provides methods to:

  • Insert UTXOs (created by transactions)

  • Update UTXO state (AVAILABLE → PENDING → SPENT)

  • Query available UTXOs (for balance calculation)

  • Handle transaction failures (PENDING → AVAILABLE)

Functions

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

Count total UTXOs (for debugging).

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

Count ALL UTXOs for an address (any state).

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

Count available UTXOs for an address (for debugging).

Link copied to clipboard
abstract suspend fun deleteAll()

Delete all UTXOs.

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

Delete all UTXOs for an address.

Link copied to clipboard
abstract suspend fun getAllUtxosForAddress(address: String): List<UnshieldedUtxoEntity>

Get ALL UTXOs for an address (any state).

Link copied to clipboard
abstract suspend fun getUnspentUtxos(address: String): List<UnshieldedUtxoEntity>

Get all available UTXOs for an address.

Link copied to clipboard
abstract suspend fun getUnspentUtxosForToken(address: String, tokenType: String): List<UnshieldedUtxoEntity>

Get available UTXOs for a specific token type.

Link copied to clipboard
abstract suspend fun getUnspentUtxosForTokenSorted(address: String, tokenType: String): List<UnshieldedUtxoEntity>

Get available UTXOs for a specific token, sorted by value (smallest first).

Link copied to clipboard
abstract suspend fun getUtxoById(utxoId: String): UnshieldedUtxoEntity?

Get UTXO by ID (transactionHash:outputIndex).

Link copied to clipboard
abstract suspend fun getUtxoByIntentHash(intentHash: String, outputIndex: Int): UnshieldedUtxoEntity?

Get UTXO by intentHash and outputIndex.

Link copied to clipboard
abstract suspend fun insertUtxos(utxos: List<UnshieldedUtxoEntity>)

Insert UTXOs into database.

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

Mark UTXO as available (unlock).

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

Mark multiple UTXOs as available.

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

Mark UTXO as pending (locked for transaction).

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

Mark multiple UTXOs as pending.

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

Mark UTXO as spent (from sync - not local transaction).

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

Mark multiple UTXOs as spent (from sync - not local transaction).

Link copied to clipboard
abstract suspend fun markAsSpentByLocalTx(utxoId: String)

Mark UTXO as spent by LOCAL transaction.

abstract suspend fun markAsSpentByLocalTx(utxoIds: List<String>)

Mark multiple UTXOs as spent by LOCAL transaction.

Link copied to clipboard
abstract fun observePendingUtxos(address: String): Flow<List<UnshieldedUtxoEntity>>

Get all pending UTXOs for an address (locked in pending transactions).

Link copied to clipboard
abstract fun observeUnspentUtxos(address: String): Flow<List<UnshieldedUtxoEntity>>

Get all available UTXOs for an address, grouped by token type.

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

Reset ALL SPENT UTXOs to AVAILABLE for healing during full resync.