4343#include < util.h>
4444#include < utilmoneystr.h>
4545#include < validationinterface.h>
46- #ifdef ENABLE_WALLET
47- #include < wallet/init.h>
48- #endif
4946#include < warnings.h>
47+ #include < walletinitinterface.h>
5048#include < stdint.h>
5149#include < stdio.h>
5250#include < memory>
@@ -74,6 +72,7 @@ static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
7472
7573std::unique_ptr<CConnman> g_connman;
7674std::unique_ptr<PeerLogicValidation> peerLogic;
75+ std::unique_ptr<WalletInitInterface> g_wallet_init_interface;
7776
7877#if ENABLE_ZMQ
7978static CZMQNotificationInterface* pzmqNotificationInterface = nullptr ;
@@ -189,9 +188,9 @@ void Shutdown()
189188 StopREST ();
190189 StopRPC ();
191190 StopHTTPServer ();
192- # ifdef ENABLE_WALLET
193- WalletInit:: Flush ();
194- # endif
191+ if (g_wallet_init_interface) {
192+ g_wallet_init_interface-> Flush ();
193+ }
195194 StopMapPort ();
196195
197196 // Because these depend on each-other, we make sure that neither can be
@@ -249,9 +248,9 @@ void Shutdown()
249248 pcoinsdbview.reset ();
250249 pblocktree.reset ();
251250 }
252- # ifdef ENABLE_WALLET
253- WalletInit:: Stop ();
254- # endif
251+ if (g_wallet_init_interface) {
252+ g_wallet_init_interface-> Stop ();
253+ }
255254
256255#if ENABLE_ZMQ
257256 if (pzmqNotificationInterface) {
@@ -271,9 +270,10 @@ void Shutdown()
271270 UnregisterAllValidationInterfaces ();
272271 GetMainSignals ().UnregisterBackgroundSignalScheduler ();
273272 GetMainSignals ().UnregisterWithMempoolSignals (mempool);
274- #ifdef ENABLE_WALLET
275- WalletInit::Close ();
276- #endif
273+ if (g_wallet_init_interface) {
274+ g_wallet_init_interface->Close ();
275+ }
276+ g_wallet_init_interface.reset ();
277277 globalVerifyHandle.reset ();
278278 ECC_Stop ();
279279 LogPrintf (" %s: done\n " , __func__);
@@ -415,9 +415,9 @@ std::string HelpMessage(HelpMessageMode mode)
415415 strUsage += HelpMessageOpt (" -whitelist=<IP address or network>" , _ (" Whitelist peers connecting from the given IP address (e.g. 1.2.3.4) or CIDR notated network (e.g. 1.2.3.0/24). Can be specified multiple times." ) +
416416 " " + _ (" Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e.g. for a gateway" ));
417417
418- # ifdef ENABLE_WALLET
419- strUsage += WalletInit:: GetHelpString (showDebug);
420- # endif
418+ if (g_wallet_init_interface) {
419+ strUsage += g_wallet_init_interface-> GetHelpString (showDebug);
420+ }
421421
422422#if ENABLE_ZMQ
423423 strUsage += HelpMessageGroup (_ (" ZeroMQ notification options:" ));
@@ -1091,9 +1091,7 @@ bool AppInitParameterInteraction()
10911091 return InitError (strprintf (" acceptnonstdtxn is not currently supported for %s chain" , chainparams.NetworkIDString ()));
10921092 nBytesPerSigOp = gArgs .GetArg (" -bytespersigop" , nBytesPerSigOp);
10931093
1094- #ifdef ENABLE_WALLET
1095- if (!WalletInit::ParameterInteraction ()) return false ;
1096- #endif
1094+ if (g_wallet_init_interface && !g_wallet_init_interface->ParameterInteraction ()) return false ;
10971095
10981096 fIsBareMultisigStd = gArgs .GetBoolArg (" -permitbaremultisig" , DEFAULT_PERMIT_BAREMULTISIG);
10991097 fAcceptDatacarrier = gArgs .GetBoolArg (" -datacarrier" , DEFAULT_ACCEPT_DATACARRIER);
@@ -1256,9 +1254,9 @@ bool AppInitMain()
12561254 * available in the GUI RPC console even if external calls are disabled.
12571255 */
12581256 RegisterAllCoreRPCCommands (tableRPC);
1259- # ifdef ENABLE_WALLET
1260- WalletInit:: RegisterRPC (tableRPC);
1261- # endif
1257+ if (g_wallet_init_interface) {
1258+ g_wallet_init_interface-> RegisterRPC (tableRPC);
1259+ }
12621260
12631261 /* Start the RPC server already. It will be started in "warmup" mode
12641262 * and not really process calls already (but it will signify connections
@@ -1275,9 +1273,8 @@ bool AppInitMain()
12751273 int64_t nStart;
12761274
12771275 // ********************************************************* Step 5: verify wallet database integrity
1278- #ifdef ENABLE_WALLET
1279- if (!WalletInit::Verify ()) return false ;
1280- #endif
1276+ if (g_wallet_init_interface && !g_wallet_init_interface->Verify ()) return false ;
1277+
12811278 // ********************************************************* Step 6: network initialization
12821279 // Note that we absolutely cannot open any actual connections
12831280 // until the very end ("start node") as the UTXO/block state
@@ -1595,11 +1592,7 @@ bool AppInitMain()
15951592 fFeeEstimatesInitialized = true ;
15961593
15971594 // ********************************************************* Step 8: load wallet
1598- #ifdef ENABLE_WALLET
1599- if (!WalletInit::Open ()) return false ;
1600- #else
1601- LogPrintf (" No wallet support compiled in!\n " );
1602- #endif
1595+ if (g_wallet_init_interface && !g_wallet_init_interface->Open ()) return false ;
16031596
16041597 // ********************************************************* Step 9: data directory maintenance
16051598
@@ -1745,9 +1738,9 @@ bool AppInitMain()
17451738 SetRPCWarmupFinished ();
17461739 uiInterface.InitMessage (_ (" Done loading" ));
17471740
1748- # ifdef ENABLE_WALLET
1749- WalletInit:: Start (scheduler);
1750- # endif
1741+ if (g_wallet_init_interface) {
1742+ g_wallet_init_interface-> Start (scheduler);
1743+ }
17511744
17521745 return true ;
17531746}
0 commit comments