anchor
anchor copied to clipboard
Close the accountLoader issue!
I built the program to close the account loader! but I am not sure it works well.
let owner = &mut ctx.accounts.owner;
let origin_lamports: u64 = owner.lamports();
**owner.lamports.borrow_mut() = origin_lamports + ctx.accounts.personal_pool.as_ref().lamports();
**ctx.accounts.personal_pool.as_ref().lamports.borrow_mut() = 0;
Here! .as_ref() is right?
Please use the close constraint to close accounts, otherwise you are putting yourself at security risk.
Separately: Recommend asking on https://solana.stackexchange.com/ and closing this issue as this is not an issue with anchor itself but just general code writing.