mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
![Jon Atack](/assets/img/avatar_default.png)
Create a fee_rate (sat/vB) RPC param and replace overloading the conf_target and estimate_mode params in the following 6 RPCs with it: - sendtoaddress - sendmany - send - fundrawtransaction - walletcreatefundedpsbt - bumpfee In RPC bumpfee, the previously existing fee_rate remains but the unit is changed from BTC/kvB to sat/vB. This is a breaking change, but it should not be an overly risky one, as the units change by a factor of 1e5 and any fees specified in BTC/kvB after this commit will either be too low and raise an error or be 1 sat/vB and can be RBFed. Update the test coverage for each RPC. Co-authored-by: Murch <murch@murch.one>
62 lines
2 KiB
C++
62 lines
2 KiB
C++
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2019 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#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)
|
|
{
|
|
static const std::map<FeeReason, std::string> fee_reason_strings = {
|
|
{FeeReason::NONE, "None"},
|
|
{FeeReason::HALF_ESTIMATE, "Half Target 60% Threshold"},
|
|
{FeeReason::FULL_ESTIMATE, "Target 85% Threshold"},
|
|
{FeeReason::DOUBLE_ESTIMATE, "Double Target 95% Threshold"},
|
|
{FeeReason::CONSERVATIVE, "Conservative Double Target longer horizon"},
|
|
{FeeReason::MEMPOOL_MIN, "Mempool Min Fee"},
|
|
{FeeReason::PAYTXFEE, "PayTxFee set"},
|
|
{FeeReason::FALLBACK, "Fallback fee"},
|
|
{FeeReason::REQUIRED, "Minimum Required Fee"},
|
|
};
|
|
auto reason_string = fee_reason_strings.find(reason);
|
|
|
|
if (reason_string == fee_reason_strings.end()) return "Unknown";
|
|
|
|
return reason_string->second;
|
|
}
|
|
|
|
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},
|
|
};
|
|
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;
|
|
}
|