Skip to content

Commit 2f1a30c

Browse files
committed
Fix MAX_STANDARD_TX_WEIGHT check
As suggested by the constant name and its comment in policy.h, a transaction with a weight of exactly MAX_STANDARD_TX_WEIGHT should be allowed
1 parent 627c376 commit 2f1a30c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/net_processing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,10 @@ bool AddOrphanTx(const CTransactionRef& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRE
664664
// large transaction with a missing parent then we assume
665665
// it will rebroadcast it later, after the parent transaction(s)
666666
// have been mined or received.
667-
// 100 orphans, each of which is at most 99,999 bytes big is
667+
// 100 orphans, each of which is at most 100,000 bytes big is
668668
// at most 10 megabytes of orphans and somewhat more byprev index (in the worst case):
669669
unsigned int sz = GetTransactionWeight(*tx);
670-
if (sz >= MAX_STANDARD_TX_WEIGHT)
670+
if (sz > MAX_STANDARD_TX_WEIGHT)
671671
{
672672
LogPrint(BCLog::MEMPOOL, "ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString());
673673
return false;

src/policy/policy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnes
9191
// computing signature hashes is O(ninputs*txsize). Limiting transactions
9292
// to MAX_STANDARD_TX_WEIGHT mitigates CPU exhaustion attacks.
9393
unsigned int sz = GetTransactionWeight(tx);
94-
if (sz >= MAX_STANDARD_TX_WEIGHT) {
94+
if (sz > MAX_STANDARD_TX_WEIGHT) {
9595
reason = "tx-size";
9696
return false;
9797
}

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3053,7 +3053,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
30533053
tx = MakeTransactionRef(std::move(txNew));
30543054

30553055
// Limit size
3056-
if (GetTransactionWeight(*tx) >= MAX_STANDARD_TX_WEIGHT)
3056+
if (GetTransactionWeight(*tx) > MAX_STANDARD_TX_WEIGHT)
30573057
{
30583058
strFailReason = _("Transaction too large");
30593059
return false;

0 commit comments

Comments
 (0)