aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2020-11-08 19:57:35 +0100
committerJon Atack <jon@atack.com>2020-11-12 11:43:03 +0100
commit173b5b5fe07d45be5a1e5bc7a5df996f20ab1e85 (patch)
tree0241bef69ca5fe14f4e90cfb99fabc216d875c17 /src
parent7f9835a05abf3e168ad93e7195cbaa4bf61b9b07 (diff)
downloadbitcoin-173b5b5fe07d45be5a1e5bc7a5df996f20ab1e85.tar.xz
wallet: update fee rate units, use sat/vB for fee_rate error messages
and BTC/kvB for feeRate error messages.
Diffstat (limited to 'src')
-rw-r--r--src/policy/feerate.cpp4
-rw-r--r--src/policy/feerate.h6
-rw-r--r--src/test/amount_tests.cpp6
-rw-r--r--src/wallet/rpcwallet.cpp2
-rw-r--r--src/wallet/wallet.cpp2
5 files changed, 11 insertions, 9 deletions
diff --git a/src/policy/feerate.cpp b/src/policy/feerate.cpp
index a01e259731..04e0e117a5 100644
--- a/src/policy/feerate.cpp
+++ b/src/policy/feerate.cpp
@@ -38,7 +38,7 @@ CAmount CFeeRate::GetFee(size_t nBytes_) const
std::string CFeeRate::ToString(const FeeEstimateMode& fee_estimate_mode) const
{
switch (fee_estimate_mode) {
- case FeeEstimateMode::SAT_B: return strprintf("%d.%03d %s/B", nSatoshisPerK / 1000, nSatoshisPerK % 1000, CURRENCY_ATOM);
- default: return strprintf("%d.%08d %s/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN, CURRENCY_UNIT);
+ case FeeEstimateMode::SAT_VB: return strprintf("%d.%03d %s/vB", nSatoshisPerK / 1000, nSatoshisPerK % 1000, CURRENCY_ATOM);
+ default: return strprintf("%d.%08d %s/kvB", nSatoshisPerK / COIN, nSatoshisPerK % COIN, CURRENCY_UNIT);
}
}
diff --git a/src/policy/feerate.h b/src/policy/feerate.h
index 0f2bff1909..7c5660ac8a 100644
--- a/src/policy/feerate.h
+++ b/src/policy/feerate.h
@@ -19,8 +19,8 @@ enum class FeeEstimateMode {
UNSET, //!< Use default settings based on other criteria
ECONOMICAL, //!< Force estimateSmartFee to use non-conservative estimates
CONSERVATIVE, //!< Force estimateSmartFee to use conservative estimates
- BTC_KB, //!< Use explicit BTC/kB fee given in coin control
- SAT_B, //!< Use explicit sat/B fee given in coin control
+ BTC_KVB, //!< Use BTC/kvB fee rate unit
+ SAT_VB, //!< Use sat/vB fee rate unit
};
/**
@@ -65,7 +65,7 @@ public:
friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; }
friend bool operator!=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK != b.nSatoshisPerK; }
CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; }
- std::string ToString(const FeeEstimateMode& fee_estimate_mode = FeeEstimateMode::BTC_KB) const;
+ std::string ToString(const FeeEstimateMode& fee_estimate_mode = FeeEstimateMode::BTC_KVB) const;
SERIALIZE_METHODS(CFeeRate, obj) { READWRITE(obj.nSatoshisPerK); }
};
diff --git a/src/test/amount_tests.cpp b/src/test/amount_tests.cpp
index e20900ed13..c16519a6b1 100644
--- a/src/test/amount_tests.cpp
+++ b/src/test/amount_tests.cpp
@@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(BinaryOperatorTest)
BOOST_CHECK(a <= a);
BOOST_CHECK(b >= a);
BOOST_CHECK(b >= b);
- // a should be 0.00000002 BTC/kB now
+ // a should be 0.00000002 BTC/kvB now
a += a;
BOOST_CHECK(a == b);
}
@@ -107,7 +107,9 @@ BOOST_AUTO_TEST_CASE(ToStringTest)
{
CFeeRate feeRate;
feeRate = CFeeRate(1);
- BOOST_CHECK_EQUAL(feeRate.ToString(), "0.00000001 BTC/kB");
+ BOOST_CHECK_EQUAL(feeRate.ToString(), "0.00000001 BTC/kvB");
+ BOOST_CHECK_EQUAL(feeRate.ToString(FeeEstimateMode::BTC_KVB), "0.00000001 BTC/kvB");
+ BOOST_CHECK_EQUAL(feeRate.ToString(FeeEstimateMode::SAT_VB), "0.001 sat/vB");
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index d286ee447b..f023d3e3f8 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -3136,7 +3136,7 @@ void FundTransaction(CWallet* const pwallet, CMutableTransaction& tx, CAmount& f
}
CFeeRate fee_rate(AmountFromValue(options["feeRate"]));
if (fee_rate <= CFeeRate(0)) {
- throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid feeRate %s (must be greater than 0)", fee_rate.ToString()));
+ throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid feeRate %s (must be greater than 0)", fee_rate.ToString(FeeEstimateMode::BTC_KVB)));
}
coinControl.m_feerate = fee_rate;
coinControl.fOverrideFeeRate = true;
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 2b4e2a1240..37f6a4a7dc 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2834,7 +2834,7 @@ bool CWallet::CreateTransactionInternal(
// Do not, ever, assume that it's fine to change the fee rate if the user has explicitly
// provided one
if (coin_control.m_feerate && nFeeRateNeeded > *coin_control.m_feerate) {
- error = strprintf(_("Fee rate (%s) is lower than the minimum fee rate setting (%s)"), coin_control.m_feerate->ToString(), nFeeRateNeeded.ToString());
+ error = strprintf(_("Fee rate (%s) is lower than the minimum fee rate setting (%s)"), coin_control.m_feerate->ToString(FeeEstimateMode::SAT_VB), nFeeRateNeeded.ToString(FeeEstimateMode::SAT_VB));
return false;
}