Skip to content

Commit 6a51f79

Browse files
committed
Disallow implicit conversion for CFeeRate constructor
1 parent 8e59af5 commit 6a51f79

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/policy/feerate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CFeeRate
2525
/** Fee rate of 0 satoshis per kB */
2626
CFeeRate() : nSatoshisPerK(0) { }
2727
template<typename I>
28-
CFeeRate(const I _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) {
28+
explicit CFeeRate(const I _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) {
2929
// We've previously had bugs creep in from silent double->int conversion...
3030
static_assert(std::is_integral<I>::value, "CFeeRate should be used without floats");
3131
}

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,7 +2327,7 @@ static UniValue settxfee(const JSONRPCRequest& request)
23272327

23282328
CAmount nAmount = AmountFromValue(request.params[0]);
23292329
CFeeRate tx_fee_rate(nAmount, 1000);
2330-
if (tx_fee_rate == 0) {
2330+
if (tx_fee_rate == CFeeRate(0)) {
23312331
// automatic selection
23322332
} else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
23332333
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("txfee cannot be less than min relay tx fee (%s)", pwallet->chain().relayMinFee().ToString()));
@@ -3386,7 +3386,7 @@ static UniValue bumpfee(const JSONRPCRequest& request)
33863386
}
33873387
} else if (options.exists("fee_rate")) {
33883388
CFeeRate fee_rate(AmountFromValue(options["fee_rate"]));
3389-
if (fee_rate <= 0) {
3389+
if (fee_rate <= CFeeRate(0)) {
33903390
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid fee_rate %s (must be greater than 0)", fee_rate.ToString()));
33913391
}
33923392
coin_control.m_feerate = fee_rate;

0 commit comments

Comments
 (0)