Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show All 16 Lines | |||||
#include <ui_interface.h> | #include <ui_interface.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <validationinterface.h> | #include <validationinterface.h> | ||||
#include <wallet/coinselection.h> | #include <wallet/coinselection.h> | ||||
#include <wallet/crypter.h> | #include <wallet/crypter.h> | ||||
#include <wallet/rpcwallet.h> | #include <wallet/rpcwallet.h> | ||||
#include <wallet/walletdb.h> | #include <wallet/walletdb.h> | ||||
#include <wallet/walletutil.h> | |||||
#include <algorithm> | #include <algorithm> | ||||
#include <atomic> | #include <atomic> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <map> | #include <map> | ||||
#include <memory> | #include <memory> | ||||
#include <set> | #include <set> | ||||
#include <stdexcept> | #include <stdexcept> | ||||
▲ Show 20 Lines • Show All 775 Lines • ▼ Show 20 Lines | private: | ||||
* 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); | ||||
/** | /** | ||||
* Wallet filename from wallet=<path> command line or config option. | * Wallet location which includes wallet name (see WalletLocation). | ||||
* Used in debug logs and to send RPCs to the right wallet instance when | |||||
* more than one wallet is loaded. | |||||
*/ | */ | ||||
std::string m_name; | WalletLocation m_location; | ||||
/** Internal database handle. */ | /** Internal database handle. */ | ||||
std::unique_ptr<WalletDatabase> database; | std::unique_ptr<WalletDatabase> database; | ||||
/** | /** | ||||
* The following is used to keep track of how far behind the wallet is | * The following is used to keep track of how far behind the wallet is | ||||
* from the chain sync, and to allow clients to block on us being caught up. | * from the chain sync, and to allow clients to block on us being caught up. | ||||
* | * | ||||
Show All 26 Lines | public: | ||||
*/ | */ | ||||
bool SelectCoins(const std::vector<COutput> &vAvailableCoins, | bool SelectCoins(const std::vector<COutput> &vAvailableCoins, | ||||
const Amount nTargetValue, | const Amount nTargetValue, | ||||
std::set<CInputCoin> &setCoinsRet, Amount &nValueRet, | std::set<CInputCoin> &setCoinsRet, Amount &nValueRet, | ||||
const CCoinControl &coin_control, | const CCoinControl &coin_control, | ||||
CoinSelectionParams &coin_selection_params, | CoinSelectionParams &coin_selection_params, | ||||
bool &bnb_used) const; | bool &bnb_used) const; | ||||
const WalletLocation &GetLocation() const { return m_location; } | |||||
/** | /** | ||||
* Get a name for this wallet for logging/debugging purposes. | * Get a name for this wallet for logging/debugging purposes. | ||||
*/ | */ | ||||
std::string GetName() const { return m_name; } | const std::string &GetName() const { return m_location.GetName(); } | ||||
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) | void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
void MarkPreSplitKeys(); | void MarkPreSplitKeys(); | ||||
// Map from Key ID to key metadata. | // Map from Key ID to key metadata. | ||||
std::map<CKeyID, CKeyMetadata> mapKeyMetadata; | std::map<CKeyID, CKeyMetadata> mapKeyMetadata; | ||||
// 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, std::string name, | CWallet(const CChainParams &chainParamsIn, const WalletLocation &location, | ||||
std::unique_ptr<WalletDatabase> databaseIn) | std::unique_ptr<WalletDatabase> databaseIn) | ||||
: m_name(std::move(name)), database(std::move(databaseIn)), | : 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; | ||||
▲ Show 20 Lines • Show All 423 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, std::string wallet_file, | static bool Verify(const CChainParams &chainParams, | ||||
bool salvage_wallet, std::string &error_string, | const WalletLocation &location, bool salvage_wallet, | ||||
std::string &warning_string); | 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(const CChainParams &chainParams, | CreateWalletFromFile(const CChainParams &chainParams, | ||||
const std::string &name, const fs::path &path, | 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 189 Lines • Show Last 20 Lines |