diff --git a/units/src/fee.rs b/units/src/fee.rs index 144ad0fd8..76aa55309 100644 --- a/units/src/fee.rs +++ b/units/src/fee.rs @@ -181,20 +181,6 @@ crate::internal_macros::impl_op_for_references! { } } -impl Weight { - /// Checked fee rate multiplication. - /// - /// Computes the absolute fee amount for a given [`FeeRate`] at this weight. When the resulting - /// fee is a non-integer amount, the amount is rounded up, ensuring that the transaction fee is - /// enough instead of falling short if rounded down. - /// - /// Returns [`None`] if overflow occurred. - #[must_use] - pub const fn checked_mul_by_fee_rate(self, fee_rate: FeeRate) -> Option { - fee_rate.checked_mul_by_weight(self) - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/units/src/weight.rs b/units/src/weight.rs index 31da7274c..5bf700471 100644 --- a/units/src/weight.rs +++ b/units/src/weight.rs @@ -10,7 +10,7 @@ use arbitrary::{Arbitrary, Unstructured}; #[cfg(feature = "serde")] use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use crate::CheckedSum; +use crate::{Amount, CheckedSum, FeeRate}; /// The factor that non-witness serialization data is multiplied by during weight calculation. pub const WITNESS_SCALE_FACTOR: usize = 4; @@ -162,6 +162,18 @@ impl Weight { None => None, } } + + /// Checked fee rate multiplication. + /// + /// Computes the absolute fee amount for a given [`FeeRate`] at this weight. When the resulting + /// fee is a non-integer amount, the amount is rounded up, ensuring that the transaction fee is + /// enough instead of falling short if rounded down. + /// + /// Returns [`None`] if overflow occurred. + #[must_use] + pub const fn checked_mul_by_fee_rate(self, fee_rate: FeeRate) -> Option { + fee_rate.checked_mul_by_weight(self) + } } /// Alternative will display the unit.