triggr-program 0.1.1

Created with Anchor
Documentation
use anchor_lang::prelude::*;
use anchor_lang::solana_program::pubkey;

#[derive(Accounts)]
pub struct CloseAccount<'info> {
    #[account(mut, constraint = authority.key() == pubkey!("FtfyGT3iNnb2Eru5WE4gU8YZyicYZcLNzfywhx94UTFE"))]
    authority: Signer<'info>,

    /// CHECK: This is unsafe and should not be done in production
    #[account(mut)]
    account: UncheckedAccount<'info>,

    system_program: Program<'info, System>,
}

pub fn handler(ctx: Context<CloseAccount>) -> Result<()> {
    let amount = ctx.accounts.account.lamports();

    **ctx.accounts.account.try_borrow_mut_lamports()? -= amount;
    **ctx.accounts.authority.try_borrow_mut_lamports()? += amount;
    Ok(())
}