Skip to content

Commit a3af5b5

Browse files
author
MarcoFalke
committed
Merge #17138: Remove wallet access to some node arguments
b96ed03 [wallet] Remove pruning check for -rescan option (John Newbery) eea462d [wallet] Remove package limit config access from wallet (John Newbery) Pull request description: Removes wallet access to `-limitancestorcount`, `-limitdescendantcount` and `-prune`: - `-limitancestorcount` and `-limitdescendantcount` are now accessed with a method `getPackageLimits` in the `Chain` interface. - `-prune` is not required. It was only used in wallet component initiation to prevent running `-rescan` when pruning was enabled. This check is not required. Partially addresses #17137. ACKs for top commit: MarcoFalke: Tested ACK b96ed03 ryanofsky: Code review ACK b96ed03 promag: Code review ACK b96ed03. ariard: ACK b96ed03, check there isn't left anymore wallet access to node arguments. Tree-SHA512: 90c8e3e083acbd37724f1bccf63dab642cf9ae95cc5e684872a67443ae048b4fdbf57b52ea47c5a1da6489fd277278fe2d9bbe95e17f3d4965a1a0fbdeb815bf
2 parents e180be4 + b96ed03 commit a3af5b5

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
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/init.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ bool WalletInit::ParameterInteraction() const
122122

123123
if (gArgs.GetBoolArg("-sysperms", false))
124124
return InitError("-sysperms is not allowed in combination with enabled wallet functionality");
125-
if (gArgs.GetArg("-prune", 0) && gArgs.GetBoolArg("-rescan", false))
126-
return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again.").translated);
127125

128126
return true;
129127
}

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)