anchor icon indicating copy to clipboard operation
anchor copied to clipboard

Close the accountLoader issue!

Open dev-tom-0108 opened this issue 3 years ago • 1 comments

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?

dev-tom-0108 avatar Aug 22 '22 12:08 dev-tom-0108

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.

Henry-E avatar Aug 29 '22 20:08 Henry-E