Skip to content

Commit 39bc2fa

Browse files
committed
wallet: Make WalletInitInterface and DummyWalletInit private
1 parent 5f0c6a7 commit 39bc2fa

File tree

9 files changed

+54
-85
lines changed

9 files changed

+54
-85
lines changed

src/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ BITCOIN_CORE_H = \
172172
wallet/db.h \
173173
wallet/feebumper.h \
174174
wallet/fees.h \
175-
wallet/init.h \
176175
wallet/rpcwallet.h \
177176
wallet/wallet.h \
178177
wallet/walletdb.h \

src/bitcoind.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
#include <httpserver.h>
1919
#include <httprpc.h>
2020
#include <utilstrencodings.h>
21-
#if ENABLE_WALLET
22-
#include <wallet/init.h>
23-
#endif
2421
#include <walletinitinterface.h>
2522

2623
#include <boost/thread.hpp>
@@ -63,12 +60,6 @@ bool AppInit(int argc, char* argv[])
6360
{
6461
bool fRet = false;
6562

66-
#if ENABLE_WALLET
67-
g_wallet_init_interface.reset(new WalletInit);
68-
#else
69-
g_wallet_init_interface.reset(new DummyWalletInit);
70-
#endif
71-
7263
//
7364
// Parameters
7465
//

src/init.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,24 @@ static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
7272

7373
std::unique_ptr<CConnman> g_connman;
7474
std::unique_ptr<PeerLogicValidation> peerLogic;
75-
std::unique_ptr<WalletInitInterface> g_wallet_init_interface;
75+
76+
#if !(ENABLE_WALLET)
77+
class DummyWalletInit : public WalletInitInterface {
78+
public:
79+
80+
std::string GetHelpString(bool showDebug) override {return std::string{};}
81+
bool ParameterInteraction() override {return true;}
82+
void RegisterRPC(CRPCTable &) override {}
83+
bool Verify() override {return true;}
84+
bool Open() override {return true;}
85+
void Start(CScheduler& scheduler) override {}
86+
void Flush() override {}
87+
void Stop() override {}
88+
void Close() override {}
89+
};
90+
91+
std::unique_ptr<WalletInitInterface> g_wallet_init_interface(new DummyWalletInit);
92+
#endif
7693

7794
#if ENABLE_ZMQ
7895
static CZMQNotificationInterface* pzmqNotificationInterface = nullptr;

src/qt/bitcoin.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
#include <util.h>
3636
#include <warnings.h>
3737

38-
#ifdef ENABLE_WALLET
39-
#include <wallet/init.h>
40-
#endif
4138
#include <walletinitinterface.h>
4239

4340
#include <memory>
@@ -660,11 +657,6 @@ int main(int argc, char *argv[])
660657
// Start up the payment server early, too, so impatient users that click on
661658
// bitcoin: links repeatedly have their payment requests routed to this process:
662659
app.createPaymentServer();
663-
664-
// Hook up the wallet init interface
665-
g_wallet_init_interface.reset(new WalletInit);
666-
#else
667-
g_wallet_init_interface.reset(new DummyWalletInit);
668660
#endif
669661

670662
/// 9. Main GUI initialization

src/wallet/init.cpp

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,51 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6-
#include <wallet/init.h>
7-
86
#include <chainparams.h>
97
#include <net.h>
108
#include <util.h>
119
#include <utilmoneystr.h>
1210
#include <validation.h>
11+
#include <walletinitinterface.h>
1312
#include <wallet/rpcwallet.h>
1413
#include <wallet/wallet.h>
1514
#include <wallet/walletutil.h>
1615

16+
class WalletInit : public WalletInitInterface {
17+
public:
18+
19+
//! Return the wallets help message.
20+
std::string GetHelpString(bool showDebug) override;
21+
22+
//! Wallets parameter interaction
23+
bool ParameterInteraction() override;
24+
25+
//! Register wallet RPCs.
26+
void RegisterRPC(CRPCTable &tableRPC) override;
27+
28+
//! Responsible for reading and validating the -wallet arguments and verifying the wallet database.
29+
// This function will perform salvage on the wallet if requested, as long as only one wallet is
30+
// being loaded (WalletParameterInteraction forbids -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet).
31+
bool Verify() override;
32+
33+
//! Load wallet databases.
34+
bool Open() override;
35+
36+
//! Complete startup of wallets.
37+
void Start(CScheduler& scheduler) override;
38+
39+
//! Flush all wallets in preparation for shutdown.
40+
void Flush() override;
41+
42+
//! Stop all wallets. Wallets will be flushed first.
43+
void Stop() override;
44+
45+
//! Close all wallets.
46+
void Close() override;
47+
};
48+
49+
std::unique_ptr<WalletInitInterface> g_wallet_init_interface(new WalletInit);
50+
1751
std::string WalletInit::GetHelpString(bool showDebug)
1852
{
1953
std::string strUsage = HelpMessageGroup(_("Wallet options:"));

src/wallet/init.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/wallet/rpcdump.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <key_io.h>
77
#include <rpc/safemode.h>
88
#include <rpc/server.h>
9-
#include <wallet/init.h>
109
#include <validation.h>
1110
#include <script/script.h>
1211
#include <script/standard.h>

src/wallet/wallet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <consensus/consensus.h>
1313
#include <consensus/validation.h>
1414
#include <fs.h>
15-
#include <wallet/init.h>
1615
#include <key.h>
1716
#include <key_io.h>
1817
#include <keystore.h>

src/walletinitinterface.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,4 @@ 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-
5137
#endif // BITCOIN_WALLETINITINTERFACE_H

0 commit comments

Comments
 (0)