Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/scriptpubkeyman.h
Show All 28 Lines | public: | ||||
virtual ~WalletStorage() = default; | virtual ~WalletStorage() = default; | ||||
virtual const std::string GetDisplayName() const = 0; | virtual const std::string GetDisplayName() const = 0; | ||||
virtual WalletDatabase &GetDatabase() = 0; | virtual WalletDatabase &GetDatabase() = 0; | ||||
virtual bool IsWalletFlagSet(uint64_t) const = 0; | virtual bool IsWalletFlagSet(uint64_t) const = 0; | ||||
virtual void UnsetBlankWalletFlag(WalletBatch &) = 0; | virtual void UnsetBlankWalletFlag(WalletBatch &) = 0; | ||||
virtual bool CanSupportFeature(enum WalletFeature) const = 0; | virtual bool CanSupportFeature(enum WalletFeature) const = 0; | ||||
virtual void SetMinVersion(enum WalletFeature, WalletBatch * = nullptr, | virtual void SetMinVersion(enum WalletFeature, WalletBatch * = nullptr, | ||||
bool = false) = 0; | bool = false) = 0; | ||||
virtual const CKeyingMaterial &GetEncryptionKey() const = 0; | |||||
virtual bool HasEncryptionKeys() const = 0; | |||||
virtual bool IsLocked() const = 0; | virtual bool IsLocked() const = 0; | ||||
}; | }; | ||||
//! Default for -keypool | //! Default for -keypool | ||||
static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000; | static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000; | ||||
std::vector<CKeyID> GetAffectedKeys(const CScript &spk, | std::vector<CKeyID> GetAffectedKeys(const CScript &spk, | ||||
const SigningProvider &provider); | const SigningProvider &provider); | ||||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | public: | ||||
ScriptPubKeyMan(WalletStorage &storage) : m_storage(storage) {} | ScriptPubKeyMan(WalletStorage &storage) : m_storage(storage) {} | ||||
virtual ~ScriptPubKeyMan(){}; | virtual ~ScriptPubKeyMan(){}; | ||||
virtual bool GetNewDestination(const OutputType type, CTxDestination &dest, | virtual bool GetNewDestination(const OutputType type, CTxDestination &dest, | ||||
std::string &error) { | std::string &error) { | ||||
return false; | return false; | ||||
} | } | ||||
virtual isminetype IsMine(const CScript &script) const { return ISMINE_NO; } | virtual isminetype IsMine(const CScript &script) const { return ISMINE_NO; } | ||||
//! Check that the given decryption key is valid for this ScriptPubKeyMan, | |||||
//! i.e. it decrypts all of the keys handled by it. | |||||
virtual bool CheckDecryptionKey(const CKeyingMaterial &master_key, | |||||
bool accept_no_keys = false) { | |||||
return false; | |||||
} | |||||
virtual bool Encrypt(const CKeyingMaterial &master_key, | |||||
WalletBatch *batch) { | |||||
return false; | |||||
} | |||||
virtual bool GetReservedDestination(const OutputType type, bool internal, | virtual bool GetReservedDestination(const OutputType type, bool internal, | ||||
CTxDestination &address, int64_t &index, | CTxDestination &address, int64_t &index, | ||||
CKeyPool &keypool) { | CKeyPool &keypool) { | ||||
return false; | return false; | ||||
} | } | ||||
virtual void KeepDestination(int64_t index, const OutputType &type) {} | virtual void KeepDestination(int64_t index, const OutputType &type) {} | ||||
virtual void ReturnDestination(int64_t index, bool internal, | virtual void ReturnDestination(int64_t index, bool internal, | ||||
const CTxDestination &addr) {} | const CTxDestination &addr) {} | ||||
Show All 39 Lines | public: | ||||
virtual const CKeyMetadata *GetMetadata(const CTxDestination &dest) const { | virtual const CKeyMetadata *GetMetadata(const CTxDestination &dest) const { | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
}; | }; | ||||
class LegacyScriptPubKeyMan : public ScriptPubKeyMan, | class LegacyScriptPubKeyMan : public ScriptPubKeyMan, | ||||
public FillableSigningProvider { | public FillableSigningProvider { | ||||
private: | private: | ||||
//! keeps track of whether Unlock has run a thorough check before | |||||
bool fDecryptionThoroughlyChecked = false; | |||||
using WatchOnlySet = std::set<CScript>; | using WatchOnlySet = std::set<CScript>; | ||||
using WatchKeyMap = std::map<CKeyID, CPubKey>; | using WatchKeyMap = std::map<CKeyID, CPubKey>; | ||||
WalletBatch *encrypted_batch GUARDED_BY(cs_wallet) = nullptr; | WalletBatch *encrypted_batch GUARDED_BY(cs_wallet) = nullptr; | ||||
using CryptedKeyMap = | using CryptedKeyMap = | ||||
std::map<CKeyID, std::pair<CPubKey, std::vector<uint8_t>>>; | std::map<CKeyID, std::pair<CPubKey, std::vector<uint8_t>>>; | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | private: | ||||
bool ReserveKeyFromKeyPool(int64_t &nIndex, CKeyPool &keypool, | bool ReserveKeyFromKeyPool(int64_t &nIndex, CKeyPool &keypool, | ||||
bool fRequestedInternal); | bool fRequestedInternal); | ||||
public: | public: | ||||
bool GetNewDestination(const OutputType type, CTxDestination &dest, | bool GetNewDestination(const OutputType type, CTxDestination &dest, | ||||
std::string &error) override; | std::string &error) override; | ||||
isminetype IsMine(const CScript &script) const override; | isminetype IsMine(const CScript &script) const override; | ||||
//! will encrypt previously unencrypted keys | bool CheckDecryptionKey(const CKeyingMaterial &master_key, | ||||
bool EncryptKeys(CKeyingMaterial &vMasterKeyIn); | bool accept_no_keys = false) override; | ||||
bool Encrypt(const CKeyingMaterial &master_key, | |||||
WalletBatch *batch) override; | |||||
bool GetReservedDestination(const OutputType type, bool internal, | bool GetReservedDestination(const OutputType type, bool internal, | ||||
CTxDestination &address, int64_t &index, | CTxDestination &address, int64_t &index, | ||||
CKeyPool &keypool) override; | CKeyPool &keypool) override; | ||||
void KeepDestination(int64_t index, const OutputType &type) override; | void KeepDestination(int64_t index, const OutputType &type) override; | ||||
void ReturnDestination(int64_t index, bool internal, | void ReturnDestination(int64_t index, bool internal, | ||||
const CTxDestination &) override; | const CTxDestination &) override; | ||||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | const std::map<CKeyID, int64_t> &GetAllReserveKeys() const { | ||||
return m_pool_key_to_index; | return m_pool_key_to_index; | ||||
} | } | ||||
std::set<CKeyID> GetKeys() const override; | std::set<CKeyID> GetKeys() const override; | ||||
// Temporary CWallet accessors and aliases. | // Temporary CWallet accessors and aliases. | ||||
friend class CWallet; | friend class CWallet; | ||||
friend class ReserveDestination; | friend class ReserveDestination; | ||||
LegacyScriptPubKeyMan(CWallet &wallet); | LegacyScriptPubKeyMan(CWallet &wallet); | ||||
bool SetCrypted(); | |||||
bool IsCrypted() const; | |||||
void NotifyWatchonlyChanged(bool fHaveWatchOnly) const; | void NotifyWatchonlyChanged(bool fHaveWatchOnly) const; | ||||
void NotifyCanGetAddressesChanged() const; | void NotifyCanGetAddressesChanged() const; | ||||
template <typename... Params> | template <typename... Params> | ||||
void WalletLogPrintf(const std::string &fmt, | void WalletLogPrintf(const std::string &fmt, | ||||
const Params &... parameters) const; | const Params &... parameters) const; | ||||
CWallet &m_wallet; | CWallet &m_wallet; | ||||
RecursiveMutex &cs_wallet; | RecursiveMutex &cs_wallet; | ||||
CKeyingMaterial &vMasterKey GUARDED_BY(cs_KeyStore); | |||||
std::atomic<bool> &fUseCrypto; | |||||
bool &fDecryptionThoroughlyChecked; | |||||
}; | }; | ||||
#endif // BITCOIN_WALLET_SCRIPTPUBKEYMAN_H | #endif // BITCOIN_WALLET_SCRIPTPUBKEYMAN_H |