DustSpend

data class DustSpend(val feeAmount: BigInteger, val oldNullifier: String, val newCommitment: String, val proof: String? = null)

Represents spending a Dust token to pay transaction fees.

What is a Dust Spend? When you create a transaction, you need to pay fees. To pay fees, you "spend" a Dust token by providing:

  • The old dust token's nullifier (to prevent double-spending)

  • A commitment to the new dust token (the "change")

  • A zero-knowledge proof that the spend is valid

  • The fee amount

Dust Spend Flow:

Old Dust Token (e.g., 5 Dust)

Spend 2 Dust for fees

├─ Fee: 2 Dust (destroyed, goes to validators)
└─ Change: 3 Dust (new dust token, back to you)

Zero-Knowledge Proof: The proof ensures:

  • You own the old dust token (know the secret key)

  • The old nullifier is correctly computed

  • The new commitment is correctly computed

  • The fee amount is valid (old_value - new_value = fee)

  • You're not creating dust out of thin air

Ledger Mapping: Mirrors the ledger's DustSpend: fee amount, spent-token nullifier, change commitment, and ZK proof.

Usage:

// Create a dust spend
val spend = wallet.createDustSpend(
oldToken = myDustToken,
feeAmount = BigInteger.valueOf(2_000_000), // 2 Dust
secretKey = myDustSecretKey
)

// Include in transaction
val tx = UnshieldedTransaction(
inputs = listOf(...),
outputs = listOf(...),
dustSpend = spend, // Pay fees with this
ttl = System.currentTimeMillis() + 60_000
)

Constructors

Link copied to clipboard
constructor(feeAmount: BigInteger, oldNullifier: String, newCommitment: String, proof: String? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Fee paid in Specks (old_value - new_value)

Link copied to clipboard

Commitment to the new (change) dust token

Link copied to clipboard

Nullifier of the dust token being spent

Link copied to clipboard
val proof: String? = null

Zero-knowledge proof (hex-encoded, optional for now)

Functions

Link copied to clipboard

Checks if this dust spend has a proof attached.

Link copied to clipboard

Validates that this dust spend is well-formed.

Link copied to clipboard

Converts this DustSpend to a serializable format for transactions.