Trait anchor_lang::Lamports
source · pub trait Lamports<'info>: AsRef<AccountInfo<'info>> {
// Provided methods
fn get_lamports(&self) -> u64 { ... }
fn add_lamports(&self, amount: u64) -> Result<&Self> { ... }
fn sub_lamports(&self, amount: u64) -> Result<&Self> { ... }
}
Expand description
Lamports related utility methods for accounts.
Provided Methods§
sourcefn get_lamports(&self) -> u64
fn get_lamports(&self) -> u64
Get the lamports of the account.
sourcefn add_lamports(&self, amount: u64) -> Result<&Self>
fn add_lamports(&self, amount: u64) -> Result<&Self>
Add lamports to the account.
This method is useful for transfering lamports from a PDA.
Requirements
- The account must be marked
mut
. - The total lamports before the transaction must equal to total lamports after the transaction.
lamports
field of the account info should not currently be borrowed.
See Lamports::sub_lamports
for subtracting lamports.
sourcefn sub_lamports(&self, amount: u64) -> Result<&Self>
fn sub_lamports(&self, amount: u64) -> Result<&Self>
Subtract lamports from the account.
This method is useful for transfering lamports from a PDA.
Requirements
- The account must be owned by the executing program.
- The account must be marked
mut
. - The total lamports before the transaction must equal to total lamports after the transaction.
lamports
field of the account info should not currently be borrowed.
See Lamports::add_lamports
for adding lamports.
Object Safety§
This trait is not object safe.