14 if (virtual_bytes > 0) {
23 Assume(virtual_bytes >= 0);
33 const auto format_feerate = [](
const CAmount fee_rate,
const CAmount divisor,
const int decimals,
const std::string& currency_unit,
const std::string& size_unit) {
35 const char*
sign{fee_rate < 0 ?
"-" :
""};
36 const CAmount quotient{std::abs(fee_rate / divisor)};
37 const CAmount remainder{std::abs(fee_rate % divisor)};
38 return strprintf(
"%s%d.%0*d %s/%s",
sign, quotient, decimals, remainder, currency_unit, size_unit);
40 switch (fee_rate_format) {
int64_t CAmount
Amount in satoshis (Can be negative)
constexpr CAmount COIN
The amount of satoshis in one BTC.
#define Assert(val)
Identity function.
#define Assume(val)
Assume is the identity function.
std::string ToString(FeeRateFormat fee_rate_format=FeeRateFormat::BTC_KVB) const
CFeeRate()=default
Fee rate of 0 satoshis per 0 vB.
FeePerVSize m_feerate
Fee rate in sats/vB (satoshis per N virtualbytes)
CAmount GetFeePerK() const
Return the fee in satoshis for a vsize of 1000 vbytes.
CAmount GetFee(int32_t virtual_bytes) const
Return the fee in satoshis for the given vsize in vbytes.
FeePerUnit< VSizeTag > FeePerVSize
const std::string CURRENCY_ATOM
@ BTC_KVB
Use BTC/kvB fee rate unit.
@ SAT_VB
Use sat/vB fee rate unit.
const std::string CURRENCY_UNIT
static int sign(const secp256k1_context *ctx, struct signer_secrets *signer_secrets, struct signer *signer, const secp256k1_musig_keyagg_cache *cache, const unsigned char *msg32, unsigned char *sig64)
int64_t EvaluateFeeUp(int32_t at_size) const noexcept
Compute the fee for a given size at_size using this object's feerate, rounding up.
bool IsEmpty() const noexcept
Check if this is empty (size and fee are 0).