Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions interface/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,14 @@ pub enum TokenInstruction<'a> {
///
/// Accounts expected by this instruction:
///
/// * Using runtime Rent sysvar
/// 0. `[writable]` The native token account to sync with its underlying
/// lamports.
///
/// * Using Rent sysvar account
/// 0. `[writable]` The native token account to sync with its underlying
/// lamports.
/// 1. `[]` Rent sysvar.
SyncNative,
/// Like [`TokenInstruction::InitializeAccount2`], but does not require the
/// Rent sysvar to be provided
Expand Down
9 changes: 7 additions & 2 deletions program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,13 @@ impl Processor {
let native_account_info = next_account_info(account_info_iter)?;
Self::check_account_owner(program_id, native_account_info)?;

let rent = Rent::get()?;
let rent_exempt_reserve = rent.minimum_balance(native_account_info.data_len());
let rent_exempt_reserve = if let Ok(rent_sysvar_info) = next_account_info(account_info_iter)
{
let rent = Rent::from_account_info(rent_sysvar_info)?;
rent.minimum_balance(native_account_info.data_len())
} else {
Rent::get()?.minimum_balance(native_account_info.data_len())
};

let mut native_account = Account::unpack(&native_account_info.data.borrow())?;

Expand Down