Bitcoin Core 32.99.0
P2P Digital Currency
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Friends | List of all members
CFeeRate Class Reference

Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac. More...

#include <feerate.h>

Collaboration diagram for CFeeRate:
[legend]

Public Member Functions

 CFeeRate ()=default
 Fee rate of 0 satoshis per 0 vB.
 
template<std::integral I>
constexpr CFeeRate (const I m_feerate_kvb)
 
 CFeeRate (const CAmount &nFeePaid, int32_t virtual_bytes)
 Construct a fee rate from a fee in satoshis and a vsize in vB.
 
 CFeeRate (const FeePerVSize &feerate)
 Construct from a fee rate expressed as FeePerVSize.
 
CAmount GetFee (int32_t virtual_bytes) const
 Return the fee in satoshis for the given vsize in vbytes. (Rounds up)
 
FeePerVSize GetFeePerVSize () const
 
CAmount GetFeePerK () const
 Return the fee in satoshis for a vsize of 1000 vbytes. (Rounds down)
 
CFeeRate & operator+= (const CFeeRate &a)
 
std::string ToString (FeeRateFormat fee_rate_format=FeeRateFormat::BTC_KVB) const
 
 SERIALIZE_METHODS (CFeeRate, obj)
 

Private Attributes

FeePerVSize m_feerate
 Fee rate in sats/vB (satoshis per N virtualbytes)
 

Friends

std::strong_ordering operator<=> (const CFeeRate &a, const CFeeRate &b) noexcept
 
bool operator== (const CFeeRate &a, const CFeeRate &b) noexcept
 
CFeeRate operator* (const CFeeRate &f, int a)
 
CFeeRate operator* (int a, const CFeeRate &f)
 

Detailed Description

Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.

Definition at line 31 of file feerate.h.

Constructor & Destructor Documentation

◆ CFeeRate() [1/4]

CFeeRate::CFeeRate ( )
default

Fee rate of 0 satoshis per 0 vB.

◆ CFeeRate() [2/4]

template<std::integral I>
constexpr CFeeRate::CFeeRate ( const I  m_feerate_kvb)
inlineexplicitconstexpr

Definition at line 41 of file feerate.h.

◆ CFeeRate() [3/4]

CFeeRate::CFeeRate ( const CAmount &  nFeePaid,
int32_t  virtual_bytes 
)

Construct a fee rate from a fee in satoshis and a vsize in vB.

Passing any virtual_bytes less than or equal to 0 will result in 0 fee rate per 0 size.

Definition at line 12 of file feerate.cpp.

Here is the call graph for this function:

◆ CFeeRate() [4/4]

CFeeRate::CFeeRate ( const FeePerVSize &  feerate)
inlineexplicit

Construct from a fee rate expressed as FeePerVSize.

Lossless: CFeeRate is internally a FeePerVSize, so the exact fee/vsize fraction is preserved. A feerate whose size is less than or equal to 0 results in 0 fee rate per 0 size.

Definition at line 57 of file feerate.h.

Member Function Documentation

◆ GetFee()

CAmount CFeeRate::GetFee ( int32_t  virtual_bytes) const

Return the fee in satoshis for the given vsize in vbytes. (Rounds up)

Definition at line 27 of file feerate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFeePerK()

CAmount CFeeRate::GetFeePerK ( ) const

Return the fee in satoshis for a vsize of 1000 vbytes. (Rounds down)

Definition at line 21 of file feerate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFeePerVSize()

FeePerVSize CFeeRate::GetFeePerVSize ( ) const
inline

Definition at line 62 of file feerate.h.

◆ operator+=()

CFeeRate & CFeeRate::operator+= ( const CFeeRate &  a)
inline

Definition at line 75 of file feerate.h.

Here is the call graph for this function:

◆ SERIALIZE_METHODS()

CFeeRate::SERIALIZE_METHODS ( CFeeRate  ,
obj   
)
inline

Definition at line 83 of file feerate.h.

Here is the call graph for this function:

◆ ToString()

std::string CFeeRate::ToString ( FeeRateFormat  fee_rate_format = FeeRateFormat::BTC_KVB) const

Definition at line 34 of file feerate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator* [1/2]

CFeeRate operator* ( const CFeeRate &  f,
int  a 
)
friend

Definition at line 80 of file feerate.h.

◆ operator* [2/2]

CFeeRate operator* ( int  a,
const CFeeRate &  f 
)
friend

Definition at line 81 of file feerate.h.

◆ operator<=>

std::strong_ordering operator<=> ( const CFeeRate &  a,
const CFeeRate &  b 
)
friend

Definition at line 67 of file feerate.h.

◆ operator==

bool operator== ( const CFeeRate &  a,
const CFeeRate &  b 
)
friend

Definition at line 71 of file feerate.h.

Member Data Documentation

◆ m_feerate

FeePerVSize CFeeRate::m_feerate
private

Fee rate in sats/vB (satoshis per N virtualbytes)

Definition at line 35 of file feerate.h.


The documentation for this class was generated from the following files: