DustToken

data class DustToken(val initialValue: BigInteger, val owner: String, val nonce: String, val sequenceNumber: Int, val creationTime: Long, val backingNight: String, val merkleTreeIndex: Long, val pendingUntil: Long? = null)

Represents a Dust UTXO (Unspent Transaction Output) in the wallet.

What is a Dust Token? Dust is Midnight's fee payment mechanism. When you register a Night UTXO for dust generation, it creates a Dust token that accumulates value over time. This accumulated dust is used to pay transaction fees.

Dust Generation:

Time →

├─ Creation (ctime): initialValue Specks

├─ Generation Phase: Value increases linearly
│ Rate: backing Night value × generation_decay_rate
│ Cap: backing Night value × night_dust_ratio

├─ Full Phase: Value stays at cap

├─ Decay Phase: Value decreases linearly (if backing Night is destroyed)

└─ Empty: Value reaches zero

Ledger Mapping: Mirrors the ledger's dust wallet UTXO state: the qualified dust output plus an optional "pending until" timestamp for when it becomes available.

Usage:

val token = DustToken(
initialValue = BigInteger("1000000"), // 1 Dust = 1,000,000 Specks
owner = dustPublicKey,
nonce = randomNonce,
sequenceNumber = 0,
creationTime = System.currentTimeMillis(),
backingNight = nightNonce,
merkleTreeIndex = 0,
pendingUntil = null // Available immediately
)

// Calculate current value
val currentValue = token.calculateValue(
now = System.currentTimeMillis(),
params = dustParams
)

Constructors

Link copied to clipboard
constructor(initialValue: BigInteger, owner: String, nonce: String, sequenceNumber: Int, creationTime: Long, backingNight: String, merkleTreeIndex: Long, pendingUntil: Long? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The Night UTXO that backs this dust generation

Link copied to clipboard

Unix timestamp in milliseconds when created

Link copied to clipboard

Initial dust value in Specks when created

Link copied to clipboard

Index in the Merkle tree

Link copied to clipboard

Unique nonce for this dust output

Link copied to clipboard

Dust public key that owns this token

Link copied to clipboard
val pendingUntil: Long? = null

If set, this token is pending until this time (milliseconds)

Link copied to clipboard

Sequence number for ordering

Functions

Link copied to clipboard

Calculates the commitment for this dust token.

Link copied to clipboard

Calculates the nullifier for this dust token.

Link copied to clipboard

Calculates the current value of this dust token at a specific time.

Link copied to clipboard

Checks if this dust token is available for spending.

Link copied to clipboard

Checks if this dust token is currently pending (not yet spendable).