pub fn transfer_spl_tokens_signed<'a>(
    source_info: &AccountInfo<'a>,
    destination_info: &AccountInfo<'a>,
    authority_info: &AccountInfo<'a>,
    authority_seeds: &[&[u8]],
    program_id: &Pubkey,
    amount: u64,
    spl_token_info: &AccountInfo<'a>,
) -> ProgramResult {
    let (authority_address, bump_seed) = Pubkey::find_program_address(authority_seeds, program_id);

    if authority_address != *authority_info.key {
        msg!(
                "Transfer SPL Token with Authority PDA: {:?} was requested while PDA: {:?} was expected",
                authority_info.key,
                authority_address
            );
        return Err(ProgramError::InvalidSeeds);
    }

    let transfer_instruction = spl_token::instruction::transfer(
        &spl_token::id(),
        source_info.key,
        destination_info.key,
        authority_info.key,
        &[],
        amount,
    )
    .unwrap();

    let mut signers_seeds = authority_seeds.to_vec();
    let bump = &[bump_seed];
    signers_seeds.push(bump);

    invoke_signed(
        &transfer_instruction,
        &[
            spl_token_info.clone(),
            authority_info.clone(),
            source_info.clone(),
            destination_info.clone(),
        ],
        &[&signers_seeds[..]],
    )?;

    Ok(())
}
/// Transfers SPL Tokens from a token account owned by the provided PDA authority with seeds
Transfers SPL Tokens from a token account owned by the provided PDA authority with seeds
Transfers SPL Tokens from a token account owned by the provided PDA authority with seeds
pub fn transfer_spl_tokens_signed<'a>(
    source_info: &AccountInfo<'a>,
    destination_info: &AccountInfo<'a>,
    authority_info: &AccountInfo<'a>,
    authority_seeds: &[&[u8]],
    program_id: &Pubkey,
    amount: u64,
    spl_token_info: &AccountInfo<'a>,
) -> ProgramResult {
    let (authority_address, bump_seed) = Pubkey::find_program_address(authority_seeds, program_id);
    if authority_address != *authority_info.key {
        msg!(
                "Transfer SPL Token with Authority PDA: {:?} was requested while PDA: {:?} was expected",
                authority_info.key,
                authority_address
            );
        return Err(ProgramError::InvalidSeeds);
    }
    let transfer_instruction = spl_token::instruction::transfer(
        &spl_token::id(),
        source_info.key,
        destination_info.key,
        authority_info.key,
        &[],
        amount,
    )
    .unwrap();
    let mut signers_seeds = authority_seeds.to_vec();
    let bump = &[bump_seed];
    signers_seeds.push(bump);
    invoke_signed(
        &transfer_instruction,
        &[
            spl_token_info.clone(),
            authority_info.clone(),
            source_info.clone(),
            destination_info.clone(),
        ],
        &[&signers_seeds[..]],
    )?;
    Ok(())
}
pub fn transfer_spl_tokens_signed < ' a > ( source_info : & AccountInfo < ' a > , destination_info : & AccountInfo < ' a > , authority_info : & AccountInfo < ' a > , authority_seeds : & [ & [ u8 ] ] , program_id : & Pubkey , amount : u64 , spl_token_info : & AccountInfo < ' a > , ) -> ProgramResult { let ( authority_address , bump_seed ) = Pubkey :: find_program_address ( authority_seeds , program_id ) ; if authority_address != * authority_info . key { msg ! ( " " authority_info key authority_address ) ; return Err ( ProgramError :: InvalidSeeds ) ; } let transfer_instruction = spl_token :: instruction :: transfer ( & spl_token :: id ( ) , source_info . key , destination_info . key , authority_info . key , & [ ] , amount , ) . unwrap ( ) ; let mut signers_seeds = authority_seeds . to_vec ( ) ; let bump = & [ bump_seed ] ; signers_seeds . push ( bump ) ; invoke_signed ( & transfer_instruction , & [ spl_token_info . clone ( ) , authority_info . clone ( ) , source_info . clone ( ) , destination_info . clone ( ) , ] , & [ & signers_seeds [ .. ] ] , ) ? ; Ok ( ( ) ) }
Transfers SPL Tokens from a token account owned by the provided PDA authority with seeds
Transfers SPL Tokens from a token account owned by the provided PDA authority with seeds
source_info
&AccountInfo<'a>
destination_info
&AccountInfo<'a>
authority_info
&AccountInfo<'a>
authority_seeds
&[&[u8]]
program_id
&Pubkey
amount
u64
spl_token_info
&AccountInfo<'a>
source_info
&AccountInfo<'a>
destination_info
&AccountInfo<'a>
authority_info
&AccountInfo<'a>
authority_seeds
&[&[u8]]
program_id
&Pubkey
amount
u64
spl_token_info
&AccountInfo<'a>