Skip to main content

compute_shielded_withdrawal_fee

Function compute_shielded_withdrawal_fee 

Source
pub fn compute_shielded_withdrawal_fee(
    num_actions: usize,
    platform_version: &PlatformVersion,
) -> Result<Credits, ProtocolError>
Expand description

Computes the ShieldedWithdrawal fee (in credits): compute_minimum_shielded_fee PLUS the flat storage cost of the Core withdrawal document a ShieldedWithdrawal inserts.

A ShieldedWithdrawal additionally writes a Core withdrawal document into the withdrawals contract (the document plus its index entries — AddWithdrawalDocument), a real, GroveDB-metered insert (≈110M credits, FLAT regardless of action count) that compute_minimum_shielded_fee does NOT price. This function adds that document cost as a flat SHIELDED_WITHDRAWAL_DOCUMENT_STORAGE_BYTES-byte storage component (priced at the same per-byte storage rate the per-action note storage uses).

Used ONLY by ShieldedWithdrawal: its SDK builder, the withdrawal transformer (for the fee carved from the pool), and the consensus gate validate_minimum_shielded_fee all call this function, so the carved fee and the validation threshold can never drift. ShieldedTransfer keeps using compute_minimum_shielded_fee, Unshield uses compute_shielded_unshield_fee, and the entry transitions use compute_minimum_shielded_fee / compute_shielded_verification_fee.

Dispatches on the SAME version key (dpp.methods.compute_minimum_shielded_fee) as compute_minimum_shielded_fee so the two formulas evolve together across protocol versions.

§Parameters

  • num_actions — number of Orchard actions in the bundle
  • platform_version — protocol version (determines the formula version and fee constants)