aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/rawtransaction.cpp
diff options
context:
space:
mode:
authorgzhao408 <gzhao408@berkeley.edu>2020-07-25 10:05:15 -0700
committergzhao408 <gzhao408@berkeley.edu>2020-10-05 04:54:05 -0700
commit8f1290c60159a3171c27250bc95687548c5c1b84 (patch)
treeeea0e386fb7add4d19609a8c2acb9ea442882a45 /src/rpc/rawtransaction.cpp
parent3487e421a7fef4b28381efcf21a7e38483946cec (diff)
[rpc/node] check for high fee before ATMP in clients
Check absurd fee in BroadcastTransaction and RPC, return TransactionError::MAX_FEE_EXCEEDED instead of TxValidationResult::TX_NOT_STANDARD because this is client preference, not a node-wide policy.
Diffstat (limited to 'src/rpc/rawtransaction.cpp')
-rw-r--r--src/rpc/rawtransaction.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index e60e0a2d90..35b75d6c47 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -947,12 +947,20 @@ static RPCHelpMan testmempoolaccept()
TxValidationState state;
bool test_accept_res;
- CAmount fee;
+ CAmount fee{0};
{
LOCK(cs_main);
test_accept_res = AcceptToMemoryPool(mempool, state, std::move(tx),
nullptr /* plTxnReplaced */, false /* bypass_limits */, max_raw_tx_fee, /* test_accept */ true, &fee);
}
+
+ // Check that fee does not exceed maximum fee
+ if (test_accept_res && max_raw_tx_fee && fee > max_raw_tx_fee) {
+ result_0.pushKV("allowed", false);
+ result_0.pushKV("reject-reason", "max-fee-exceeded");
+ result.push_back(std::move(result_0));
+ return result;
+ }
result_0.pushKV("allowed", test_accept_res);
// Only return the fee and vsize if the transaction would pass ATMP.