Intent

data class Intent(val guaranteedUnshieldedOffer: UnshieldedOffer?, val fallibleUnshieldedOffer: UnshieldedOffer?, val dustActions: List<DustSpendCreator.DustSpend>? = null, val ttl: Long)

Represents a complete Midnight transaction intent.

Purpose:

  • Top-level transaction container

  • Contains offers for unshielded assets

  • Includes TTL (time-to-live) for transaction expiry

  • Includes dust actions for fee payment

Ledger Mapping: Mirrors the ledger's Intent: an optional guaranteed unshielded offer (segment 0, always executes), an optional fallible unshielded offer, contract actions, dust actions for fee payment, a TTL, and a cryptographic binding commitment. When the dust actions are present they are required for the transaction to be valid; the binding commitment is created by the ledger during signing.

Usage in Transaction:

// Simple unshielded transfer
val intent = Intent(
guaranteedUnshieldedOffer = UnshieldedOffer(
inputs = listOf(utxoSpend),
outputs = listOf(recipientOutput, changeOutput)
),
fallibleUnshieldedOffer = null,
ttl = System.currentTimeMillis() + (5 * 60 * 1000) // 5 minutes
)

Important:

  • At least one offer (guaranteed or fallible) must be present

  • Guaranteed offer executes unconditionally (always processes)

  • Fallible offer may fail without invalidating transaction (future use)

  • TTL must be in future (transaction expires after this time)

Constructors

Link copied to clipboard
constructor(guaranteedUnshieldedOffer: UnshieldedOffer?, fallibleUnshieldedOffer: UnshieldedOffer?, dustActions: List<DustSpendCreator.DustSpend>? = null, ttl: Long)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

List of dust spends for fee payment

Link copied to clipboard

Optional fallible segment (may fail)

Link copied to clipboard

Segment 0 offer (always executes)

Link copied to clipboard
val ttl: Long

Time-to-live in milliseconds (Unix epoch time)

Functions

Link copied to clipboard

Check if intent is balanced (all offers are balanced).

Link copied to clipboard
fun isExpired(currentTime: Long = System.currentTimeMillis()): Boolean

Check if intent has expired.

Link copied to clipboard

Check if intent is fully signed (all offers have signatures).

Link copied to clipboard
fun remainingTime(currentTime: Long = System.currentTimeMillis()): Long

Get remaining time until expiry.

Link copied to clipboard

Get total number of inputs across all offers.

Link copied to clipboard

Get total number of outputs across all offers.