mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Merge #18467: rpc: Improve documentation and return value of settxfee
38677274f931088218eeb1f258077d3387f39c89 rpc: settxfee respects -maxtxfee wallet setting (Fabian Jahr) bda84a08a0ac92dff6cadc99cf9bb8c3fadd7e13 rpc: Add documentation for deactivating settxfee (Fabian Jahr) Pull request description: ~~Closes 18315~~ `settxfee` can be deactivated by passing 0 as the fee. That does not seem to be documented for the user so this PR adds it in the description. The return value of a simple boolean seems also too simplified given the multiple dimensions that this deactivation feature enables. I.e. it does not seem intuitive if the returned boolean shows that the call succeeded or if means that `settxfee` is active. My suggested solution is to change the return value to a JSON object that included the "active" state and the currently set fee rate. Examples: ``` $ src/bitcoin-cli settxfee 0.0000000 { "active": false, "fee_rate": "0.00000000 BTC/kB" } $ src/bitcoin-cli settxfee 0.0001 { "active": true, "fee_rate": "0.00010000 BTC/kB" } ``` ACKs for top commit: MarcoFalke: ACK 38677274f931088218eeb1f258077d3387f39c89, seems useful to error out early instead of later #16257 🕍 jonatack: ACK 38677274f931088218eeb meshcollider: LGTM, utACK 38677274f931088218eeb1f258077d3387f39c89 Tree-SHA512: 642813b5cf6612abb4b6cb63728081a6bd1659d809e0149c8f56060b6da7253fee989b3b202854f3051df3773c966799af30b612648c466b099f00590f356548
This commit is contained in:
parent
4abace34ad
commit
9867af5500
@ -2288,7 +2288,8 @@ static UniValue listlockunspent(const JSONRPCRequest& request)
|
||||
static UniValue settxfee(const JSONRPCRequest& request)
|
||||
{
|
||||
RPCHelpMan{"settxfee",
|
||||
"\nSet the transaction fee per kB for this wallet. Overrides the global -paytxfee command line parameter.\n",
|
||||
"\nSet the transaction fee per kB for this wallet. Overrides the global -paytxfee command line parameter.\n"
|
||||
"Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.\n",
|
||||
{
|
||||
{"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "The transaction fee in " + CURRENCY_UNIT + "/kB"},
|
||||
},
|
||||
@ -2309,12 +2310,15 @@ static UniValue settxfee(const JSONRPCRequest& request)
|
||||
|
||||
CAmount nAmount = AmountFromValue(request.params[0]);
|
||||
CFeeRate tx_fee_rate(nAmount, 1000);
|
||||
CFeeRate max_tx_fee_rate(pwallet->m_default_max_tx_fee, 1000);
|
||||
if (tx_fee_rate == 0) {
|
||||
// automatic selection
|
||||
} 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()));
|
||||
} 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()));
|
||||
} else if (tx_fee_rate > max_tx_fee_rate) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("txfee cannot be more than wallet max tx fee (%s)", max_tx_fee_rate.ToString()));
|
||||
}
|
||||
|
||||
pwallet->m_pay_tx_fee = tx_fee_rate;
|
||||
|
@ -7,6 +7,7 @@
|
||||
Verify that a dashd node can load multiple wallet files
|
||||
"""
|
||||
from threading import Thread
|
||||
from decimal import Decimal
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
@ -204,9 +205,9 @@ class MultiWalletTest(BitcoinTestFramework):
|
||||
self.log.info('Check for per-wallet settxfee call')
|
||||
assert_equal(w1.getwalletinfo()['paytxfee'], 0)
|
||||
assert_equal(w2.getwalletinfo()['paytxfee'], 0)
|
||||
w2.settxfee(4.0)
|
||||
w2.settxfee(0.001)
|
||||
assert_equal(w1.getwalletinfo()['paytxfee'], 0)
|
||||
assert_equal(w2.getwalletinfo()['paytxfee'], 4.0)
|
||||
assert_equal(w2.getwalletinfo()['paytxfee'], Decimal('0.00100000'))
|
||||
|
||||
self.log.info("Test dynamic wallet loading")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user