diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -176,6 +176,12 @@ virtual void getTransactionAncestry(const TxId &txid, size_t &ancestors, size_t &descendants) = 0; + //! Get the node's package limits. + //! Currently only returns the ancestor and descendant count limits, but + //! could be enhanced to return more policy settings. + virtual void getPackageLimits(size_t &limit_ancestor_count, + size_t &limit_descendant_count) = 0; + //! Check if transaction will pass the mempool's chain limits. virtual bool checkChainLimits(const CTransactionRef &tx) = 0; diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -312,6 +312,15 @@ size_t &descendants) override { ::g_mempool.GetTransactionAncestry(txid, ancestors, descendants); } + void getPackageLimits(size_t &limit_ancestor_count, + size_t &limit_descendant_count) override { + limit_ancestor_count = size_t( + std::max(1, gArgs.GetArg("-limitancestorcount", + DEFAULT_ANCESTOR_LIMIT))); + limit_descendant_count = size_t( + std::max(1, gArgs.GetArg("-limitdescendantcount", + DEFAULT_DESCENDANT_LIMIT))); + } bool checkChainLimits(const CTransactionRef &tx) override { LockPoints lp; CTxMemPoolEntry entry(tx, Amount(), 0, 0, false, 0, lp); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -3053,10 +3052,9 @@ std::vector groups = GroupOutputs(vCoins, !coin_control.m_avoid_partial_spends); - size_t max_ancestors = std::max( - 1, gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT)); - size_t max_descendants = std::max( - 1, gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT)); + size_t max_ancestors{0}; + size_t max_descendants{0}; + chain().getPackageLimits(max_ancestors, max_descendants); bool fRejectLongChains = gArgs.GetBoolArg( "-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS);