43
43
#include < util.h>
44
44
#include < utilmoneystr.h>
45
45
#include < validationinterface.h>
46
- #ifdef ENABLE_WALLET
47
- #include < wallet/init.h>
48
- #endif
49
46
#include < warnings.h>
47
+ #include < walletinitinterface.h>
50
48
#include < stdint.h>
51
49
#include < stdio.h>
52
50
#include < memory>
@@ -74,6 +72,7 @@ static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
74
72
75
73
std::unique_ptr<CConnman> g_connman;
76
74
std::unique_ptr<PeerLogicValidation> peerLogic;
75
+ std::unique_ptr<WalletInitInterface> g_wallet_init_interface;
77
76
78
77
#if ENABLE_ZMQ
79
78
static CZMQNotificationInterface* pzmqNotificationInterface = nullptr ;
@@ -189,9 +188,9 @@ void Shutdown()
189
188
StopREST ();
190
189
StopRPC ();
191
190
StopHTTPServer ();
192
- # ifdef ENABLE_WALLET
193
- WalletInit:: Flush ();
194
- # endif
191
+ if (g_wallet_init_interface) {
192
+ g_wallet_init_interface-> Flush ();
193
+ }
195
194
StopMapPort ();
196
195
197
196
// Because these depend on each-other, we make sure that neither can be
@@ -249,9 +248,9 @@ void Shutdown()
249
248
pcoinsdbview.reset ();
250
249
pblocktree.reset ();
251
250
}
252
- # ifdef ENABLE_WALLET
253
- WalletInit:: Stop ();
254
- # endif
251
+ if (g_wallet_init_interface) {
252
+ g_wallet_init_interface-> Stop ();
253
+ }
255
254
256
255
#if ENABLE_ZMQ
257
256
if (pzmqNotificationInterface) {
@@ -271,9 +270,10 @@ void Shutdown()
271
270
UnregisterAllValidationInterfaces ();
272
271
GetMainSignals ().UnregisterBackgroundSignalScheduler ();
273
272
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 ();
277
277
globalVerifyHandle.reset ();
278
278
ECC_Stop ();
279
279
LogPrintf (" %s: done\n " , __func__);
@@ -415,9 +415,9 @@ std::string HelpMessage(HelpMessageMode mode)
415
415
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." ) +
416
416
" " + _ (" 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" ));
417
417
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
+ }
421
421
422
422
#if ENABLE_ZMQ
423
423
strUsage += HelpMessageGroup (_ (" ZeroMQ notification options:" ));
@@ -1091,9 +1091,7 @@ bool AppInitParameterInteraction()
1091
1091
return InitError (strprintf (" acceptnonstdtxn is not currently supported for %s chain" , chainparams.NetworkIDString ()));
1092
1092
nBytesPerSigOp = gArgs .GetArg (" -bytespersigop" , nBytesPerSigOp);
1093
1093
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 ;
1097
1095
1098
1096
fIsBareMultisigStd = gArgs .GetBoolArg (" -permitbaremultisig" , DEFAULT_PERMIT_BAREMULTISIG);
1099
1097
fAcceptDatacarrier = gArgs .GetBoolArg (" -datacarrier" , DEFAULT_ACCEPT_DATACARRIER);
@@ -1256,9 +1254,9 @@ bool AppInitMain()
1256
1254
* available in the GUI RPC console even if external calls are disabled.
1257
1255
*/
1258
1256
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
+ }
1262
1260
1263
1261
/* Start the RPC server already. It will be started in "warmup" mode
1264
1262
* and not really process calls already (but it will signify connections
@@ -1275,9 +1273,8 @@ bool AppInitMain()
1275
1273
int64_t nStart;
1276
1274
1277
1275
// ********************************************************* 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
+
1281
1278
// ********************************************************* Step 6: network initialization
1282
1279
// Note that we absolutely cannot open any actual connections
1283
1280
// until the very end ("start node") as the UTXO/block state
@@ -1595,11 +1592,7 @@ bool AppInitMain()
1595
1592
fFeeEstimatesInitialized = true ;
1596
1593
1597
1594
// ********************************************************* 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 ;
1603
1596
1604
1597
// ********************************************************* Step 9: data directory maintenance
1605
1598
@@ -1745,9 +1738,9 @@ bool AppInitMain()
1745
1738
SetRPCWarmupFinished ();
1746
1739
uiInterface.InitMessage (_ (" Done loading" ));
1747
1740
1748
- # ifdef ENABLE_WALLET
1749
- WalletInit:: Start (scheduler);
1750
- # endif
1741
+ if (g_wallet_init_interface) {
1742
+ g_wallet_init_interface-> Start (scheduler);
1743
+ }
1751
1744
1752
1745
return true ;
1753
1746
}
0 commit comments