import uniffi.t2z_uniffi.*
fun main() {
// 1. Create transparent input
val input = UniffiTransparentInput(
pubkey = "03abc123...", // 33-byte compressed pubkey (hex)
prevoutTxid = "ce15f716...", // 32-byte txid (little-endian hex)
prevoutIndex = 0u,
value = 1_000_000uL, // 0.01 ZEC in zatoshis
scriptPubkey = "76a914...88ac", // P2PKH script (hex)
sequence = null
)
// 2. Create payment
val payment = UniffiPayment(
address = "u1recipient...", // Unified address with Orchard
amount = 900_000uL,
memo = null,
label = null
)
val request = UniffiTransactionRequest(
payments = listOf(payment)
)
// 3. Propose transaction
var pczt = proposeTransaction(
inputsToSpend = listOf(input),
transactionRequest = request,
changeAddress = "u1change...",
network = "testnet",
expiryHeight = 3720100u
)
// 4. Sign transparent inputs (external signing)
val sighash = getSighash(pczt, 0u)
// Sign the sighash with your key (ECDSA secp256k1)
val signature = sign(sighash, privateKey) // Your signing logic
pczt = appendSignature(pczt, 0u, pubkeyHex, signature)
// 5. Generate Orchard proofs (~10 seconds first time)
pczt = proveTransaction(pczt)
// 6. Finalize and get raw transaction
val txHex = finalizeAndExtractHex(pczt)
println("Transaction ready: $txHex")
}