rpc: define and use new RPC_LIMIT_EXCEEDED error code
What changed, and why it matters
This commit changes the error code returned when Bitcoin Core's private broadcast transaction queue is full. Previously, the node reported an 'out of memory' error (-7), which was misleading because the server is not actually running out of memory. The new error code (-37, RPC_LIMIT_EXCEEDED) more accurately tells the caller that a configured capacity limit has been reached. This is a correctness and clarity improvement, not a security fix for a vulnerability.
No security action required. Treat as a normal code-quality/correctness update. Reviewers may verify that RPC client documentation or release notes mention the new -37 error code if users depend on the old -7 behavior.
Security signals we found
No vulnerability signal: change is an error-code correction, not a memory-safety or authorization fix
No attacker-controlled code path introduced
No change to resource limits or queue eviction policy
Evidence from the diff
The patch adds a new RPC error code RPC_LIMIT_EXCEEDED (-37) in src/rpc/protocol.h and maps TransactionError::PRIVATE_BROADCAST_FULL to it in RPCErrorFromTransactionError() instead of RPC_OUT_OF_MEMORY (-7). The functional test is updated to expect -37. The behavior of rejecting transactions when the queue is full is unchanged; only the reported error code and message classification are corrected.
Changed components
src/rpc/protocol.hsrc/rpc/util.cpptest/functional/p2p_private_broadcast_cap.pyInspect captured patch +3 / −2
diff --git a/src/rpc/protocol.h b/src/rpc/protocol.h
index 99e8f05f..7e282376 100644
--- a/src/rpc/protocol.h
+++ b/src/rpc/protocol.h
@@ -72,6 +72,7 @@ enum RPCErrorCode
RPC_VERIFY_ALREADY_IN_UTXO_SET = -27, //!< Transaction already in utxo set
RPC_IN_WARMUP = -28, //!< Client still warming up
RPC_METHOD_DEPRECATED = -32, //!< RPC method is deprecated
+ RPC_LIMIT_EXCEEDED = -37, //!< A bounded resource is currently at capacity
//! Aliases for backward compatibility
RPC_TRANSACTION_ERROR = RPC_VERIFY_ERROR,
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index 46ab8ea7..1279c658 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -396,7 +396,7 @@ RPCErrorCode RPCErrorFromTransactionError(TransactionError terr)
case TransactionError::ALREADY_IN_UTXO_SET:
return RPC_VERIFY_ALREADY_IN_UTXO_SET;
case TransactionError::PRIVATE_BROADCAST_FULL:
- return RPC_OUT_OF_MEMORY;
+ return RPC_LIMIT_EXCEEDED;
default: break;
}
return RPC_TRANSACTION_ERROR;
diff --git a/test/functional/p2p_private_broadcast_cap.py b/test/functional/p2p_private_broadcast_cap.py
index 154bf8b5..81f00a89 100755
--- a/test/functional/p2p_private_broadcast_cap.py
+++ b/test/functional/p2p_private_broadcast_cap.py
@@ -71,7 +71,7 @@ class PrivateBroadcastCapTest(BitcoinTestFramework):
# queue is left unchanged (nothing evicted to make room).
self.log.info(f"Submitting {OVER_CAP} more; each should be rejected (queue full)")
for child in children[MAX_TRANSACTIONS:]:
- assert_raises_rpc_error(-7, "Private broadcast queue is full",
+ assert_raises_rpc_error(-37, "Private broadcast queue is full",
node.sendrawtransaction, child["hex"])
assert_equal(pbinfo["transactions"], node.getprivatebroadcastinfo()["transactions"])
Why this scored 20/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.