(account: &AccountInfo, recipient: &AccountInfo)
| 9 | |
| 10 | #[inline(always)] |
| 11 | pub fn close_program_account(account: &AccountInfo, recipient: &AccountInfo) -> ProgramResult { |
| 12 | // transfer lamports from the account to the destination account. |
| 13 | let mut destination_lamports = recipient.try_borrow_mut_lamports()?; |
| 14 | let mut source_lamports = account.try_borrow_mut_lamports()?; |
| 15 | |
| 16 | *destination_lamports = (*destination_lamports) |
| 17 | .checked_add(*source_lamports) |
| 18 | .unwrap(); |
| 19 | *source_lamports = 0; |
| 20 | |
| 21 | // realloc the account data size to 0 bytes and re-assign ownership of |
| 22 | // the account to the system program |
| 23 | account.realloc(0, false)?; |
| 24 | account.assign(&system_program::ID); |
| 25 | |
| 26 | Ok(()) |
| 27 | } |
| 28 | |
| 29 | #[allow(clippy::manual_try_fold)] |
| 30 | #[inline(always)] |
no outgoing calls
no test coverage detected