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§

source

fn get_lamports(&self) -> u64

Get the lamports of the account.

source

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

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.

source

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

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§

source§

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