Skip to main content

build_shielded_withdrawal_transition

Function build_shielded_withdrawal_transition 

Source
pub fn build_shielded_withdrawal_transition<P: OrchardProver>(
    spends: Vec<SpendableNote>,
    withdrawal_amount: u64,
    output_script: CoreScript,
    core_fee_per_byte: u32,
    pooling: Pooling,
    change_address: &OrchardAddress,
    fvk: &FullViewingKey,
    ask: &SpendAuthorizingKey,
    anchor: Anchor,
    prover: &P,
    memo: [u8; 36],
    platform_version: &PlatformVersion,
) -> Result<(StateTransition, Credits), ProtocolError>
Expand description

Builds a ShieldedWithdrawal state transition (shielded pool -> core L1 address).

Spends existing notes and withdraws value to a core chain script output. The shielded fee is deducted from the spent notes. Any remaining value is returned to the shielded change_address; the change note is encrypted with the sender’s External-scope OVK (derived from fvk) so the wallet can recover it — including the structured memo — via OVK recovery.

§Parameters

  • spends - Notes to spend with their Merkle paths
  • withdrawal_amount - Amount to withdraw to the core chain
  • output_script - Core chain script to receive the funds
  • core_fee_per_byte - Core chain fee rate
  • pooling - Withdrawal pooling strategy
  • change_address - Orchard address for change output
  • fvk - Full viewing key for spend authorization
  • ask - Spend authorizing key for RedPallas signatures
  • anchor - Sinsemilla root of the note commitment tree (Orchard Anchor)
  • prover - Orchard prover (holds the Halo 2 proving key)
  • memo - 36-byte structured memo for the change output (4-byte type tag + 32-byte payload)
  • platform_version - Protocol version

The fee is not a parameter: consensus always charges exactly compute_shielded_withdrawal_fee (the base shielded minimum fee PLUS the flat storage cost of the Core withdrawal document this transition inserts) and ignores any surplus. Returns the built transition together with the fee (in credits) that was applied.