fn process_empty_account(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    proof_instruction_offset: i64,
) -> ProgramResult {
    let account_info_iter = &mut accounts.iter();
    let token_account_info = next_account_info(account_info_iter)?;
    let instructions_sysvar_info = next_account_info(account_info_iter)?;
    let authority_info = next_account_info(account_info_iter)?;
    let authority_info_data_len = authority_info.data_len();

    check_program_account(token_account_info.owner)?;
    let token_account_data = &mut token_account_info.data.borrow_mut();
    let mut token_account = StateWithExtensionsMut::<Account>::unpack(token_account_data)?;

    Processor::validate_owner(
        program_id,
        token_account_info.owner,
        authority_info,
        authority_info_data_len,
        account_info_iter.as_slice(),
    )?;

    let mut ct_token_account = token_account.get_extension_mut::<ConfidentialTransferAccount>()?;

    let previous_instruction =
        get_instruction_relative(proof_instruction_offset, instructions_sysvar_info)?;
    let proof_data = decode_proof_instruction::<CloseAccountData>(
        ProofInstruction::VerifyCloseAccount,
        &previous_instruction,
    )?;

    if ct_token_account.pending_balance != pod::ElGamalCiphertext::zeroed() {
        msg!("Pending balance is not zero");
        return Err(ProgramError::InvalidAccountData);
    }

    if ct_token_account.available_balance != proof_data.ciphertext {
        msg!("Available balance mismatch");
        return Err(ProgramError::InvalidInstructionData);
    }

    ct_token_account.approved()?;
    ct_token_account.available_balance = pod::ElGamalCiphertext::zeroed();
    ct_token_account.closable()?;

    Ok(())
}
/// Processes an [EmptyAccount] instruction.
Processes an [EmptyAccount] instruction.
Processes an [ EmptyAccount ] instruction .
fn process_empty_account(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    proof_instruction_offset: i64,
) -> ProgramResult {
    let account_info_iter = &mut accounts.iter();
    let token_account_info = next_account_info(account_info_iter)?;
    let instructions_sysvar_info = next_account_info(account_info_iter)?;
    let authority_info = next_account_info(account_info_iter)?;
    let authority_info_data_len = authority_info.data_len();
    check_program_account(token_account_info.owner)?;
    let token_account_data = &mut token_account_info.data.borrow_mut();
    let mut token_account = StateWithExtensionsMut::<Account>::unpack(token_account_data)?;
    Processor::validate_owner(
        program_id,
        token_account_info.owner,
        authority_info,
        authority_info_data_len,
        account_info_iter.as_slice(),
    )?;
    let mut ct_token_account = token_account.get_extension_mut::<ConfidentialTransferAccount>()?;
    let previous_instruction =
        get_instruction_relative(proof_instruction_offset, instructions_sysvar_info)?;
    let proof_data = decode_proof_instruction::<CloseAccountData>(
        ProofInstruction::VerifyCloseAccount,
        &previous_instruction,
    )?;
    if ct_token_account.pending_balance != pod::ElGamalCiphertext::zeroed() {
        msg!("Pending balance is not zero");
        return Err(ProgramError::InvalidAccountData);
    }
    if ct_token_account.available_balance != proof_data.ciphertext {
        msg!("Available balance mismatch");
        return Err(ProgramError::InvalidInstructionData);
    }
    ct_token_account.approved()?;
    ct_token_account.available_balance = pod::ElGamalCiphertext::zeroed();
    ct_token_account.closable()?;
    Ok(())
}
fn process_empty_account ( program_id : & Pubkey , accounts : & [ AccountInfo ] , proof_instruction_offset : i64 , ) -> ProgramResult { let account_info_iter = & mut accounts . iter ( ) ; let token_account_info = next_account_info ( account_info_iter ) ? ; let instructions_sysvar_info = next_account_info ( account_info_iter ) ? ; let authority_info = next_account_info ( account_info_iter ) ? ; let authority_info_data_len = authority_info . data_len ( ) ; check_program_account ( token_account_info . owner ) ? ; let token_account_data = & mut token_account_info . data . borrow_mut ( ) ; let mut token_account = StateWithExtensionsMut :: < Account > :: unpack ( token_account_data ) ? ; Processor :: validate_owner ( program_id , token_account_info . owner , authority_info , authority_info_data_len , account_info_iter . as_slice ( ) , ) ? ; let mut ct_token_account = token_account . get_extension_mut :: < ConfidentialTransferAccount > ( ) ? ; let previous_instruction = get_instruction_relative ( proof_instruction_offset , instructions_sysvar_info ) ? ; let proof_data = decode_proof_instruction :: < CloseAccountData > ( ProofInstruction :: VerifyCloseAccount , & previous_instruction , ) ? ; if ct_token_account . pending_balance != pod :: ElGamalCiphertext :: zeroed ( ) { msg ! ( " " ) ; return Err ( ProgramError :: InvalidAccountData ) ; } if ct_token_account . available_balance != proof_data . ciphertext { msg ! ( " " ) ; return Err ( ProgramError :: InvalidInstructionData ) ; } ct_token_account . approved ( ) ? ; ct_token_account . available_balance = pod :: ElGamalCiphertext :: zeroed ( ) ; ct_token_account . closable ( ) ? ; Ok ( ( ) ) }
Processes an [EmptyAccount] instruction.
Processes an [ EmptyAccount ] instruction .
program_id
&Pubkey
accounts
&[AccountInfo]
proof_instruction_offset
i64
program_id
&Pubkey
accounts
&[AccountInfo]
proof_instruction_offset
i64