You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
7abd2e6 wallet/rpc: add maxfeerate parameter to testmempoolaccept (Karl-Johan Alm)
6c0a6f7 wallet/rpc: add maxfeerate parameter to sendrawtransaction (Karl-Johan Alm)
e5efacb test: Refactor vout fetches in rpc_rawtransaction (Karl-Johan Alm)
Pull request description:
This adds a new `maxfeerate` parameter to `sendrawtransaction` which forces the node to reject a transaction whose feerate is above the given fee rate.
This is a safety harness from shooting yourself in the foot and accidentally overpaying fees.
See also #12911.
Tree-SHA512: efa50134a7c17c9330cfdfd48ba400e095c0a419cc45e630618d8b44929c25d780d1bb2710c1fbbb6e687eca373505b0338cdaa7f2ff4ca22636d84c31557a2e
// TODO: temporary migration code for old clients. Remove in v0.20
1073
+
if (request.params[1].isBool()) {
1074
+
throwJSONRPCError(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.");
1075
+
} elseif (request.params[1].isNum()) {
1076
+
size_t weight = GetTransactionWeight(*tx);
1077
+
CFeeRate fr(AmountFromValue(request.params[1]));
1078
+
// the +3/4 part rounds the value up, and is the same formula used when
1079
+
// calculating the fee for a transaction
1080
+
// (see GetVirtualTransactionSize)
1081
+
max_raw_tx_fee = fr.GetFee((weight+3)/4);
1082
+
} elseif (!request.params[1].isNull()) {
1083
+
throwJSONRPCError(RPC_INVALID_PARAMETER, "second argument (maxfeerate) must be numeric");
if (!request.params[1].isNull() && request.params[1].get_bool()) {
1134
-
max_raw_tx_fee = 0;
1152
+
CAmount max_raw_tx_fee = maxTxFee;
1153
+
// TODO: temporary migration code for old clients. Remove in v0.20
1154
+
if (request.params[1].isBool()) {
1155
+
throwJSONRPCError(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.");
1156
+
} elseif (request.params[1].isNum()) {
1157
+
size_t weight = GetTransactionWeight(*tx);
1158
+
CFeeRate fr(AmountFromValue(request.params[1]));
1159
+
// the +3/4 part rounds the value up, and is the same formula used when
1160
+
// calculating the fee for a transaction
1161
+
// (see GetVirtualTransactionSize)
1162
+
max_raw_tx_fee = fr.GetFee((weight+3)/4);
1163
+
} elseif (!request.params[1].isNull()) {
1164
+
throwJSONRPCError(RPC_INVALID_PARAMETER, "second argument (maxfeerate) must be numeric");
0 commit comments