Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
//! Default for -addresstype | //! Default for -addresstype | ||||
constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::LEGACY}; | constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::LEGACY}; | ||||
//! Default for -changetype | //! Default for -changetype | ||||
constexpr OutputType DEFAULT_CHANGE_TYPE{OutputType::CHANGE_AUTO}; | constexpr OutputType DEFAULT_CHANGE_TYPE{OutputType::CHANGE_AUTO}; | ||||
enum WalletFlags : uint64_t { | |||||
// Wallet flags in the upper section (> 1 << 31) will lead to not opening | |||||
// the wallet if flag is unknown. | |||||
// Unknown wallet flags in the lower section <= (1 << 31) will be tolerated. | |||||
// Will enforce the rule that the wallet can't contain any private keys | |||||
// (only watch-only/pubkeys). | |||||
WALLET_FLAG_DISABLE_PRIVATE_KEYS = (1ULL << 32), | |||||
}; | |||||
static constexpr uint64_t g_known_wallet_flags = | |||||
WALLET_FLAG_DISABLE_PRIVATE_KEYS; | |||||
/** A key pool entry */ | /** A key pool entry */ | ||||
class CKeyPool { | class CKeyPool { | ||||
public: | public: | ||||
int64_t nTime; | int64_t nTime; | ||||
CPubKey vchPubKey; | CPubKey vchPubKey; | ||||
// for change outputs | // for change outputs | ||||
bool fInternal; | bool fInternal; | ||||
// For keys generated before keypool split upgrade | // For keys generated before keypool split upgrade | ||||
▲ Show 20 Lines • Show All 637 Lines • ▼ Show 20 Lines | void DeriveNewChildKey(WalletBatch &batch, CKeyMetadata &metadata, | ||||
CKey &secret, bool internal = false) | CKey &secret, bool internal = false) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
std::set<int64_t> setInternalKeyPool; | std::set<int64_t> setInternalKeyPool; | ||||
std::set<int64_t> setExternalKeyPool; | std::set<int64_t> setExternalKeyPool; | ||||
std::set<int64_t> set_pre_split_keypool; | std::set<int64_t> set_pre_split_keypool; | ||||
int64_t m_max_keypool_index = 0; | int64_t m_max_keypool_index = 0; | ||||
std::map<CKeyID, int64_t> m_pool_key_to_index; | std::map<CKeyID, int64_t> m_pool_key_to_index; | ||||
std::atomic<uint64_t> m_wallet_flags{0}; | |||||
int64_t nTimeFirstKey = 0; | int64_t nTimeFirstKey = 0; | ||||
/** | /** | ||||
* Private version of AddWatchOnly method which does not accept a timestamp, | * Private version of AddWatchOnly method which does not accept a timestamp, | ||||
* and which will reset the wallet's nTimeFirstKey value to 1 if the watch | * and which will reset the wallet's nTimeFirstKey value to 1 if the watch | ||||
* key did not previously have a timestamp associated with it. Because this | * key did not previously have a timestamp associated with it. Because this | ||||
* is an inherited virtual method, it is accessible despite being marked | * is an inherited virtual method, it is accessible despite being marked | ||||
▲ Show 20 Lines • Show All 523 Lines • ▼ Show 20 Lines | static bool Verify(const CChainParams &chainParams, std::string wallet_file, | ||||
std::string &warning_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 std::string &name, const fs::path &path, | ||||
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 All 38 Lines | public: | ||||
*/ | */ | ||||
void LearnRelatedScripts(const CPubKey &key, OutputType); | void LearnRelatedScripts(const CPubKey &key, OutputType); | ||||
/** | /** | ||||
* Same as LearnRelatedScripts, but when the OutputType is not known (and | * Same as LearnRelatedScripts, but when the OutputType is not known (and | ||||
* could be anything). | * could be anything). | ||||
*/ | */ | ||||
void LearnAllRelatedScripts(const CPubKey &key); | void LearnAllRelatedScripts(const CPubKey &key); | ||||
/** | |||||
* Set a single wallet flag. | |||||
*/ | |||||
void SetWalletFlag(uint64_t flags); | |||||
/** | |||||
* Check if a certain wallet flag is set. | |||||
*/ | |||||
bool IsWalletFlagSet(uint64_t flag); | |||||
/** | |||||
* Overwrite all flags by the given uint64_t. | |||||
* Returns false if unknown, non-tolerable flags are present. | |||||
*/ | |||||
bool SetWalletFlags(uint64_t overwriteFlags, bool memOnly); | |||||
}; | }; | ||||
/** A key allocated from the key pool. */ | /** A key allocated from the key pool. */ | ||||
class CReserveKey final : public CReserveScript { | class CReserveKey final : public CReserveScript { | ||||
protected: | protected: | ||||
CWallet *pwallet; | CWallet *pwallet; | ||||
int64_t nIndex{-1}; | int64_t nIndex{-1}; | ||||
CPubKey vchPubKey; | CPubKey vchPubKey; | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |