36 lines
963 B
Rust
36 lines
963 B
Rust
use anchor_lang::prelude::*;
|
|
use anchor_lang::solana_program;
|
|
|
|
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
|
|
|
#[program]
|
|
pub mod arbitrary_cpi_insecure {
|
|
use super::*;
|
|
|
|
pub fn cpi(ctx: Context<Cpi>, amount: u64) -> ProgramResult {
|
|
solana_program::program::invoke(
|
|
&spl_token::instruction::transfer(
|
|
ctx.accounts.token_program.key,
|
|
ctx.accounts.source.key,
|
|
ctx.accounts.destination.key,
|
|
ctx.accounts.authority.key,
|
|
&[],
|
|
amount,
|
|
)?,
|
|
&[
|
|
ctx.accounts.source.clone(),
|
|
ctx.accounts.destination.clone(),
|
|
ctx.accounts.authority.clone(),
|
|
],
|
|
)
|
|
}
|
|
}
|
|
|
|
#[derive(Accounts)]
|
|
pub struct Cpi<'info> {
|
|
source: AccountInfo<'info>,
|
|
destination: AccountInfo<'info>,
|
|
authority: AccountInfo<'info>,
|
|
token_program: AccountInfo<'info>,
|
|
}
|