aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2018-08-09 01:52:42 +1000
committerAnthony Towns <aj@erisian.com.au>2018-08-16 12:47:31 +1000
commit48618daf262b84c2e2f7322b5ca14375d7d68b64 (patch)
tree81c9457376ab2c579e9f3d0b8d20d6d0b16abe0d /src
parentb5591ca0b053623f0d96423b05ad809115a0bdef (diff)
downloadbitcoin-48618daf262b84c2e2f7322b5ca14375d7d68b64.tar.xz
Add checks for settxfee reasonableness
Diffstat (limited to 'src')
-rw-r--r--src/wallet/rpcwallet.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 281fd46146..46162556eb 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -2982,8 +2982,16 @@ static UniValue settxfee(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet);
CAmount nAmount = AmountFromValue(request.params[0]);
+ CFeeRate tx_fee_rate(nAmount, 1000);
+ if (tx_fee_rate == 0) {
+ // automatic selection
+ } else if (tx_fee_rate < ::minRelayTxFee) {
+ throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("txfee cannot be less than min relay tx fee (%s)", ::minRelayTxFee.ToString()));
+ } else if (tx_fee_rate < pwallet->m_min_fee) {
+ throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("txfee cannot be less than wallet min fee (%s)", pwallet->m_min_fee.ToString()));
+ }
- pwallet->m_pay_tx_fee = CFeeRate(nAmount, 1000);
+ pwallet->m_pay_tx_fee = tx_fee_rate;
return true;
}