package main
import (
"fmt"
"log"
t2z "github.com/d4mr/t2z/sdks/go/t2z_uniffi"
)
func main() {
// 1. Create transparent input
input := t2z.UniffiTransparentInput{
Pubkey: "03abc123...", // 33-byte compressed pubkey (hex)
PrevoutTxid: "ce15f716...", // 32-byte txid (little-endian hex)
PrevoutIndex: 0,
Value: 1_000_000, // 0.01 ZEC in zatoshis
ScriptPubkey: "76a914...88ac", // P2PKH script (hex)
Sequence: nil,
}
// 2. Create payment
payment := t2z.UniffiPayment{
Address: "u1recipient...", // Unified address with Orchard
Amount: 900_000,
Memo: nil,
Label: nil,
}
request := t2z.UniffiTransactionRequest{
Payments: []t2z.UniffiPayment{payment},
}
// 3. Propose transaction
changeAddr := "u1change..."
pczt, err := t2z.ProposeTransaction(
[]t2z.UniffiTransparentInput{input},
request,
&changeAddr,
"testnet",
3720100,
)
if err != nil {
log.Fatal(err)
}
// 4. Sign transparent inputs (external signing)
sighash, err := t2z.GetSighash(pczt, 0)
if err != nil {
log.Fatal(err)
}
// Sign the sighash with your key (ECDSA secp256k1)
signature := sign(sighash, privateKey) // Your signing logic
pczt, err = t2z.AppendSignature(pczt, 0, pubkeyHex, signature)
if err != nil {
log.Fatal(err)
}
// 5. Generate Orchard proofs (~10 seconds first time)
pczt, err = t2z.ProveTransaction(pczt)
if err != nil {
log.Fatal(err)
}
// 6. Finalize and get raw transaction
txHex, err := t2z.FinalizeAndExtractHex(pczt)
if err != nil {
log.Fatal(err)
}
fmt.Println("Transaction ready:", txHex)
}