Skip to content

Commit c7ec524

Browse files
committed
[wallet] Add dummy wallet init class
1 parent 49baa4a commit c7ec524

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

src/bitcoind.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include <utilstrencodings.h>
2121
#if ENABLE_WALLET
2222
#include <wallet/init.h>
23-
#include <walletinitinterface.h>
2423
#endif
24+
#include <walletinitinterface.h>
2525

2626
#include <boost/thread.hpp>
2727

@@ -65,6 +65,8 @@ bool AppInit(int argc, char* argv[])
6565

6666
#if ENABLE_WALLET
6767
g_wallet_init_interface.reset(new WalletInit);
68+
#else
69+
g_wallet_init_interface.reset(new DummyWalletInit);
6870
#endif
6971

7072
//

src/init.cpp

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ void Shutdown()
188188
StopREST();
189189
StopRPC();
190190
StopHTTPServer();
191-
if (g_wallet_init_interface) {
192-
g_wallet_init_interface->Flush();
193-
}
191+
g_wallet_init_interface->Flush();
194192
StopMapPort();
195193

196194
// Because these depend on each-other, we make sure that neither can be
@@ -248,9 +246,7 @@ void Shutdown()
248246
pcoinsdbview.reset();
249247
pblocktree.reset();
250248
}
251-
if (g_wallet_init_interface) {
252-
g_wallet_init_interface->Stop();
253-
}
249+
g_wallet_init_interface->Stop();
254250

255251
#if ENABLE_ZMQ
256252
if (pzmqNotificationInterface) {
@@ -270,9 +266,7 @@ void Shutdown()
270266
UnregisterAllValidationInterfaces();
271267
GetMainSignals().UnregisterBackgroundSignalScheduler();
272268
GetMainSignals().UnregisterWithMempoolSignals(mempool);
273-
if (g_wallet_init_interface) {
274-
g_wallet_init_interface->Close();
275-
}
269+
g_wallet_init_interface->Close();
276270
g_wallet_init_interface.reset();
277271
globalVerifyHandle.reset();
278272
ECC_Stop();
@@ -415,9 +409,7 @@ std::string HelpMessage(HelpMessageMode mode)
415409
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.") +
416410
" " + _("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"));
417411

418-
if (g_wallet_init_interface) {
419-
strUsage += g_wallet_init_interface->GetHelpString(showDebug);
420-
}
412+
strUsage += g_wallet_init_interface->GetHelpString(showDebug);
421413

422414
#if ENABLE_ZMQ
423415
strUsage += HelpMessageGroup(_("ZeroMQ notification options:"));
@@ -1091,7 +1083,7 @@ bool AppInitParameterInteraction()
10911083
return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));
10921084
nBytesPerSigOp = gArgs.GetArg("-bytespersigop", nBytesPerSigOp);
10931085

1094-
if (g_wallet_init_interface && !g_wallet_init_interface->ParameterInteraction()) return false;
1086+
if (!g_wallet_init_interface->ParameterInteraction()) return false;
10951087

10961088
fIsBareMultisigStd = gArgs.GetBoolArg("-permitbaremultisig", DEFAULT_PERMIT_BAREMULTISIG);
10971089
fAcceptDatacarrier = gArgs.GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER);
@@ -1254,9 +1246,7 @@ bool AppInitMain()
12541246
* available in the GUI RPC console even if external calls are disabled.
12551247
*/
12561248
RegisterAllCoreRPCCommands(tableRPC);
1257-
if (g_wallet_init_interface) {
1258-
g_wallet_init_interface->RegisterRPC(tableRPC);
1259-
}
1249+
g_wallet_init_interface->RegisterRPC(tableRPC);
12601250

12611251
/* Start the RPC server already. It will be started in "warmup" mode
12621252
* and not really process calls already (but it will signify connections
@@ -1273,7 +1263,7 @@ bool AppInitMain()
12731263
int64_t nStart;
12741264

12751265
// ********************************************************* Step 5: verify wallet database integrity
1276-
if (g_wallet_init_interface && !g_wallet_init_interface->Verify()) return false;
1266+
if (!g_wallet_init_interface->Verify()) return false;
12771267

12781268
// ********************************************************* Step 6: network initialization
12791269
// Note that we absolutely cannot open any actual connections
@@ -1592,7 +1582,7 @@ bool AppInitMain()
15921582
fFeeEstimatesInitialized = true;
15931583

15941584
// ********************************************************* Step 8: load wallet
1595-
if (g_wallet_init_interface && !g_wallet_init_interface->Open()) return false;
1585+
if (!g_wallet_init_interface->Open()) return false;
15961586

15971587
// ********************************************************* Step 9: data directory maintenance
15981588

@@ -1738,9 +1728,7 @@ bool AppInitMain()
17381728
SetRPCWarmupFinished();
17391729
uiInterface.InitMessage(_("Done loading"));
17401730

1741-
if (g_wallet_init_interface) {
1742-
g_wallet_init_interface->Start(scheduler);
1743-
}
1731+
g_wallet_init_interface->Start(scheduler);
17441732

17451733
return true;
17461734
}

src/qt/bitcoin.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#ifdef ENABLE_WALLET
3636
#include <wallet/init.h>
3737
#include <wallet/wallet.h>
38-
#include <walletinitinterface.h>
3938
#endif
39+
#include <walletinitinterface.h>
4040

4141
#include <stdint.h>
4242

@@ -674,6 +674,8 @@ int main(int argc, char *argv[])
674674

675675
// Hook up the wallet init interface
676676
g_wallet_init_interface.reset(new WalletInit);
677+
#else
678+
g_wallet_init_interface.reset(new DummyWalletInit);
677679
#endif
678680

679681
/// 9. Main GUI initialization

src/walletinitinterface.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,18 @@ class WalletInitInterface {
3434
virtual ~WalletInitInterface() {}
3535
};
3636

37+
class DummyWalletInit : public WalletInitInterface {
38+
public:
39+
40+
std::string GetHelpString(bool showDebug) override {return std::string{};}
41+
bool ParameterInteraction() override {return true;}
42+
void RegisterRPC(CRPCTable &) override {}
43+
bool Verify() override {return true;}
44+
bool Open() override {return true;}
45+
void Start(CScheduler& scheduler) override {}
46+
void Flush() override {}
47+
void Stop() override {}
48+
void Close() override {}
49+
};
50+
3751
#endif // WALLETINITINTERFACE_H

0 commit comments

Comments
 (0)