Skip to main content

compute_shielded_unshield_fee

Function compute_shielded_unshield_fee 

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

Computes the Unshield fee (in credits): compute_minimum_shielded_fee PLUS the flat storage cost of the single AddBalanceToAddress write an Unshield performs.

An Unshield additionally credits the net (unshielding_amount − fee) to the output platform address via AddBalanceToAddress, a real, GroveDB-metered write (≈6.24M credits, FLAT regardless of action count) that compute_minimum_shielded_fee does NOT price. This function adds that address cost as a flat SHIELDED_UNSHIELD_ADDRESS_STORAGE_BYTES-byte storage component (priced at the same per-byte storage rate the per-action note storage uses).

Used ONLY by Unshield: its SDK builder, the unshield 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, ShieldedWithdrawal, and the entry transitions keep using compute_minimum_shielded_fee / compute_shielded_withdrawal_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)