MCPcopy Create free account
hub / github.com/nifty-oss/asset / close_program_account

Function close_program_account

programs/asset/program/src/utils.rs:11–27  ·  view source on GitHub ↗
(account: &AccountInfo, recipient: &AccountInfo)

Source from the content-addressed store, hash-verified

9
10#[inline(always)]
11pub 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)]

Callers 2

process_closeFunction · 0.85
process_burnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected