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)Content copied to clipboard
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
)Content copied to clipboard
Constructors
Link copied to clipboard
constructor(feeAmount: BigInteger, oldNullifier: String, newCommitment: String, proof: String? = null)