Bitcoin Core
32.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
util
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 */
18
enum class
FeeEstimateMode
{
19
UNSET,
20
ECONOMICAL
,
21
CONSERVATIVE
,
22
};
23
24
/* Used to determine the reason a wallet selected a transaction fee rate */
25
enum class
FeeReason
{
26
FEE_RATE_ESTIMATOR
,
27
MEMPOOL_MIN
,
28
USER_SPECIFIED
,
29
FALLBACK
,
30
REQUIRED
,
31
};
32
37
enum class
FeeRateEstimatorType
{
38
AUTO
,
39
BLOCK_POLICY
,
40
MEMPOOL_POLICY,
41
};
42
47
struct
FeeRateEstimation
{
49
FeeRateEstimatorType
feerate_estimator
;
51
FeePerVSize
feerate
;
53
int
returned_target
;
59
auto
operator<=>
(
const
FeeRateEstimation
& other)
const
60
{
61
return
ByRatio
{
feerate
} <=>
ByRatio
{other.
feerate
};
62
}
63
};
64
70
struct
FeeRateEstimationError
{
71
FeeRateEstimation
estimation
;
72
std::string
reason
;
73
};
74
79
inline
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
88
inline
const
FeeRateEstimation
&
FeeRateEstimationRef
(
const
util::Expected<FeeRateEstimation, FeeRateEstimationError>
& result
LIFETIMEBOUND
)
89
{
90
return
result ? *result : result.error().estimation;
91
}
92
93
std::string_view
FeeRateEstimatorTypeToString
(
FeeRateEstimatorType
feerate_estimator_type);
94
std::optional<FeeRateEstimatorType>
FeeRateEstimatorTypeFromString
(std::string_view feerate_estimator_type);
95
96
#endif
// BITCOIN_UTIL_FEES_H
attributes.h
LIFETIMEBOUND
#define LIFETIMEBOUND
Definition
attributes.h:16
BlockPolicyEstimateReason::CONSERVATIVE
@ CONSERVATIVE
Definition
block_policy_estimator.h:63
ByRatio
Wrapper around FeeFrac & derived types, which adds a feerate-based ordering which treats equal-feerat...
Definition
feefrac.h:218
util::Expected
The util::Expected class provides a standard way for low-level functions to return either error value...
Definition
expected.h:44
util::Unexpected
The util::Unexpected class represents an unexpected value stored in util::Expected.
Definition
expected.h:21
expected.h
feefrac.h
FeePerVSize
FeePerUnit< VSizeTag > FeePerVSize
Definition
feefrac.h:204
FeeRateEstimationError
A failed fee rate estimation, carrying the zero-value estimation that identifies the estimator and ta...
Definition
fees.h:70
FeeRateEstimationError::reason
std::string reason
Definition
fees.h:72
FeeRateEstimationError::estimation
FeeRateEstimation estimation
Definition
fees.h:71
FeeRateEstimation
A successful fee rate estimate returned by a fee rate estimator.
Definition
fees.h:47
FeeRateEstimation::feerate_estimator
FeeRateEstimatorType feerate_estimator
This identifies which fee rate estimator is providing this feerate estimate.
Definition
fees.h:49
FeeRateEstimation::operator<=>
auto operator<=>(const FeeRateEstimation &other) const
Compare two FeeRateEstimation objects based on fee rate.
Definition
fees.h:59
FeeRateEstimation::feerate
FeePerVSize feerate
Fee rate sufficient for confirmation within target.
Definition
fees.h:51
FeeRateEstimation::returned_target
int returned_target
The returned confirmation target for the estimate.
Definition
fees.h:53
FeeRateEstimatorTypeToString
std::string_view FeeRateEstimatorTypeToString(FeeRateEstimatorType feerate_estimator_type)
Definition
fees.cpp:13
FeeRateEstimatorTypeFromString
std::optional< FeeRateEstimatorType > FeeRateEstimatorTypeFromString(std::string_view feerate_estimator_type)
Definition
fees.cpp:27
EstimationError
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
FeeRateEstimatorType
FeeRateEstimatorType
Identifier for fee rate estimator.
Definition
fees.h:37
FeeRateEstimatorType::BLOCK_POLICY
@ BLOCK_POLICY
Definition
fees.h:39
FeeRateEstimatorType::AUTO
@ AUTO
Definition
fees.h:38
FeeRateEstimationRef
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
FeeReason
Definition
fees.h:25
FeeReason::USER_SPECIFIED
@ USER_SPECIFIED
Definition
fees.h:28
FeeReason::FEE_RATE_ESTIMATOR
@ FEE_RATE_ESTIMATOR
Definition
fees.h:26
FeeReason::REQUIRED
@ REQUIRED
Definition
fees.h:30
FeeReason::FALLBACK
@ FALLBACK
Definition
fees.h:29
FeeReason::MEMPOOL_MIN
@ MEMPOOL_MIN
Definition
fees.h:27
FeeEstimateMode
FeeEstimateMode
Definition
fees.h:18
FeeEstimateMode::ECONOMICAL
@ ECONOMICAL
Force Fee rate estimator to return non-conservative estimates.
Definition
fees.h:20
Generated on
for Bitcoin Core by
1.18.0