Bitcoin Core 31.99.0
P2P Digital Currency
fees.h
Go to the documentation of this file.
1// Copyright (c) The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_UTIL_FEES_H
6#define BITCOIN_UTIL_FEES_H
7
8#include <attributes.h>
9#include <util/expected.h>
10#include <util/feefrac.h>
11
12#include <string>
13#include <string_view>
14#include <utility>
15
16/* Used to determine type of fee estimation requested */
17enum class FeeEstimateMode {
18 UNSET,
21};
22
23/* Used to determine the reason a wallet selected a transaction fee rate */
24enum class FeeReason {
30};
31
37 NONE,
39 MEMPOOL_POLICY,
40};
41
58 auto operator<=>(const FeeRateEstimation& other) const
59 {
60 return ByRatio{feerate} <=> ByRatio{other.feerate};
61 }
62};
63
71 std::string reason;
72};
73
78inline util::Unexpected<FeeRateEstimationError> EstimationError(FeeRateEstimatorType estimator, int returned_target, std::string error)
79{
80 return util::Unexpected{FeeRateEstimationError{{estimator, FeePerVSize{0, 0}, returned_target}, std::move(error)}};
81}
82
88{
89 return result ? *result : result.error().estimation;
90}
91
92std::string_view FeeRateEstimatorTypeToString(FeeRateEstimatorType feerate_estimator_type);
93FeeRateEstimatorType FeeRateEstimatorTypeFromString(std::string_view feerate_estimator_type);
94
95#endif // BITCOIN_UTIL_FEES_H
#define LIFETIMEBOUND
Definition: attributes.h:16
Wrapper around FeeFrac & derived types, which adds a feerate-based ordering which treats equal-feerat...
Definition: feefrac.h:219
The util::Expected class provides a standard way for low-level functions to return either error value...
Definition: expected.h:44
The util::Unexpected class represents an unexpected value stored in util::Expected.
Definition: expected.h:21
A failed fee rate estimation, carrying the zero-value estimation that identifies the estimator and ta...
Definition: fees.h:69
std::string reason
Definition: fees.h:71
FeeRateEstimation estimation
Definition: fees.h:70
A successful fee rate estimate returned by a fee rate estimator.
Definition: fees.h:46
FeeRateEstimatorType feerate_estimator
This identifies which fee rate estimator is providing this feerate estimate.
Definition: fees.h:48
auto operator<=>(const FeeRateEstimation &other) const
Compare two FeeRateEstimation objects based on fee rate.
Definition: fees.h:58
FeePerVSize feerate
Fee rate sufficient for confirmation within target.
Definition: fees.h:50
int returned_target
The returned confirmation target for the estimate.
Definition: fees.h:52
util::Unexpected< FeeRateEstimationError > EstimationError(FeeRateEstimatorType estimator, int returned_target, std::string error)
Build a fee rate estimation error result: a zero-value estimation identifying the estimator and targe...
Definition: fees.h:78
std::string_view FeeRateEstimatorTypeToString(FeeRateEstimatorType feerate_estimator_type)
Definition: fees.cpp:12
FeeRateEstimatorType FeeRateEstimatorTypeFromString(std::string_view feerate_estimator_type)
Definition: fees.cpp:26
FeeRateEstimatorType
Identifier for fee rate estimator.
Definition: fees.h:36
const FeeRateEstimation & FeeRateEstimationRef(const util::Expected< FeeRateEstimation, FeeRateEstimationError > &result LIFETIMEBOUND)
Return the estimation carried by a fee rate estimate result: the successful estimation,...
Definition: fees.h:87
FeeReason
Definition: fees.h:24
@ FEE_RATE_ESTIMATOR
FeeEstimateMode
Definition: fees.h:17
@ ECONOMICAL
Force Fee rate estimator to return non-conservative estimates.