Bitcoin Core 32.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 <optional>
13#include <string>
14#include <string_view>
15#include <utility>
16
17/* Used to determine type of fee estimation requested */
18enum class FeeEstimateMode {
19 UNSET,
22};
23
24/* Used to determine the reason a wallet selected a transaction fee rate */
25enum class FeeReason {
31};
32
38 AUTO,
40 MEMPOOL_POLICY,
41};
42
59 auto operator<=>(const FeeRateEstimation& other) const
60 {
61 return ByRatio{feerate} <=> ByRatio{other.feerate};
62 }
63};
64
72 std::string reason;
73};
74
79inline util::Unexpected<FeeRateEstimationError> EstimationError(FeeRateEstimatorType estimator, int returned_target, std::string error)
80{
81 return util::Unexpected{FeeRateEstimationError{{estimator, FeePerVSize{0, 0}, returned_target}, std::move(error)}};
82}
83
89{
90 return result ? *result : result.error().estimation;
91}
92
93std::string_view FeeRateEstimatorTypeToString(FeeRateEstimatorType feerate_estimator_type);
94std::optional<FeeRateEstimatorType> FeeRateEstimatorTypeFromString(std::string_view feerate_estimator_type);
95
96#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:218
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:70
std::string reason
Definition: fees.h:72
FeeRateEstimation estimation
Definition: fees.h:71
A successful fee rate estimate returned by a fee rate estimator.
Definition: fees.h:47
FeeRateEstimatorType feerate_estimator
This identifies which fee rate estimator is providing this feerate estimate.
Definition: fees.h:49
auto operator<=>(const FeeRateEstimation &other) const
Compare two FeeRateEstimation objects based on fee rate.
Definition: fees.h:59
FeePerVSize feerate
Fee rate sufficient for confirmation within target.
Definition: fees.h:51
int returned_target
The returned confirmation target for the estimate.
Definition: fees.h:53
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:79
std::string_view FeeRateEstimatorTypeToString(FeeRateEstimatorType feerate_estimator_type)
Definition: fees.cpp:13
FeeRateEstimatorType
Identifier for fee rate estimator.
Definition: fees.h:37
std::optional< FeeRateEstimatorType > FeeRateEstimatorTypeFromString(std::string_view feerate_estimator_type)
Definition: fees.cpp:27
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:88
FeeReason
Definition: fees.h:25
@ FEE_RATE_ESTIMATOR
FeeEstimateMode
Definition: fees.h:18
@ ECONOMICAL
Force Fee rate estimator to return non-conservative estimates.