aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/init.cpp40
-rw-r--r--src/wallet/init.h48
-rw-r--r--src/wallet/rpcdump.cpp1
-rw-r--r--src/wallet/wallet.cpp1
-rw-r--r--src/wallet/wallet.h49
5 files changed, 53 insertions, 86 deletions
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
index 3d7bb674f0..c860eede05 100644
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -3,17 +3,53 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <wallet/init.h>
-
#include <chainparams.h>
+#include <init.h>
#include <net.h>
#include <util.h>
#include <utilmoneystr.h>
#include <validation.h>
+#include <walletinitinterface.h>
#include <wallet/rpcwallet.h>
#include <wallet/wallet.h>
#include <wallet/walletutil.h>
+class WalletInit : public WalletInitInterface {
+public:
+
+ //! Return the wallets help message.
+ std::string GetHelpString(bool showDebug) override;
+
+ //! Wallets parameter interaction
+ bool ParameterInteraction() override;
+
+ //! Register wallet RPCs.
+ void RegisterRPC(CRPCTable &tableRPC) override;
+
+ //! Responsible for reading and validating the -wallet arguments and verifying the wallet database.
+ // This function will perform salvage on the wallet if requested, as long as only one wallet is
+ // being loaded (WalletParameterInteraction forbids -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet).
+ bool Verify() override;
+
+ //! Load wallet databases.
+ bool Open() override;
+
+ //! Complete startup of wallets.
+ void Start(CScheduler& scheduler) override;
+
+ //! Flush all wallets in preparation for shutdown.
+ void Flush() override;
+
+ //! Stop all wallets. Wallets will be flushed first.
+ void Stop() override;
+
+ //! Close all wallets.
+ void Close() override;
+};
+
+static WalletInit g_wallet_init;
+WalletInitInterface* const g_wallet_init_interface = &g_wallet_init;
+
std::string WalletInit::GetHelpString(bool showDebug)
{
std::string strUsage = HelpMessageGroup(_("Wallet options:"));
diff --git a/src/wallet/init.h b/src/wallet/init.h
deleted file mode 100644
index f8be90d3e3..0000000000
--- a/src/wallet/init.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2017 The Bitcoin Core developers
-// Distributed under the MIT software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
-#ifndef BITCOIN_WALLET_INIT_H
-#define BITCOIN_WALLET_INIT_H
-
-#include <walletinitinterface.h>
-#include <string>
-
-class CRPCTable;
-class CScheduler;
-
-class WalletInit : public WalletInitInterface {
-public:
-
- //! Return the wallets help message.
- std::string GetHelpString(bool showDebug) override;
-
- //! Wallets parameter interaction
- bool ParameterInteraction() override;
-
- //! Register wallet RPCs.
- void RegisterRPC(CRPCTable &tableRPC) override;
-
- //! Responsible for reading and validating the -wallet arguments and verifying the wallet database.
- // This function will perform salvage on the wallet if requested, as long as only one wallet is
- // being loaded (WalletParameterInteraction forbids -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet).
- bool Verify() override;
-
- //! Load wallet databases.
- bool Open() override;
-
- //! Complete startup of wallets.
- void Start(CScheduler& scheduler) override;
-
- //! Flush all wallets in preparation for shutdown.
- void Flush() override;
-
- //! Stop all wallets. Wallets will be flushed first.
- void Stop() override;
-
- //! Close all wallets.
- void Close() override;
-};
-
-#endif // BITCOIN_WALLET_INIT_H
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index 3f88c62c61..a3594aa692 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -6,7 +6,6 @@
#include <key_io.h>
#include <rpc/safemode.h>
#include <rpc/server.h>
-#include <wallet/init.h>
#include <validation.h>
#include <script/script.h>
#include <script/standard.h>
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index dbc1760c80..8dac547abb 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -12,7 +12,6 @@
#include <consensus/consensus.h>
#include <consensus/validation.h>
#include <fs.h>
-#include <wallet/init.h>
#include <key.h>
#include <key_io.h>
#include <keystore.h>
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 898c32c708..22a0ac2924 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -661,22 +661,22 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
{
private:
static std::atomic<bool> fFlushScheduled;
- std::atomic<bool> fAbortRescan;
- std::atomic<bool> fScanningWallet; //controlled by WalletRescanReserver
+ std::atomic<bool> fAbortRescan{false};
+ std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
std::mutex mutexScanning;
friend class WalletRescanReserver;
- CWalletDB *pwalletdbEncryption;
+ CWalletDB *pwalletdbEncryption = nullptr;
//! the current wallet version: clients below this version are not able to load the wallet
- int nWalletVersion;
+ int nWalletVersion = FEATURE_BASE;
//! the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
- int nWalletMaxVersion;
+ int nWalletMaxVersion = FEATURE_BASE;
- int64_t nNextResend;
- int64_t nLastResend;
- bool fBroadcastTransactions;
+ int64_t nNextResend = 0;
+ int64_t nLastResend = 0;
+ bool fBroadcastTransactions = false;
/**
* Used to keep track of spent outpoints, and
@@ -705,10 +705,10 @@ private:
std::set<int64_t> setInternalKeyPool;
std::set<int64_t> setExternalKeyPool;
- int64_t m_max_keypool_index;
+ int64_t m_max_keypool_index = 0;
std::map<CKeyID, int64_t> m_pool_key_to_index;
- int64_t nTimeFirstKey;
+ int64_t nTimeFirstKey = 0;
/**
* Private version of AddWatchOnly method which does not accept a
@@ -741,7 +741,7 @@ private:
*
* Protected by cs_main (see BlockUntilSyncedToCurrentChain)
*/
- const CBlockIndex* m_last_block_processed;
+ const CBlockIndex* m_last_block_processed = nullptr;
public:
/*
@@ -780,12 +780,11 @@ public:
typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
MasterKeyMap mapMasterKeys;
- unsigned int nMasterKeyMaxID;
+ unsigned int nMasterKeyMaxID = 0;
/** Construct wallet with specified name and database implementation. */
CWallet(std::string name, std::unique_ptr<CWalletDBWrapper> dbw) : m_name(std::move(name)), dbw(std::move(dbw))
{
- SetNull();
}
~CWallet()
@@ -794,24 +793,6 @@ public:
pwalletdbEncryption = nullptr;
}
- void SetNull()
- {
- nWalletVersion = FEATURE_BASE;
- nWalletMaxVersion = FEATURE_BASE;
- nMasterKeyMaxID = 0;
- pwalletdbEncryption = nullptr;
- nOrderPosNext = 0;
- nAccountingEntryNumber = 0;
- nNextResend = 0;
- nLastResend = 0;
- m_max_keypool_index = 0;
- nTimeFirstKey = 0;
- fBroadcastTransactions = false;
- nRelockTime = 0;
- fAbortRescan = false;
- fScanningWallet = false;
- }
-
std::map<uint256, CWalletTx> mapWallet;
std::list<CAccountingEntry> laccentries;
@@ -819,8 +800,8 @@ public:
typedef std::multimap<int64_t, TxPair > TxItems;
TxItems wtxOrdered;
- int64_t nOrderPosNext;
- uint64_t nAccountingEntryNumber;
+ int64_t nOrderPosNext = 0;
+ uint64_t nAccountingEntryNumber = 0;
std::map<uint256, int> mapRequestCount;
std::map<CTxDestination, CAddressBookData> mapAddressBook;
@@ -913,7 +894,7 @@ public:
bool LoadWatchOnly(const CScript &dest);
//! Holds a timestamp at which point the wallet is scheduled (externally) to be relocked. Caller must arrange for actual relocking to occur via Lock().
- int64_t nRelockTime;
+ int64_t nRelockTime = 0;
bool Unlock(const SecureString& strWalletPassphrase);
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);