2023-04-25 13:51:26 +02:00
|
|
|
// Copyright (c) 2018-2020 The Bitcoin Core developers
|
2021-08-05 16:41:46 +02:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include <logging.h>
|
|
|
|
#include <util/system.h>
|
|
|
|
#include <walletinitinterface.h>
|
|
|
|
|
2021-08-10 07:48:49 +02:00
|
|
|
class CWallet;
|
|
|
|
|
2019-02-12 19:19:05 +01:00
|
|
|
namespace interfaces {
|
|
|
|
class Chain;
|
2019-09-27 13:31:44 +02:00
|
|
|
class Handler;
|
|
|
|
class Wallet;
|
2019-02-12 19:19:05 +01:00
|
|
|
}
|
|
|
|
|
2021-08-05 16:41:46 +02:00
|
|
|
class DummyWalletInit : public WalletInitInterface {
|
|
|
|
public:
|
|
|
|
|
|
|
|
bool HasWalletSupport() const override {return false;}
|
2022-05-21 10:27:30 +02:00
|
|
|
void AddWalletOptions(ArgsManager& argsman) const override;
|
2021-08-05 16:41:46 +02:00
|
|
|
bool ParameterInteraction() const override {return true;}
|
2022-04-05 11:09:41 +02:00
|
|
|
void Construct(NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");}
|
2021-08-05 16:41:46 +02:00
|
|
|
|
|
|
|
// Dash Specific WalletInitInterface InitCoinJoinSettings
|
|
|
|
void AutoLockMasternodeCollaterals() const override {}
|
refactor: subsume CoinJoin objects under CJContext, deglobalize coinJoin{ClientQueueManager,Server} (#5337)
## Motivation
CoinJoin's subsystems are initialized by variables and managers that
occupy the global context. The _extent_ to which these subsystems
entrench themselves into the codebase is difficult to assess and moving
them out of the global context forces us to enumerate the subsystems in
the codebase that rely on CoinJoin logic and enumerate the order in
which components are initialized and destroyed.
Keeping this in mind, the scope of this pull request aims to:
* Reduce the amount of CoinJoin-specific entities present in the global
scope
* Make the remaining usage of these entities in the global scope
explicit and easily searchable
## Additional Information
* The initialization of `CCoinJoinClientQueueManager` is dependent on
blocks-only mode being disabled (which can be alternatively interpreted
as enabling the relay of transactions). The same applies to
`CBlockPolicyEstimator`, which `CCoinJoinClientQueueManager` depends.
Therefore, `CCoinJoinClientQueueManager` is only initialized if
transaction relaying is enabled and so is its scheduled maintenance
task. This can be found by looking at `init.cpp`
[here](https://github.com/dashpay/dash/blob/93f8df1c31fdce6a14f149acfdff22678c3f22ca/src/init.cpp#L1681-L1683),
[here](https://github.com/dashpay/dash/blob/93f8df1c31fdce6a14f149acfdff22678c3f22ca/src/init.cpp#L2253-L2255)
and
[here](https://github.com/dashpay/dash/blob/93f8df1c31fdce6a14f149acfdff22678c3f22ca/src/init.cpp#L2326-L2327).
For this reason, `CBlockPolicyEstimator` is not a member of `CJContext`
and its usage is fulfilled by passing it as a reference when
initializing the scheduling task.
* `CJClientManager` has not used `CConnman` or `CTxMemPool` as `const`
as existing code that is outside the scope of this PR would cast away
constness, which would be unacceptable. Furthermore, some logical paths
are taken that will grind to a halt if they are stored as `const`.
Examples of such a call chains would be:
* `CJClientManager::DoMaintenance >
CCoinJoinClientManager::DoMaintenance > DoAutomaticDenominating >
CCoinJoinClientSession::DoAutomaticDenominating >
CCoinJoinClientSession::StartNewQueue > CConnman::AddPendingMasternode`
which modifies `CConnman::vPendingMasternodes`, which is non-const
behaviour
* `CJClientManager::DoMaintenance >
CCoinJoinClientManager::DoMaintenance > DoAutomaticDenominating >
CCoinJoin::IsCollateralValid > AcceptToMemoryPool` which adds a
transaction to the memory pool, which is non-const behaviour
* There were cppcheck [linter
failures](https://github.com/dashpay/dash/pull/5337#issuecomment-1685084688)
that seemed to be caused by the usage of `Assert` in
`coinjoin/client.h`. This seems to be resolved by backporting
[bitcoin#24714](https://github.com/bitcoin/bitcoin/pull/24714). (Thanks
@knst!)
* Depends on #5546
---------
Co-authored-by: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com>
Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
2023-09-13 19:52:38 +02:00
|
|
|
void InitCoinJoinSettings(const CJClientManager& clientman) const override {}
|
2021-08-05 16:41:46 +02:00
|
|
|
bool InitAutoBackup() const override {return true;}
|
|
|
|
};
|
|
|
|
|
2022-05-21 10:27:30 +02:00
|
|
|
void DummyWalletInit::AddWalletOptions(ArgsManager& argsman) const
|
2021-08-05 16:41:46 +02:00
|
|
|
{
|
2022-05-21 10:27:30 +02:00
|
|
|
argsman.AddHiddenArgs({
|
2019-04-29 14:45:44 +02:00
|
|
|
"-avoidpartialspends",
|
|
|
|
"-createwalletbackups=<n>",
|
|
|
|
"-disablewallet",
|
|
|
|
"-instantsendnotify=<cmd>",
|
|
|
|
"-keypool=<n>",
|
2021-12-12 14:38:12 +01:00
|
|
|
"-maxtxfee=<amt>",
|
2019-04-29 14:45:44 +02:00
|
|
|
"-rescan=<mode>",
|
|
|
|
"-salvagewallet",
|
|
|
|
"-spendzeroconfchange",
|
|
|
|
"-wallet=<path>",
|
|
|
|
"-walletbackupsdir=<dir>",
|
|
|
|
"-walletbroadcast",
|
|
|
|
"-walletdir=<dir>",
|
|
|
|
"-walletnotify=<cmd>",
|
|
|
|
"-discardfee=<amt>",
|
|
|
|
"-fallbackfee=<amt>",
|
|
|
|
"-mintxfee=<amt>",
|
|
|
|
"-paytxfee=<amt>",
|
|
|
|
"-txconfirmtarget=<n>",
|
|
|
|
"-hdseed=<hex>",
|
|
|
|
"-mnemonic=<text>",
|
|
|
|
"-mnemonicpassphrase=<text>",
|
|
|
|
"-usehd",
|
|
|
|
"-enablecoinjoin",
|
|
|
|
"-coinjoinamount=<n>",
|
|
|
|
"-coinjoinautostart",
|
|
|
|
"-coinjoindenomsgoal=<n>",
|
|
|
|
"-coinjoindenomshardcap=<n>",
|
|
|
|
"-coinjoinmultisession",
|
|
|
|
"-coinjoinrounds=<n>",
|
|
|
|
"-coinjoinsessions=<n>",
|
|
|
|
"-dblogsize=<n>",
|
|
|
|
"-flushwallet",
|
|
|
|
"-privdb",
|
2021-04-08 02:55:09 +02:00
|
|
|
"-walletrejectlongchains",
|
|
|
|
"-unsafesqlitesync"
|
2019-04-29 14:45:44 +02:00
|
|
|
});
|
2021-08-05 16:41:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
|
2021-08-10 07:48:49 +02:00
|
|
|
|
2019-09-27 13:31:44 +02:00
|
|
|
namespace interfaces {
|
2021-08-10 07:48:49 +02:00
|
|
|
|
refactor: subsume CoinJoin objects under CJContext, deglobalize coinJoin{ClientQueueManager,Server} (#5337)
## Motivation
CoinJoin's subsystems are initialized by variables and managers that
occupy the global context. The _extent_ to which these subsystems
entrench themselves into the codebase is difficult to assess and moving
them out of the global context forces us to enumerate the subsystems in
the codebase that rely on CoinJoin logic and enumerate the order in
which components are initialized and destroyed.
Keeping this in mind, the scope of this pull request aims to:
* Reduce the amount of CoinJoin-specific entities present in the global
scope
* Make the remaining usage of these entities in the global scope
explicit and easily searchable
## Additional Information
* The initialization of `CCoinJoinClientQueueManager` is dependent on
blocks-only mode being disabled (which can be alternatively interpreted
as enabling the relay of transactions). The same applies to
`CBlockPolicyEstimator`, which `CCoinJoinClientQueueManager` depends.
Therefore, `CCoinJoinClientQueueManager` is only initialized if
transaction relaying is enabled and so is its scheduled maintenance
task. This can be found by looking at `init.cpp`
[here](https://github.com/dashpay/dash/blob/93f8df1c31fdce6a14f149acfdff22678c3f22ca/src/init.cpp#L1681-L1683),
[here](https://github.com/dashpay/dash/blob/93f8df1c31fdce6a14f149acfdff22678c3f22ca/src/init.cpp#L2253-L2255)
and
[here](https://github.com/dashpay/dash/blob/93f8df1c31fdce6a14f149acfdff22678c3f22ca/src/init.cpp#L2326-L2327).
For this reason, `CBlockPolicyEstimator` is not a member of `CJContext`
and its usage is fulfilled by passing it as a reference when
initializing the scheduling task.
* `CJClientManager` has not used `CConnman` or `CTxMemPool` as `const`
as existing code that is outside the scope of this PR would cast away
constness, which would be unacceptable. Furthermore, some logical paths
are taken that will grind to a halt if they are stored as `const`.
Examples of such a call chains would be:
* `CJClientManager::DoMaintenance >
CCoinJoinClientManager::DoMaintenance > DoAutomaticDenominating >
CCoinJoinClientSession::DoAutomaticDenominating >
CCoinJoinClientSession::StartNewQueue > CConnman::AddPendingMasternode`
which modifies `CConnman::vPendingMasternodes`, which is non-const
behaviour
* `CJClientManager::DoMaintenance >
CCoinJoinClientManager::DoMaintenance > DoAutomaticDenominating >
CCoinJoin::IsCollateralValid > AcceptToMemoryPool` which adds a
transaction to the memory pool, which is non-const behaviour
* There were cppcheck [linter
failures](https://github.com/dashpay/dash/pull/5337#issuecomment-1685084688)
that seemed to be caused by the usage of `Assert` in
`coinjoin/client.h`. This seems to be resolved by backporting
[bitcoin#24714](https://github.com/bitcoin/bitcoin/pull/24714). (Thanks
@knst!)
* Depends on #5546
---------
Co-authored-by: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com>
Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
2023-09-13 19:52:38 +02:00
|
|
|
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet, const CJClientManager& clientman)
|
2021-08-10 07:48:49 +02:00
|
|
|
{
|
|
|
|
throw std::logic_error("Wallet function called in non-wallet build.");
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace interfaces
|