Skip to main content

safe_close

Function safe_close 

Source
pub fn safe_close(
    account: &AccountView,
    destination: &AccountView,
) -> ProgramResult
Expand description

Close account, sending all its lamports to destination.

Steps:

  1. Overflow-checked addition of lamports into destination.
  2. Zero account lamports.
  3. close_unchecked(): zeros data and clears the owner field.

Both accounts must be writable - caller is responsible for that check.

ยงSafety

Caller must guarantee no active borrows exist on account at call time.