Trait switchboard_solana::prelude::Lamports
pub trait Lamports<'info>: AsRef<AccountInfo<'info>> {
// Provided methods
fn get_lamports(&self) -> u64 { ... }
fn add_lamports(&self, amount: u64) -> Result<&Self, Error> { ... }
fn sub_lamports(&self, amount: u64) -> Result<&Self, Error> { ... }
}
Expand description
Lamports related utility methods for accounts.
Provided Methods§
fn get_lamports(&self) -> u64
fn get_lamports(&self) -> u64
Get the lamports of the account.
fn add_lamports(&self, amount: u64) -> Result<&Self, Error>
fn add_lamports(&self, amount: u64) -> Result<&Self, Error>
Add lamports to the account.
This method is useful for transferring 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.
fn sub_lamports(&self, amount: u64) -> Result<&Self, Error>
fn sub_lamports(&self, amount: u64) -> Result<&Self, Error>
Subtract lamports from the account.
This method is useful for transferring 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.