mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
Disallow implicit conversion for CFeeRate constructor
This commit is contained in:
parent
8e59af55aa
commit
6a51f79517
@ -25,7 +25,7 @@ public:
|
|||||||
/** Fee rate of 0 satoshis per kB */
|
/** Fee rate of 0 satoshis per kB */
|
||||||
CFeeRate() : nSatoshisPerK(0) { }
|
CFeeRate() : nSatoshisPerK(0) { }
|
||||||
template<typename I>
|
template<typename I>
|
||||||
CFeeRate(const I _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) {
|
explicit CFeeRate(const I _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) {
|
||||||
// We've previously had bugs creep in from silent double->int conversion...
|
// We've previously had bugs creep in from silent double->int conversion...
|
||||||
static_assert(std::is_integral<I>::value, "CFeeRate should be used without floats");
|
static_assert(std::is_integral<I>::value, "CFeeRate should be used without floats");
|
||||||
}
|
}
|
||||||
|
@ -2327,7 +2327,7 @@ static UniValue settxfee(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
CAmount nAmount = AmountFromValue(request.params[0]);
|
CAmount nAmount = AmountFromValue(request.params[0]);
|
||||||
CFeeRate tx_fee_rate(nAmount, 1000);
|
CFeeRate tx_fee_rate(nAmount, 1000);
|
||||||
if (tx_fee_rate == 0) {
|
if (tx_fee_rate == CFeeRate(0)) {
|
||||||
// automatic selection
|
// automatic selection
|
||||||
} else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
|
} else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("txfee cannot be less than min relay tx fee (%s)", pwallet->chain().relayMinFee().ToString()));
|
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)
|
|||||||
}
|
}
|
||||||
} else if (options.exists("fee_rate")) {
|
} else if (options.exists("fee_rate")) {
|
||||||
CFeeRate fee_rate(AmountFromValue(options["fee_rate"]));
|
CFeeRate fee_rate(AmountFromValue(options["fee_rate"]));
|
||||||
if (fee_rate <= 0) {
|
if (fee_rate <= CFeeRate(0)) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid fee_rate %s (must be greater than 0)", fee_rate.ToString()));
|
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid fee_rate %s (must be greater than 0)", fee_rate.ToString()));
|
||||||
}
|
}
|
||||||
coin_control.m_feerate = fee_rate;
|
coin_control.m_feerate = fee_rate;
|
||||||
|
Loading…
Reference in New Issue
Block a user