mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#15620: Uncouple non-wallet rpcs from maxTxFee global
This commit is contained in:
parent
c04f74b1d4
commit
3284d82296
@ -685,8 +685,8 @@ void SetupServerArgs()
|
|||||||
gArgs.AddArg("-maxsigcachesize=<n>", strprintf("Limit sum of signature cache and script execution cache sizes to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
gArgs.AddArg("-maxsigcachesize=<n>", strprintf("Limit sum of signature cache and script execution cache sizes to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||||
gArgs.AddArg("-maxtipage=<n>", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
gArgs.AddArg("-maxtipage=<n>", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||||
gArgs.AddArg("-mocktime=<n>", "Replace actual time with <n> seconds since epoch (default: 0)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
gArgs.AddArg("-mocktime=<n>", "Replace actual time with <n> seconds since epoch (default: 0)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||||
gArgs.AddArg("-maxtxfee=<amt>", strprintf("Maximum total fees (in %s) to use in a single wallet transaction or raw transaction; setting this too low may abort large transactions (default: %s)",
|
gArgs.AddArg("-maxtxfee=<amt>", strprintf("Maximum total fees (in %s) to use in a single wallet transaction; setting this too low may abort large transactions (default: %s)",
|
||||||
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
|
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); // TODO move setting to wallet
|
||||||
gArgs.AddArg("-minsporkkeys=<n>", "Overrides minimum spork signers to change spork value. Only useful for regtest and devnet. Using this on mainnet or testnet will ban you.", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
|
gArgs.AddArg("-minsporkkeys=<n>", "Overrides minimum spork signers to change spork value. Only useful for regtest and devnet. Using this on mainnet or testnet will ban you.", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
|
||||||
gArgs.AddArg("-printpriority", strprintf("Log transaction fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
gArgs.AddArg("-printpriority", strprintf("Log transaction fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||||
gArgs.AddArg("-printtoconsole", "Send trace/debug info to console (default: 1 when no -daemon. To disable logging to file, set -nodebuglogfile)", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
|
gArgs.AddArg("-printtoconsole", "Send trace/debug info to console (default: 1 when no -daemon. To disable logging to file, set -nodebuglogfile)", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
|
||||||
|
@ -48,6 +48,11 @@
|
|||||||
|
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
|
||||||
|
/** High fee for sendrawtransaction and testmempoolaccept.
|
||||||
|
* By default, transaction with a fee higher than this will be rejected by the
|
||||||
|
* RPCs. This can be overriden with the maxfeerate argument.
|
||||||
|
*/
|
||||||
|
constexpr static CAmount DEFAULT_MAX_RAW_TX_FEE{COIN / 10};
|
||||||
|
|
||||||
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
|
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
|
||||||
{
|
{
|
||||||
@ -752,14 +757,11 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
UniValue sendrawtransaction(const JSONRPCRequest& request)
|
UniValue sendrawtransaction(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
|
const RPCHelpMan help{"sendrawtransaction", "\nSubmits raw transaction (serialized, hex-encoded) to local node and network.\n"
|
||||||
throw std::runtime_error(
|
|
||||||
RPCHelpMan{"sendrawtransaction",
|
|
||||||
"\nSubmits raw transaction (serialized, hex-encoded) to local node and network.\n"
|
|
||||||
"\nAlso see createrawtransaction and signrawtransactionwithkey calls.\n",
|
"\nAlso see createrawtransaction and signrawtransactionwithkey calls.\n",
|
||||||
{
|
{
|
||||||
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex string of the raw transaction"},
|
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex string of the raw transaction"},
|
||||||
{"maxfeerate", RPCArg::Type::AMOUNT, /* default */ FormatMoney(maxTxFee), "Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT + "/kB\n"},
|
{"maxfeerate", RPCArg::Type::AMOUNT, /* default */ FormatMoney(DEFAULT_MAX_RAW_TX_FEE), "Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT + "/kB\n"},
|
||||||
{"instantsend", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, "Deprecated and ignored"},
|
{"instantsend", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, "Deprecated and ignored"},
|
||||||
{"bypasslimits", RPCArg::Type::BOOL, /* default_val */ "false", "Bypass transaction policy limits"},
|
{"bypasslimits", RPCArg::Type::BOOL, /* default_val */ "false", "Bypass transaction policy limits"},
|
||||||
},
|
},
|
||||||
@ -776,7 +778,11 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
|
|||||||
"\nAs a JSON-RPC call\n"
|
"\nAs a JSON-RPC call\n"
|
||||||
+ HelpExampleRpc("sendrawtransaction", "\"signedhex\"")
|
+ HelpExampleRpc("sendrawtransaction", "\"signedhex\"")
|
||||||
},
|
},
|
||||||
}.ToString());
|
};
|
||||||
|
|
||||||
|
if (request.fHelp || !help.IsValidNumArgs(request.params.size())) {
|
||||||
|
throw std::runtime_error(help.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
RPCTypeCheck(request.params, {
|
RPCTypeCheck(request.params, {
|
||||||
UniValue::VSTR,
|
UniValue::VSTR,
|
||||||
@ -789,7 +795,7 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
|
|||||||
if (!DecodeHexTx(mtx, request.params[0].get_str()))
|
if (!DecodeHexTx(mtx, request.params[0].get_str()))
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
||||||
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
|
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
|
||||||
CAmount max_raw_tx_fee = ::maxTxFee;
|
CAmount max_raw_tx_fee = DEFAULT_MAX_RAW_TX_FEE;
|
||||||
|
|
||||||
// TODO: temporary migration code for old clients. Remove in v0.20
|
// TODO: temporary migration code for old clients. Remove in v0.20
|
||||||
if (request.params[1].isBool()) {
|
if (request.params[1].isBool()) {
|
||||||
@ -815,9 +821,7 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
static UniValue testmempoolaccept(const JSONRPCRequest& request)
|
static UniValue testmempoolaccept(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) {
|
const RPCHelpMan help{"testmempoolaccept",
|
||||||
throw std::runtime_error(
|
|
||||||
RPCHelpMan{"testmempoolaccept",
|
|
||||||
"\nReturns result of mempool acceptance tests indicating if raw transaction (serialized, hex-encoded) would be accepted by mempool.\n"
|
"\nReturns result of mempool acceptance tests indicating if raw transaction (serialized, hex-encoded) would be accepted by mempool.\n"
|
||||||
"\nThis checks if the transaction violates the consensus or policy rules.\n"
|
"\nThis checks if the transaction violates the consensus or policy rules.\n"
|
||||||
"\nSee sendrawtransaction call.\n",
|
"\nSee sendrawtransaction call.\n",
|
||||||
@ -828,7 +832,7 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
|
|||||||
{"rawtx", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, ""},
|
{"rawtx", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, ""},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{"maxfeerate", RPCArg::Type::AMOUNT, /* default */ FormatMoney(maxTxFee), "Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT + "/kB\n"},
|
{"maxfeerate", RPCArg::Type::AMOUNT, /* default */ FormatMoney(DEFAULT_MAX_RAW_TX_FEE), "Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT + "/kB\n"},
|
||||||
},
|
},
|
||||||
RPCResult{
|
RPCResult{
|
||||||
"[ (array) The result of the mempool acceptance test for each raw transaction in the input array.\n"
|
"[ (array) The result of the mempool acceptance test for each raw transaction in the input array.\n"
|
||||||
@ -850,7 +854,10 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
|
|||||||
"\nAs a JSON-RPC call\n"
|
"\nAs a JSON-RPC call\n"
|
||||||
+ HelpExampleRpc("testmempoolaccept", "[\"signedhex\"]")
|
+ HelpExampleRpc("testmempoolaccept", "[\"signedhex\"]")
|
||||||
},
|
},
|
||||||
}.ToString());
|
};
|
||||||
|
|
||||||
|
if (request.fHelp || !help.IsValidNumArgs(request.params.size())) {
|
||||||
|
throw std::runtime_error(help.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
RPCTypeCheck(request.params, {
|
RPCTypeCheck(request.params, {
|
||||||
@ -869,7 +876,7 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
|
|||||||
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
|
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
|
||||||
const uint256& tx_hash = tx->GetHash();
|
const uint256& tx_hash = tx->GetHash();
|
||||||
|
|
||||||
CAmount max_raw_tx_fee = ::maxTxFee;
|
CAmount max_raw_tx_fee = DEFAULT_MAX_RAW_TX_FEE;
|
||||||
// TODO: temporary migration code for old clients. Remove in v0.20
|
// TODO: temporary migration code for old clients. Remove in v0.20
|
||||||
if (request.params[1].isBool()) {
|
if (request.params[1].isBool()) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Second argument must be numeric (maxfeerate) and no longer supports a boolean. To allow a transaction with high fees, set maxfeerate to 0.");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Second argument must be numeric (maxfeerate) and no longer supports a boolean. To allow a transaction with high fees, set maxfeerate to 0.");
|
||||||
|
Loading…
Reference in New Issue
Block a user