Skip to content

Commit f63bc5e

Browse files
wallet: Initialize m_last_block_processed to nullptr. Initialize fields where defined.
1 parent c564424 commit f63bc5e

File tree

1 file changed

+15
-34
lines changed

1 file changed

+15
-34
lines changed

src/wallet/wallet.h

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -660,22 +660,22 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
660660
{
661661
private:
662662
static std::atomic<bool> fFlushScheduled;
663-
std::atomic<bool> fAbortRescan;
664-
std::atomic<bool> fScanningWallet; //controlled by WalletRescanReserver
663+
std::atomic<bool> fAbortRescan{false};
664+
std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
665665
std::mutex mutexScanning;
666666
friend class WalletRescanReserver;
667667

668-
CWalletDB *pwalletdbEncryption;
668+
CWalletDB *pwalletdbEncryption = nullptr;
669669

670670
//! the current wallet version: clients below this version are not able to load the wallet
671-
int nWalletVersion;
671+
int nWalletVersion = FEATURE_BASE;
672672

673673
//! the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
674-
int nWalletMaxVersion;
674+
int nWalletMaxVersion = FEATURE_BASE;
675675

676-
int64_t nNextResend;
677-
int64_t nLastResend;
678-
bool fBroadcastTransactions;
676+
int64_t nNextResend = 0;
677+
int64_t nLastResend = 0;
678+
bool fBroadcastTransactions = false;
679679

680680
/**
681681
* Used to keep track of spent outpoints, and
@@ -704,10 +704,10 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
704704

705705
std::set<int64_t> setInternalKeyPool;
706706
std::set<int64_t> setExternalKeyPool;
707-
int64_t m_max_keypool_index;
707+
int64_t m_max_keypool_index = 0;
708708
std::map<CKeyID, int64_t> m_pool_key_to_index;
709709

710-
int64_t nTimeFirstKey;
710+
int64_t nTimeFirstKey = 0;
711711

712712
/**
713713
* Private version of AddWatchOnly method which does not accept a
@@ -740,7 +740,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
740740
*
741741
* Protected by cs_main (see BlockUntilSyncedToCurrentChain)
742742
*/
743-
const CBlockIndex* m_last_block_processed;
743+
const CBlockIndex* m_last_block_processed = nullptr;
744744

745745
public:
746746
/*
@@ -779,12 +779,11 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
779779

780780
typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
781781
MasterKeyMap mapMasterKeys;
782-
unsigned int nMasterKeyMaxID;
782+
unsigned int nMasterKeyMaxID = 0;
783783

784784
/** Construct wallet with specified name and database implementation. */
785785
CWallet(std::string name, std::unique_ptr<CWalletDBWrapper> dbw) : m_name(std::move(name)), dbw(std::move(dbw))
786786
{
787-
SetNull();
788787
}
789788

790789
~CWallet()
@@ -793,33 +792,15 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
793792
pwalletdbEncryption = nullptr;
794793
}
795794

796-
void SetNull()
797-
{
798-
nWalletVersion = FEATURE_BASE;
799-
nWalletMaxVersion = FEATURE_BASE;
800-
nMasterKeyMaxID = 0;
801-
pwalletdbEncryption = nullptr;
802-
nOrderPosNext = 0;
803-
nAccountingEntryNumber = 0;
804-
nNextResend = 0;
805-
nLastResend = 0;
806-
m_max_keypool_index = 0;
807-
nTimeFirstKey = 0;
808-
fBroadcastTransactions = false;
809-
nRelockTime = 0;
810-
fAbortRescan = false;
811-
fScanningWallet = false;
812-
}
813-
814795
std::map<uint256, CWalletTx> mapWallet;
815796
std::list<CAccountingEntry> laccentries;
816797

817798
typedef std::pair<CWalletTx*, CAccountingEntry*> TxPair;
818799
typedef std::multimap<int64_t, TxPair > TxItems;
819800
TxItems wtxOrdered;
820801

821-
int64_t nOrderPosNext;
822-
uint64_t nAccountingEntryNumber;
802+
int64_t nOrderPosNext = 0;
803+
uint64_t nAccountingEntryNumber = 0;
823804
std::map<uint256, int> mapRequestCount;
824805

825806
std::map<CTxDestination, CAddressBookData> mapAddressBook;
@@ -912,7 +893,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
912893
bool LoadWatchOnly(const CScript &dest);
913894

914895
//! Holds a timestamp at which point the wallet is scheduled (externally) to be relocked. Caller must arrange for actual relocking to occur via Lock().
915-
int64_t nRelockTime;
896+
int64_t nRelockTime = 0;
916897

917898
bool Unlock(const SecureString& strWalletPassphrase);
918899
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);

0 commit comments

Comments
 (0)