|
@@ -172,18 +172,17 @@ pub fn process_transfer(
|
|
if source_account.is_native() {
|
|
if source_account.is_native() {
|
|
// SAFETY: single mutable borrow to `source_account_info` lamports.
|
|
// SAFETY: single mutable borrow to `source_account_info` lamports.
|
|
let source_lamports = unsafe { source_account_info.borrow_mut_lamports_unchecked() };
|
|
let source_lamports = unsafe { source_account_info.borrow_mut_lamports_unchecked() };
|
|
- *source_lamports = source_lamports
|
|
|
|
- .checked_sub(amount)
|
|
|
|
- .ok_or(TokenError::Overflow)?;
|
|
|
|
|
|
+ // Note: The amount of a source token account is already validated and the
|
|
|
|
+ // `lamports` on the account is always greater than `amount`.
|
|
|
|
+ *source_lamports -= amount;
|
|
|
|
|
|
// SAFETY: single mutable borrow to `destination_account_info` lamports; the
|
|
// SAFETY: single mutable borrow to `destination_account_info` lamports; the
|
|
// account is already validated to be different from
|
|
// account is already validated to be different from
|
|
// `source_account_info`.
|
|
// `source_account_info`.
|
|
let destination_lamports =
|
|
let destination_lamports =
|
|
unsafe { destination_account_info.borrow_mut_lamports_unchecked() };
|
|
unsafe { destination_account_info.borrow_mut_lamports_unchecked() };
|
|
- *destination_lamports = destination_lamports
|
|
|
|
- .checked_add(amount)
|
|
|
|
- .ok_or(TokenError::Overflow)?;
|
|
|
|
|
|
+ // Note: The total lamports supply is bound to `u64::MAX`.
|
|
|
|
+ *destination_lamports += amount;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|