pub struct FeeRate(/* private fields */);
alloc
only.Expand description
Represents fee rate.
This is an integer newtype representing fee rate in sat/kwu
. It provides protection against mixing
up the types as well as basic formatting features.
Implementations§
source§impl FeeRate
impl FeeRate
sourcepub const ZERO: FeeRate = _
pub const ZERO: FeeRate = _
0 sat/kwu.
Equivalent to MIN
, may better express intent in some contexts.
sourcepub const MIN: FeeRate = FeeRate::ZERO
pub const MIN: FeeRate = FeeRate::ZERO
Minimum possible value (0 sat/kwu).
Equivalent to ZERO
, may better express intent in some contexts.
sourcepub const BROADCAST_MIN: FeeRate = _
pub const BROADCAST_MIN: FeeRate = _
Minimum fee rate required to broadcast a transaction.
The value matches the default Bitcoin Core policy at the time of library release.
sourcepub const fn from_sat_per_kwu(sat_kwu: u64) -> Self
pub const fn from_sat_per_kwu(sat_kwu: u64) -> Self
Constructs FeeRate
from satoshis per 1000 weight units.
sourcepub fn from_sat_per_vb(sat_vb: u64) -> Option<Self>
pub fn from_sat_per_vb(sat_vb: u64) -> Option<Self>
sourcepub const fn from_sat_per_vb_unchecked(sat_vb: u64) -> Self
pub const fn from_sat_per_vb_unchecked(sat_vb: u64) -> Self
Constructs FeeRate
from satoshis per virtual bytes without overflow check.
sourcepub const fn to_sat_per_kwu(self) -> u64
pub const fn to_sat_per_kwu(self) -> u64
Returns raw fee rate.
Can be used instead of into()
to avoid inference issues.
sourcepub const fn to_sat_per_vb_floor(self) -> u64
pub const fn to_sat_per_vb_floor(self) -> u64
Converts to sat/vB rounding down.
sourcepub const fn to_sat_per_vb_ceil(self) -> u64
pub const fn to_sat_per_vb_ceil(self) -> u64
Converts to sat/vB rounding up.
sourcepub fn checked_mul(self, rhs: u64) -> Option<Self>
pub fn checked_mul(self, rhs: u64) -> Option<Self>
Checked multiplication.
Computes self * rhs
returning None
if overflow occurred.
sourcepub fn checked_div(self, rhs: u64) -> Option<Self>
pub fn checked_div(self, rhs: u64) -> Option<Self>
Checked division.
Computes self / rhs
returning None
if rhs == 0
.
sourcepub fn checked_mul_by_weight(self, rhs: Weight) -> Option<Amount>
pub fn checked_mul_by_weight(self, rhs: Weight) -> Option<Amount>
Checked weight multiplication.
Computes the absolute fee amount for a given Weight
at this fee rate.
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.
None
is returned if an overflow occurred.
sourcepub fn checked_add(self, rhs: u64) -> Option<Self>
pub fn checked_add(self, rhs: u64) -> Option<Self>
Checked addition.
Computes self + rhs
returning None
if overflow occured.
sourcepub fn checked_sub(self, rhs: u64) -> Option<Self>
pub fn checked_sub(self, rhs: u64) -> Option<Self>
Checked subtraction.
Computes self - rhs
returning None
if overflow occured.
Trait Implementations§
source§impl AddAssign<&FeeRate> for FeeRate
impl AddAssign<&FeeRate> for FeeRate
source§fn add_assign(&mut self, rhs: &FeeRate)
fn add_assign(&mut self, rhs: &FeeRate)
+=
operation. Read moresource§impl AddAssign for FeeRate
impl AddAssign for FeeRate
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moresource§impl<'a> Arbitrary<'a> for FeeRate
Available on crate feature arbitrary
only.
impl<'a> Arbitrary<'a> for FeeRate
arbitrary
only.source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self
from the given unstructured data. Read moresource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self
from the entirety of the given
unstructured data. Read moresource§impl<'de> Deserialize<'de> for FeeRate
impl<'de> Deserialize<'de> for FeeRate
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Mul<FeeRate> for Weight
impl Mul<FeeRate> for Weight
Computes the ceiling so that the fee computation is conservative.
source§impl Ord for FeeRate
impl Ord for FeeRate
source§impl PartialOrd for FeeRate
impl PartialOrd for FeeRate
source§impl SubAssign<&FeeRate> for FeeRate
impl SubAssign<&FeeRate> for FeeRate
source§fn sub_assign(&mut self, rhs: &FeeRate)
fn sub_assign(&mut self, rhs: &FeeRate)
-=
operation. Read moresource§impl SubAssign for FeeRate
impl SubAssign for FeeRate
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read moreimpl Copy for FeeRate
impl Eq for FeeRate
impl StructuralPartialEq for FeeRate
Auto Trait Implementations§
impl Freeze for FeeRate
impl RefUnwindSafe for FeeRate
impl Send for FeeRate
impl Sync for FeeRate
impl Unpin for FeeRate
impl UnwindSafe for FeeRate
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)