mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Remove potentially-failing unchecked arithmetic operations for ones which error
In response to 9.13.3. Requires a bump to Rust 1.82 to take advantage of `Option::is_none_or`.
This commit is contained in:
@@ -305,12 +305,13 @@ impl SignableTransaction {
|
||||
.payments
|
||||
.iter()
|
||||
.filter_map(|payment| match payment {
|
||||
InternalPayment::Payment(_, amount) => Some(amount),
|
||||
InternalPayment::Payment(_, amount) => Some(*amount),
|
||||
InternalPayment::Change(_) => None,
|
||||
})
|
||||
.sum::<u64>();
|
||||
.try_fold(0, u64::checked_add);
|
||||
let payments_amount = payments_amount.ok_or(SendError::TooManyOutputs)?;
|
||||
let (weight, necessary_fee) = self.weight_and_necessary_fee();
|
||||
if in_amount < (payments_amount + necessary_fee) {
|
||||
if payments_amount.checked_add(necessary_fee).is_none_or(|total_out| in_amount < total_out) {
|
||||
Err(SendError::NotEnoughFunds {
|
||||
inputs: in_amount,
|
||||
outputs: payments_amount,
|
||||
|
||||
Reference in New Issue
Block a user