DustActionsBuilder

class DustActionsBuilder @Inject constructor(dustRepository: DustRepository, feeCalculator: FeeCalculator, dustSpendCreator: DustSpendCreator)

Builds DustActions for transaction fee payment.

High-Level Flow:

1. Calculate transaction fee (FeeCalculator)
2. Load DustLocalState from repository
3. Create DustSpend for each UTXO in state (DustSpendCreator)
4. Save updated state (contains new nullifiers)
5. Return DustActions (ready to add to Intent)

DustActions Structure:

  • spends: List of DustSpend actions (one per UTXO)

  • registrations: List of DustRegistration actions (empty for fee payment)

Integration with TransactionSubmitter:

val dustActions = dustActionsBuilder.buildDustActions(
transactionHex = serializedTx,
ledgerParamsHex = paramsHex,
address = userAddress,
seed = userSeed
)

// Add dustActions to Intent
val intentWithFees = intent.copy(dustActions = dustActions)

Note: This implementation works directly with DustLocalState (Rust FFI), bypassing the database for fee payment. Database sync is only needed for UI display.

See also

/midnight-wallet/packages/dust-wallet/src/Transacting.ts:addFeePayment (TypeScript SDK reference)

Constructors

Link copied to clipboard
@Inject
constructor(dustRepository: DustRepository, feeCalculator: FeeCalculator, dustSpendCreator: DustSpendCreator)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class DustActions(val spends: List<DustSpendCreator.DustSpend>, val selectedCoins: List<DustTokenEntity>, val totalFee: BigInteger, val change: BigInteger, val utxoIndices: List<Int>)

Result of building dust actions.

Functions

Link copied to clipboard
suspend fun buildDustActions(transactionHex: String, ledgerParamsHex: String, address: String, seed: ByteArray, feeBlocksMargin: Int = 5): DustActionsBuilder.DustActions?

Builds dust actions for transaction fee payment.

Link copied to clipboard

Confirms dust actions (marks coins as spent after transaction success).

Link copied to clipboard

Rolls back dust actions (unlocks coins after transaction failure).

Link copied to clipboard

Validates dust actions before submission.