Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show All 29 Lines | |||||
#include <map> | #include <map> | ||||
#include <memory> | #include <memory> | ||||
#include <set> | #include <set> | ||||
#include <stdexcept> | #include <stdexcept> | ||||
#include <string> | #include <string> | ||||
#include <utility> | #include <utility> | ||||
#include <vector> | #include <vector> | ||||
namespace interfaces { | |||||
class Chain; | |||||
} // namespace interfaces | |||||
bool AddWallet(const std::shared_ptr<CWallet> &wallet); | bool AddWallet(const std::shared_ptr<CWallet> &wallet); | ||||
bool RemoveWallet(const std::shared_ptr<CWallet> &wallet); | bool RemoveWallet(const std::shared_ptr<CWallet> &wallet); | ||||
bool HasWallets(); | bool HasWallets(); | ||||
std::vector<std::shared_ptr<CWallet>> GetWallets(); | std::vector<std::shared_ptr<CWallet>> GetWallets(); | ||||
std::shared_ptr<CWallet> GetWallet(const std::string &name); | std::shared_ptr<CWallet> GetWallet(const std::string &name); | ||||
//! Default for -keypool | //! Default for -keypool | ||||
static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000; | static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000; | ||||
▲ Show 20 Lines • Show All 774 Lines • ▼ Show 20 Lines | private: | ||||
* is an inherited virtual method, it is accessible despite being marked | * is an inherited virtual method, it is accessible despite being marked | ||||
* private, but it is marked private anyway to encourage use of the other | * private, but it is marked private anyway to encourage use of the other | ||||
* AddWatchOnly which accepts a timestamp and sets nTimeFirstKey more | * AddWatchOnly which accepts a timestamp and sets nTimeFirstKey more | ||||
* intelligently for more efficient rescans. | * intelligently for more efficient rescans. | ||||
*/ | */ | ||||
bool AddWatchOnly(const CScript &dest) override | bool AddWatchOnly(const CScript &dest) override | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
/** Interface for accessing chain state. */ | |||||
interfaces::Chain &m_chain; | |||||
/** | /** | ||||
* Wallet location which includes wallet name (see WalletLocation). | * Wallet location which includes wallet name (see WalletLocation). | ||||
*/ | */ | ||||
WalletLocation m_location; | WalletLocation m_location; | ||||
/** Internal database handle. */ | /** Internal database handle. */ | ||||
std::unique_ptr<WalletDatabase> database; | std::unique_ptr<WalletDatabase> database; | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | public: | ||||
// Map from Script ID to key metadata (for watch-only keys). | // Map from Script ID to key metadata (for watch-only keys). | ||||
std::map<CScriptID, CKeyMetadata> m_script_metadata; | std::map<CScriptID, CKeyMetadata> m_script_metadata; | ||||
typedef std::map<unsigned int, CMasterKey> MasterKeyMap; | typedef std::map<unsigned int, CMasterKey> MasterKeyMap; | ||||
MasterKeyMap mapMasterKeys; | MasterKeyMap mapMasterKeys; | ||||
unsigned int nMasterKeyMaxID = 0; | unsigned int nMasterKeyMaxID = 0; | ||||
/** Construct wallet with specified name and database implementation. */ | /** Construct wallet with specified name and database implementation. */ | ||||
CWallet(const CChainParams &chainParamsIn, const WalletLocation &location, | CWallet(const CChainParams &chainParamsIn, interfaces::Chain &chain, | ||||
const WalletLocation &location, | |||||
std::unique_ptr<WalletDatabase> databaseIn) | std::unique_ptr<WalletDatabase> databaseIn) | ||||
: m_location(location), database(std::move(databaseIn)), | : m_chain(chain), m_location(location), database(std::move(databaseIn)), | ||||
chainParams(chainParamsIn) {} | chainParams(chainParamsIn) {} | ||||
~CWallet() { | ~CWallet() { | ||||
delete encrypted_batch; | delete encrypted_batch; | ||||
encrypted_batch = nullptr; | encrypted_batch = nullptr; | ||||
} | } | ||||
std::map<TxId, CWalletTx> mapWallet; | std::map<TxId, CWalletTx> mapWallet; | ||||
std::list<CAccountingEntry> laccentries; | std::list<CAccountingEntry> laccentries; | ||||
typedef std::pair<CWalletTx *, CAccountingEntry *> TxPair; | typedef std::pair<CWalletTx *, CAccountingEntry *> TxPair; | ||||
typedef std::multimap<int64_t, TxPair> TxItems; | typedef std::multimap<int64_t, TxPair> TxItems; | ||||
TxItems wtxOrdered; | TxItems wtxOrdered; | ||||
int64_t nOrderPosNext = 0; | int64_t nOrderPosNext = 0; | ||||
uint64_t nAccountingEntryNumber = 0; | uint64_t nAccountingEntryNumber = 0; | ||||
std::map<CTxDestination, CAddressBookData> mapAddressBook; | std::map<CTxDestination, CAddressBookData> mapAddressBook; | ||||
std::set<COutPoint> setLockedCoins; | std::set<COutPoint> setLockedCoins; | ||||
/** Interface for accessing chain state. */ | |||||
interfaces::Chain &chain() const { return m_chain; } | |||||
const CWalletTx *GetWalletTx(const TxId &txid) const; | const CWalletTx *GetWalletTx(const TxId &txid) const; | ||||
//! check whether we are allowed to upgrade (or already support) to the | //! check whether we are allowed to upgrade (or already support) to the | ||||
//! named feature | //! named feature | ||||
bool CanSupportFeature(enum WalletFeature wf) const | bool CanSupportFeature(enum WalletFeature wf) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { | ||||
AssertLockHeld(cs_wallet); | AssertLockHeld(cs_wallet); | ||||
return nWalletMaxVersion >= wf; | return nWalletMaxVersion >= wf; | ||||
▲ Show 20 Lines • Show All 406 Lines • ▼ Show 20 Lines | public: | ||||
/** | /** | ||||
* Mark a transaction (and it in-wallet descendants) as abandoned so its | * Mark a transaction (and it in-wallet descendants) as abandoned so its | ||||
* inputs may be respent. | * inputs may be respent. | ||||
*/ | */ | ||||
bool AbandonTransaction(const TxId &txid); | bool AbandonTransaction(const TxId &txid); | ||||
//! Verify wallet naming and perform salvage on the wallet if required | //! Verify wallet naming and perform salvage on the wallet if required | ||||
static bool Verify(const CChainParams &chainParams, | static bool Verify(const CChainParams &chainParams, | ||||
const WalletLocation &location, bool salvage_wallet, | interfaces::Chain &chain, const WalletLocation &location, | ||||
std::string &error_string, std::string &warning_string); | bool salvage_wallet, std::string &error_string, | ||||
std::string &warning_string); | |||||
/** | /** | ||||
* 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 std::shared_ptr<CWallet> | static std::shared_ptr<CWallet> CreateWalletFromFile( | ||||
CreateWalletFromFile(const CChainParams &chainParams, | const CChainParams &chainParams, interfaces::Chain &chain, | ||||
const WalletLocation &location, | const WalletLocation &location, uint64_t wallet_creation_flags = 0); | ||||
uint64_t wallet_creation_flags = 0); | |||||
/** | /** | ||||
* 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(); | void postInitProcess(); | ||||
▲ Show 20 Lines • Show All 202 Lines • Show Last 20 Lines |