Skip to main content

close_and_transfer

Function close_and_transfer 

Source
pub fn close_and_transfer(
    source: &AccountView,
    destination: &AccountView,
) -> ProgramResult
Expand description

Transfer all lamports from source to destination and zero the source.

This is the standard “close an account” pattern: move all SOL to the rent receiver and wipe the source account. Combines what would normally be 3 separate operations (read lamports, set source to 0, add to destination) into one safe call.