Skip to content

Commit 5882c09

Browse files
committed
CreateTransaction: Don't return success with too-many-ancestor txn
1 parent 0b2294a commit 5882c09

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,6 +2555,21 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
25552555
}
25562556
}
25572557

2558+
if (GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS)) {
2559+
// Lastly, ensure this tx will pass the mempool's chain limits
2560+
LockPoints lp;
2561+
CTxMemPoolEntry entry(txNew, 0, 0, 0, 0, false, 0, false, 0, lp);
2562+
CTxMemPool::setEntries setAncestors;
2563+
size_t nLimitAncestors = GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
2564+
size_t nLimitAncestorSize = GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT)*1000;
2565+
size_t nLimitDescendants = GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
2566+
size_t nLimitDescendantSize = GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT)*1000;
2567+
std::string errString;
2568+
if (!mempool.CalculateMemPoolAncestors(entry, setAncestors, nLimitAncestors, nLimitAncestorSize, nLimitDescendants, nLimitDescendantSize, errString)) {
2569+
strFailReason = _("Transaction has too long of a mempool chain");
2570+
return false;
2571+
}
2572+
}
25582573
return true;
25592574
}
25602575

0 commit comments

Comments
 (0)