Created
January 10, 2022 18:37
-
-
Save kayandra/1e277e749345c94611bb4be0ddb2b599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn transfer_from_account_we_own( | |
src: &mut AccountInfo, // we better own this account though | |
dst: &mut AccountInfo, | |
amount: u64, | |
) -> ProgramResult { | |
**src.try_borrow_mut_lamports()? = src | |
.lamports() | |
.checked_sub(amount) | |
.ok_or(ProgramError::InvalidArgument)?; | |
**dst.try_borrow_mut_lamports()? = dst | |
.lamports() | |
.checked_add(amount) | |
.ok_or(ProgramError::InvalidArgument)?; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment