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

Get the lamports of the account.

fn add_lamports(&self, amount: u64) -> Result<&Self, Error>

Add lamports to the account.

This method is useful for transfering lamports from a PDA.

§Requirements
  1. The account must be marked mut.
  2. The total lamports before the transaction must equal to total lamports after the transaction.
  3. 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>

Subtract lamports from the account.

This method is useful for transfering lamports from a PDA.

§Requirements
  1. The account must be owned by the executing program.
  2. The account must be marked mut.
  3. The total lamports before the transaction must equal to total lamports after the transaction.
  4. 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.

Implementors§

§

impl<'info, T> Lamports<'info> for T
where T: AsRef<AccountInfo<'info>>,