checked_sub_lamports (#16932)

This commit is contained in:
Jeff Washington (jwash) 2021-04-30 09:56:34 -05:00 committed by GitHub
parent e0ffcfd53c
commit c4943f3cb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -17,7 +17,7 @@ use dashmap::{
use log::*;
use rand::{thread_rng, Rng};
use solana_sdk::{
account::{Account, AccountSharedData, ReadableAccount},
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
account_utils::StateMut,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
clock::{Slot, INITIAL_RENT_EPOCH},
@ -287,7 +287,9 @@ impl Accounts {
error_counters.insufficient_funds += 1;
Err(TransactionError::InsufficientFundsForFee)
} else {
accounts[payer_index].lamports -= fee;
accounts[payer_index]
.checked_sub_lamports(fee)
.map_err(|_| TransactionError::InsufficientFundsForFee)?;
let message = tx.message();
let loaders = message