Bitcoin Core  0.19.99
P2P Digital Currency
fees.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2019 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include <util/fees.h>
7 
8 #include <policy/fees.h>
9 
10 #include <map>
11 #include <string>
12 
13 std::string StringForFeeReason(FeeReason reason) {
14  static const std::map<FeeReason, std::string> fee_reason_strings = {
15  {FeeReason::NONE, "None"},
16  {FeeReason::HALF_ESTIMATE, "Half Target 60% Threshold"},
17  {FeeReason::FULL_ESTIMATE, "Target 85% Threshold"},
18  {FeeReason::DOUBLE_ESTIMATE, "Double Target 95% Threshold"},
19  {FeeReason::CONSERVATIVE, "Conservative Double Target longer horizon"},
20  {FeeReason::MEMPOOL_MIN, "Mempool Min Fee"},
21  {FeeReason::PAYTXFEE, "PayTxFee set"},
22  {FeeReason::FALLBACK, "Fallback fee"},
23  {FeeReason::REQUIRED, "Minimum Required Fee"},
24  };
25  auto reason_string = fee_reason_strings.find(reason);
26 
27  if (reason_string == fee_reason_strings.end()) return "Unknown";
28 
29  return reason_string->second;
30 }
31 
32 bool FeeModeFromString(const std::string& mode_string, FeeEstimateMode& fee_estimate_mode) {
33  static const std::map<std::string, FeeEstimateMode> fee_modes = {
34  {"UNSET", FeeEstimateMode::UNSET},
35  {"ECONOMICAL", FeeEstimateMode::ECONOMICAL},
36  {"CONSERVATIVE", FeeEstimateMode::CONSERVATIVE},
37  };
38  auto mode = fee_modes.find(mode_string);
39 
40  if (mode == fee_modes.end()) return false;
41 
42  fee_estimate_mode = mode->second;
43  return true;
44 }
FeeEstimateMode
Definition: fees.h:49
Force estimateSmartFee to use conservative estimates.
Use default settings based on other criteria.
FeeReason
Definition: fees.h:36
Force estimateSmartFee to use non-conservative estimates.
bool FeeModeFromString(const std::string &mode_string, FeeEstimateMode &fee_estimate_mode)
Definition: fees.cpp:32
std::string StringForFeeReason(FeeReason reason)
Definition: fees.cpp:13