mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 01:33:20 +02:00
Merge #11413: [wallet] [rpc] sendtoaddress/sendmany: Add explicit feerate option
25dac9fa65doc: add release notes for explicit fee estimators and bumpfee change (Karl-Johan Alm)05227a3554tests for bumpfee / estimate_modes (Karl-Johan Alm)3404c1b753policy: optional FeeEstimateMode param to CFeeRate::ToString (Karl-Johan Alm)6fcf448430rpc/wallet: add two explicit modes to estimate_mode (Karl-Johan Alm)b188d80c2dMOVEONLY: Make FeeEstimateMode available to CFeeRate (Karl-Johan Alm)5d1a411eb1fees: add FeeModes doc helper function (Karl-Johan Alm)91f6d2bc8frpc/wallet: add conf_target as alias to confTarget in bumpfee (Karl-Johan Alm)69158b41fcadded CURRENCY_ATOM to express minimum indivisible unit (Karl-Johan Alm) Pull request description: This lets users pick their own fees when using `sendtoaddress`/`sendmany` if they prefer this over the estimators. ACKs for top commit: Sjors: re-utACK25dac9fa65: rebased, more fancy C++, jonatack: ACK25dac9fa65I think this should be merged after all this time, even though it looks to me like there are needed follow-ups, fixes and test coverage to be added (see further down), which I don't mind helping out with, if wanted. fjahr: Code review ACK25dac9fa65Tree-SHA512: f31177e6cabf3187a43cdfe93477144f8e8385c7344613743cbbd16e8490d53ff5144aec7b9de6c9a65eb855b55e0f99d7f164dee4b6bf3cfea4dce51cf11d33
This commit is contained in:
@@ -6,11 +6,16 @@
|
||||
#include <util/fees.h>
|
||||
|
||||
#include <policy/fees.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
std::string StringForFeeReason(FeeReason reason) {
|
||||
std::string StringForFeeReason(FeeReason reason)
|
||||
{
|
||||
static const std::map<FeeReason, std::string> fee_reason_strings = {
|
||||
{FeeReason::NONE, "None"},
|
||||
{FeeReason::HALF_ESTIMATE, "Half Target 60% Threshold"},
|
||||
@@ -29,16 +34,31 @@ std::string StringForFeeReason(FeeReason reason) {
|
||||
return reason_string->second;
|
||||
}
|
||||
|
||||
bool FeeModeFromString(const std::string& mode_string, FeeEstimateMode& fee_estimate_mode) {
|
||||
static const std::map<std::string, FeeEstimateMode> fee_modes = {
|
||||
{"UNSET", FeeEstimateMode::UNSET},
|
||||
{"ECONOMICAL", FeeEstimateMode::ECONOMICAL},
|
||||
{"CONSERVATIVE", FeeEstimateMode::CONSERVATIVE},
|
||||
const std::vector<std::pair<std::string, FeeEstimateMode>>& FeeModeMap()
|
||||
{
|
||||
static const std::vector<std::pair<std::string, FeeEstimateMode>> FEE_MODES = {
|
||||
{"unset", FeeEstimateMode::UNSET},
|
||||
{"economical", FeeEstimateMode::ECONOMICAL},
|
||||
{"conservative", FeeEstimateMode::CONSERVATIVE},
|
||||
{(CURRENCY_UNIT + "/kB"), FeeEstimateMode::BTC_KB},
|
||||
{(CURRENCY_ATOM + "/B"), FeeEstimateMode::SAT_B},
|
||||
};
|
||||
auto mode = fee_modes.find(mode_string);
|
||||
|
||||
if (mode == fee_modes.end()) return false;
|
||||
|
||||
fee_estimate_mode = mode->second;
|
||||
return true;
|
||||
return FEE_MODES;
|
||||
}
|
||||
|
||||
std::string FeeModes(const std::string& delimiter)
|
||||
{
|
||||
return Join(FeeModeMap(), delimiter, [&](const std::pair<std::string, FeeEstimateMode>& i) { return i.first; });
|
||||
}
|
||||
|
||||
bool FeeModeFromString(const std::string& mode_string, FeeEstimateMode& fee_estimate_mode)
|
||||
{
|
||||
auto searchkey = ToUpper(mode_string);
|
||||
for (const auto& pair : FeeModeMap()) {
|
||||
if (ToUpper(pair.first) == searchkey) {
|
||||
fee_estimate_mode = pair.second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,5 +12,6 @@ enum class FeeReason;
|
||||
|
||||
bool FeeModeFromString(const std::string& mode_string, FeeEstimateMode& fee_estimate_mode);
|
||||
std::string StringForFeeReason(FeeReason reason);
|
||||
std::string FeeModes(const std::string& delimiter);
|
||||
|
||||
#endif // BITCOIN_UTIL_FEES_H
|
||||
|
||||
Reference in New Issue
Block a user