Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 635 Lines • ▼ Show 20 Lines | private: | ||||
/* HD derive new child key (on internal or external chain) */ | /* HD derive new child key (on internal or external chain) */ | ||||
void DeriveNewChildKey(CWalletDB &walletdb, CKeyMetadata &metadata, | void DeriveNewChildKey(CWalletDB &walletdb, CKeyMetadata &metadata, | ||||
CKey &secret, bool internal = false); | CKey &secret, bool internal = false); | ||||
std::set<int64_t> setInternalKeyPool; | std::set<int64_t> setInternalKeyPool; | ||||
std::set<int64_t> setExternalKeyPool; | std::set<int64_t> setExternalKeyPool; | ||||
int64_t m_max_keypool_index; | int64_t m_max_keypool_index; | ||||
std::map<CKeyID, int64_t> m_pool_key_to_index; | |||||
int64_t nTimeFirstKey; | int64_t nTimeFirstKey; | ||||
/** | /** | ||||
* 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 All 28 Lines | public: | ||||
std::string GetName() const { | std::string GetName() const { | ||||
if (dbw) { | if (dbw) { | ||||
return dbw->GetName(); | return dbw->GetName(); | ||||
} else { | } else { | ||||
return "dummy"; | return "dummy"; | ||||
} | } | ||||
} | } | ||||
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) { | void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool); | ||||
if (keypool.fInternal) { | |||||
setInternalKeyPool.insert(nIndex); | |||||
} else { | |||||
setExternalKeyPool.insert(nIndex); | |||||
} | |||||
m_max_keypool_index = std::max(m_max_keypool_index, nIndex); | |||||
// If no metadata exists yet, create a default with the pool key's | |||||
// creation time. Note that this may be overwritten by actually stored | |||||
// metadata for that key later, which is fine. | |||||
CKeyID keyid = keypool.vchPubKey.GetID(); | |||||
if (mapKeyMetadata.count(keyid) == 0) | |||||
mapKeyMetadata[keyid] = CKeyMetadata(keypool.nTime); | |||||
} | |||||
// Map from Key ID (for regular keys) or Script ID (for watch-only keys) to | // Map from Key ID (for regular keys) or Script ID (for watch-only keys) to | ||||
// 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; | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | public: | ||||
CPubKey vchDefaultKey; | CPubKey vchDefaultKey; | ||||
std::set<COutPoint> setLockedCoins; | std::set<COutPoint> setLockedCoins; | ||||
const CWalletTx *GetWalletTx(const uint256 &hash) const; | const CWalletTx *GetWalletTx(const uint256 &hash) 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) { | bool CanSupportFeature(enum WalletFeature wf) const { | ||||
AssertLockHeld(cs_wallet); | AssertLockHeld(cs_wallet); | ||||
return nWalletMaxVersion >= wf; | return nWalletMaxVersion >= wf; | ||||
} | } | ||||
/** | /** | ||||
* populate vCoins with vector of available COutputs. | * populate vCoins with vector of available COutputs. | ||||
*/ | */ | ||||
void AvailableCoins(std::vector<COutput> &vCoins, | void AvailableCoins(std::vector<COutput> &vCoins, | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | public: | ||||
static Amount GetRequiredFee(unsigned int nTxBytes); | static Amount GetRequiredFee(unsigned int nTxBytes); | ||||
bool NewKeyPool(); | bool NewKeyPool(); | ||||
size_t KeypoolCountExternalKeys(); | size_t KeypoolCountExternalKeys(); | ||||
bool TopUpKeyPool(unsigned int kpSize = 0); | bool TopUpKeyPool(unsigned int kpSize = 0); | ||||
void ReserveKeyFromKeyPool(int64_t &nIndex, CKeyPool &keypool, | void ReserveKeyFromKeyPool(int64_t &nIndex, CKeyPool &keypool, | ||||
bool fRequestedInternal); | bool fRequestedInternal); | ||||
void KeepKey(int64_t nIndex); | void KeepKey(int64_t nIndex); | ||||
void ReturnKey(int64_t nIndex, bool fInternal); | void ReturnKey(int64_t nIndex, bool fInternal, const CPubKey &pubkey); | ||||
bool GetKeyFromPool(CPubKey &key, bool internal = false); | bool GetKeyFromPool(CPubKey &key, bool internal = false); | ||||
int64_t GetOldestKeyPoolTime(); | int64_t GetOldestKeyPoolTime(); | ||||
void GetAllReserveKeys(std::set<CKeyID> &setAddress) const; | /** | ||||
* Marks all keys in the keypool up to and including reserve_key as used. | |||||
*/ | |||||
void MarkReserveKeysAsUsed(int64_t keypool_id); | |||||
const std::map<CKeyID, int64_t> &GetAllReserveKeys() const { | |||||
return m_pool_key_to_index; | |||||
} | |||||
/** Does the wallet have at least min_keys in the keypool? */ | |||||
bool HasUnusedKeys(int min_keys) const; | |||||
std::set<std::set<CTxDestination>> GetAddressGroupings(); | std::set<std::set<CTxDestination>> GetAddressGroupings(); | ||||
std::map<CTxDestination, Amount> GetAddressBalances(); | std::map<CTxDestination, Amount> GetAddressBalances(); | ||||
Amount GetAccountBalance(const std::string &strAccount, int nMinDepth, | Amount GetAccountBalance(const std::string &strAccount, int nMinDepth, | ||||
const isminefilter &filter); | const isminefilter &filter); | ||||
Amount GetAccountBalance(CWalletDB &walletdb, const std::string &strAccount, | Amount GetAccountBalance(CWalletDB &walletdb, const std::string &strAccount, | ||||
int nMinDepth, const isminefilter &filter); | int nMinDepth, const isminefilter &filter); | ||||
▲ Show 20 Lines • Show All 238 Lines • Show Last 20 Lines |