buildDustActions

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

Builds dust actions for transaction fee payment.

Steps:

  1. Calculate transaction fee using midnight-ledger

  2. Load DustLocalState from repository

  3. Create DustSpend for each UTXO in state

  4. Save updated state (contains new nullifiers)

  5. Return DustActions

Implementation Notes:

  • Works directly with DustLocalState (Rust FFI), bypasses database

  • Uses ALL available UTXOs (no coin selection for MVP)

  • Only first spend pays fee, rest have vFee=0

  • State is saved immediately after spends created

Rollback: Not needed for MVP - if transaction fails, state is already saved. Future: Track UTXO states in database for UI display.

Return

DustActions, or null on error

Parameters

transactionHex

SCALE-serialized transaction (hex)

ledgerParamsHex

SCALE-serialized ledger parameters (hex)

address

Wallet address

seed

32-byte seed for deriving DustSecretKey

feeBlocksMargin

Safety margin in blocks (default: 5)