Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
| // Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
| // Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
| // Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
| #ifndef BITCOIN_WALLET_WALLET_H | #ifndef BITCOIN_WALLET_WALLET_H | ||||
| #define BITCOIN_WALLET_WALLET_H | #define BITCOIN_WALLET_WALLET_H | ||||
| #include "amount.h" | #include "amount.h" | ||||
| #include "config.h" | |||||
| #include "script/ismine.h" | #include "script/ismine.h" | ||||
| #include "script/sign.h" | #include "script/sign.h" | ||||
| #include "streams.h" | #include "streams.h" | ||||
| #include "tinyformat.h" | #include "tinyformat.h" | ||||
| #include "ui_interface.h" | #include "ui_interface.h" | ||||
| #include "utilstrencodings.h" | #include "utilstrencodings.h" | ||||
| #include "validationinterface.h" | #include "validationinterface.h" | ||||
| #include "wallet/crypter.h" | #include "wallet/crypter.h" | ||||
| ▲ Show 20 Lines • Show All 651 Lines • ▼ Show 20 Lines | private: | ||||
| std::unique_ptr<CWalletDBWrapper> dbw; | std::unique_ptr<CWalletDBWrapper> dbw; | ||||
| // Used to NotifyTransactionChanged of the previous block's coinbase when | // Used to NotifyTransactionChanged of the previous block's coinbase when | ||||
| // the next block comes in | // the next block comes in | ||||
| uint256 hashPrevBestCoinbase; | uint256 hashPrevBestCoinbase; | ||||
| public: | public: | ||||
| const CChainParams &chainParams; | const Config &config; | ||||
deadalnix: private | |||||
| /* | /* | ||||
| * Main wallet lock. | * Main wallet lock. | ||||
| * This lock protects all the fields added by CWallet. | * This lock protects all the fields added by CWallet. | ||||
| */ | */ | ||||
| mutable CCriticalSection cs_wallet; | mutable CCriticalSection cs_wallet; | ||||
| /** | /** | ||||
| * Get database handle used by this wallet. Ideally this function would not | * Get database handle used by this wallet. Ideally this function would not | ||||
| Show All 18 Lines | public: | ||||
| // key metadata. | // key metadata. | ||||
| std::map<CTxDestination, CKeyMetadata> mapKeyMetadata; | std::map<CTxDestination, CKeyMetadata> mapKeyMetadata; | ||||
| typedef std::map<unsigned int, CMasterKey> MasterKeyMap; | typedef std::map<unsigned int, CMasterKey> MasterKeyMap; | ||||
| MasterKeyMap mapMasterKeys; | MasterKeyMap mapMasterKeys; | ||||
| unsigned int nMasterKeyMaxID; | unsigned int nMasterKeyMaxID; | ||||
| // Create wallet with dummy database handle | // Create wallet with dummy database handle | ||||
| CWallet(const CChainParams &chainParams) | CWallet(const Config &config) | ||||
deadalnixUnsubmitted Not Done Inline ActionsThis is taking ownership of the config, so it needs to pass it by pointer. deadalnix: This is taking ownership of the config, so it needs to pass it by pointer. | |||||
matiuAuthorUnsubmitted Not Done Inline Actionsthanks, will change. matiu: thanks, will change. | |||||
| : dbw(new CWalletDBWrapper()), chainParams(chainParams) { | : dbw(new CWalletDBWrapper()), config(config) { | ||||
| SetNull(); | SetNull(); | ||||
| } | } | ||||
| // Create wallet with passed-in database handle | // Create wallet with passed-in database handle | ||||
| CWallet(const CChainParams &chainParams, | CWallet(const Config &config, std::unique_ptr<CWalletDBWrapper> dbw_in) | ||||
| std::unique_ptr<CWalletDBWrapper> dbw_in) | : dbw(std::move(dbw_in)), config(config) { | ||||
| : dbw(std::move(dbw_in)), chainParams(chainParams) { | |||||
| SetNull(); | SetNull(); | ||||
| } | } | ||||
| ~CWallet() { | ~CWallet() { | ||||
| delete pwalletdbEncryption; | delete pwalletdbEncryption; | ||||
| pwalletdbEncryption = nullptr; | pwalletdbEncryption = nullptr; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 330 Lines • ▼ Show 20 Lines | public: | ||||
| //! Flush wallet (bitdb flush) | //! Flush wallet (bitdb flush) | ||||
| void Flush(bool shutdown = false); | void Flush(bool shutdown = false); | ||||
| //! Responsible for reading and validating the -wallet arguments and | //! Responsible for reading and validating the -wallet arguments and | ||||
| //! verifying the wallet database. | //! verifying the wallet database. | ||||
| // This function will perform salvage on the wallet if requested, as long as | // This function will perform salvage on the wallet if requested, as long as | ||||
| // only one wallet is being loaded (CWallet::ParameterInteraction forbids | // only one wallet is being loaded (CWallet::ParameterInteraction forbids | ||||
| // -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet). | // -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet). | ||||
| static bool Verify(const CChainParams &chainParams); | static bool Verify(const Config &config); | ||||
| /** | /** | ||||
| * Address book entry changed. | * Address book entry changed. | ||||
| * @note called with lock cs_wallet held. | * @note called with lock cs_wallet held. | ||||
| */ | */ | ||||
| boost::signals2::signal<void(CWallet *wallet, const CTxDestination &address, | boost::signals2::signal<void(CWallet *wallet, const CTxDestination &address, | ||||
| const std::string &label, bool isMine, | const std::string &label, bool isMine, | ||||
| const std::string &purpose, ChangeType status)> | const std::string &purpose, ChangeType status)> | ||||
| Show All 29 Lines | public: | ||||
| /* Returns the wallets help message */ | /* Returns the wallets help message */ | ||||
| static std::string GetWalletHelpString(bool showDebug); | static std::string GetWalletHelpString(bool showDebug); | ||||
| /** | /** | ||||
| * Initializes the wallet, returns a new CWallet instance or a null pointer | * Initializes the wallet, returns a new CWallet instance or a null pointer | ||||
| * in case of an error. | * in case of an error. | ||||
| */ | */ | ||||
| static CWallet *CreateWalletFromFile(const CChainParams &chainParams, | static CWallet *CreateWalletFromFile(const Config &config, | ||||
| const std::string walletFile); | const std::string walletFile); | ||||
| static bool InitLoadWallet(const CChainParams &chainParams); | static bool InitLoadWallet(const Config &config); | ||||
| /** | /** | ||||
| * Wallet post-init setup | * Wallet post-init setup | ||||
| * Gives the wallet a chance to register repetitive tasks and complete | * Gives the wallet a chance to register repetitive tasks and complete | ||||
| * post-init tasks | * post-init tasks | ||||
| */ | */ | ||||
| void postInitProcess(CScheduler &scheduler); | void postInitProcess(CScheduler &scheduler); | ||||
| ▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines | |||||
private