Skip to content

Commit eea462d

Browse files
committed
[wallet] Remove package limit config access from wallet
The wallet should not be able to directly access global configuration from the node. Remove access of "-limitancestorcount" and "-limitdescendantcount".
1 parent b33c03b commit eea462d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/interfaces/chain.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ class ChainImpl : public Chain
298298
{
299299
::mempool.GetTransactionAncestry(txid, ancestors, descendants);
300300
}
301+
void getPackageLimits(unsigned int& limit_ancestor_count, unsigned int& limit_descendant_count) override
302+
{
303+
limit_ancestor_count = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
304+
limit_descendant_count = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
305+
}
301306
bool checkChainLimits(const CTransactionRef& tx) override
302307
{
303308
LockPoints lp;

src/interfaces/chain.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ class Chain
163163
//! Calculate mempool ancestor and descendant counts for the given transaction.
164164
virtual void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) = 0;
165165

166+
//! Get the node's package limits.
167+
//! Currently only returns the ancestor and descendant count limits, but could be enhanced to
168+
//! return more policy settings.
169+
virtual void getPackageLimits(unsigned int& limit_ancestor_count, unsigned int& limit_descendant_count) = 0;
170+
166171
//! Check if transaction will pass the mempool's chain limits.
167172
virtual bool checkChainLimits(const CTransactionRef& tx) = 0;
168173

src/wallet/wallet.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <util/rbf.h>
2828
#include <util/translation.h>
2929
#include <util/validation.h>
30-
#include <validation.h>
3130
#include <wallet/coincontrol.h>
3231
#include <wallet/fees.h>
3332

@@ -2739,8 +2738,11 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
27392738
}
27402739
std::vector<OutputGroup> groups = GroupOutputs(vCoins, !coin_control.m_avoid_partial_spends);
27412740

2742-
size_t max_ancestors = (size_t)std::max<int64_t>(1, gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT));
2743-
size_t max_descendants = (size_t)std::max<int64_t>(1, gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT));
2741+
unsigned int limit_ancestor_count;
2742+
unsigned int limit_descendant_count;
2743+
chain().getPackageLimits(limit_ancestor_count, limit_descendant_count);
2744+
size_t max_ancestors = (size_t)std::max<int64_t>(1, limit_ancestor_count);
2745+
size_t max_descendants = (size_t)std::max<int64_t>(1, limit_descendant_count);
27442746
bool fRejectLongChains = gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS);
27452747

27462748
bool res = nTargetValue <= nValueFromPresetInputs ||

0 commit comments

Comments
 (0)