Skip to main content
Verifies that a PCZT matches the original transaction request before signing. Important security check when the PCZT was handled by a third party.

Signature

function verify_before_signing(
  pczt: WasmPczt,
  payments: WasmPayment[],
  expected_change: WasmExpectedTxOut[]
): void  // Throws on failure

Parameters

pczt
Pczt
required
The PCZT to verify
payments
Payment[]
required
Original payments (same as passed to propose_transaction)
expected_change
ExpectedTxOut[]
required
Expected change outputs

Example

// Get actual change from PCZT
const info = t2z.inspect_pczt(pczt.to_hex());
const paymentTotal = payments.reduce((sum, p) => sum + p.amount, 0n);
const changeAmount = BigInt(info.total_orchard_output) - paymentTotal;

// Build expected change
const expectedChange = changeAmount > 0n 
  ? [new t2z.WasmExpectedTxOut(changeAddress, changeAmount)]
  : [];

// Verify
t2z.verify_before_signing(pczt, payments, expectedChange);

When to Use

  • PCZT came from another system
  • Hardware wallet workflow
  • Multi-party transaction construction
May be skipped when you created the PCZT yourself.

See Also