Bitcoin Core  22.99.0
P2P Digital Currency
scriptpubkeyman.h
Go to the documentation of this file.
1 // Copyright (c) 2019-2020 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_WALLET_SCRIPTPUBKEYMAN_H
6 #define BITCOIN_WALLET_SCRIPTPUBKEYMAN_H
7 
8 #include <psbt.h>
9 #include <script/descriptor.h>
10 #include <script/signingprovider.h>
11 #include <script/standard.h>
12 #include <util/error.h>
13 #include <util/message.h>
14 #include <util/time.h>
15 #include <wallet/crypter.h>
16 #include <wallet/ismine.h>
17 #include <wallet/walletdb.h>
18 #include <wallet/walletutil.h>
19 
20 #include <boost/signals2/signal.hpp>
21 
22 #include <unordered_map>
23 
24 enum class OutputType;
25 struct bilingual_str;
26 
27 // Wallet storage things that ScriptPubKeyMans need in order to be able to store things to the wallet database.
28 // It provides access to things that are part of the entire wallet and not specific to a ScriptPubKeyMan such as
29 // wallet flags, wallet version, encryption keys, encryption status, and the database itself. This allows a
30 // ScriptPubKeyMan to have callbacks into CWallet without causing a circular dependency.
31 // WalletStorage should be the same for all ScriptPubKeyMans of a wallet.
33 {
34 public:
35  virtual ~WalletStorage() = default;
36  virtual const std::string GetDisplayName() const = 0;
37  virtual WalletDatabase& GetDatabase() const = 0;
38  virtual bool IsWalletFlagSet(uint64_t) const = 0;
39  virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
40  virtual bool CanSupportFeature(enum WalletFeature) const = 0;
41  virtual void SetMinVersion(enum WalletFeature, WalletBatch* = nullptr) = 0;
42  virtual const CKeyingMaterial& GetEncryptionKey() const = 0;
43  virtual bool HasEncryptionKeys() const = 0;
44  virtual bool IsLocked() const = 0;
45 };
46 
48 static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000;
49 
50 std::vector<CKeyID> GetAffectedKeys(const CScript& spk, const SigningProvider& provider);
51 
101 class CKeyPool
102 {
103 public:
105  int64_t nTime;
109  bool fInternal;
112 
113  CKeyPool();
114  CKeyPool(const CPubKey& vchPubKeyIn, bool internalIn);
115 
116  template<typename Stream>
117  void Serialize(Stream& s) const
118  {
119  int nVersion = s.GetVersion();
120  if (!(s.GetType() & SER_GETHASH)) {
121  s << nVersion;
122  }
123  s << nTime << vchPubKey << fInternal << m_pre_split;
124  }
125 
126  template<typename Stream>
127  void Unserialize(Stream& s)
128  {
129  int nVersion = s.GetVersion();
130  if (!(s.GetType() & SER_GETHASH)) {
131  s >> nVersion;
132  }
133  s >> nTime >> vchPubKey;
134  try {
135  s >> fInternal;
136  } catch (std::ios_base::failure&) {
137  /* flag as external address if we can't read the internal boolean
138  (this will be the case for any wallet before the HD chain split version) */
139  fInternal = false;
140  }
141  try {
142  s >> m_pre_split;
143  } catch (std::ios_base::failure&) {
144  /* flag as postsplit address if we can't read the m_pre_split boolean
145  (this will be the case for any wallet that upgrades to HD chain split) */
146  m_pre_split = false;
147  }
148  }
149 };
150 
151 /*
152  * A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
153  * It contains the scripts and keys related to the scriptPubKeys it manages.
154  * A ScriptPubKeyMan will be able to give out scriptPubKeys to be used, as well as marking
155  * when a scriptPubKey has been used. It also handles when and how to store a scriptPubKey
156  * and its related scripts and keys, including encryption.
157  */
159 {
160 protected:
162 
163 public:
164  explicit ScriptPubKeyMan(WalletStorage& storage) : m_storage(storage) {}
165  virtual ~ScriptPubKeyMan() {};
166  virtual bool GetNewDestination(const OutputType type, CTxDestination& dest, bilingual_str& error) { return false; }
167  virtual isminetype IsMine(const CScript& script) const { return ISMINE_NO; }
168 
170  virtual bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) { return false; }
171  virtual bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) { return false; }
172 
173  virtual bool GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool, bilingual_str& error) { return false; }
174  virtual void KeepDestination(int64_t index, const OutputType& type) {}
175  virtual void ReturnDestination(int64_t index, bool internal, const CTxDestination& addr) {}
176 
181  virtual bool TopUp(unsigned int size = 0) { return false; }
182 
184  virtual void MarkUnusedAddresses(const CScript& script) {}
185 
190  virtual bool SetupGeneration(bool force = false) { return false; }
191 
192  /* Returns true if HD is enabled */
193  virtual bool IsHDEnabled() const { return false; }
194 
195  /* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
196  virtual bool CanGetAddresses(bool internal = false) const { return false; }
197 
199  virtual bool Upgrade(int prev_version, int new_version, bilingual_str& error) { return true; }
200 
201  virtual bool HavePrivateKeys() const { return false; }
202 
204  virtual void RewriteDB() {}
205 
206  virtual int64_t GetOldestKeyPoolTime() const { return GetTime(); }
207 
208  virtual unsigned int GetKeyPoolSize() const { return 0; }
209 
210  virtual int64_t GetTimeFirstKey() const { return 0; }
211 
212  virtual std::unique_ptr<CKeyMetadata> GetMetadata(const CTxDestination& dest) const { return nullptr; }
213 
214  virtual std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const { return nullptr; }
215 
219  virtual bool CanProvide(const CScript& script, SignatureData& sigdata) { return false; }
220 
222  virtual bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const { return false; }
224  virtual SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const { return SigningResult::SIGNING_FAILED; };
226  virtual TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = 1 /* SIGHASH_ALL */, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr) const { return TransactionError::INVALID_PSBT; }
227 
228  virtual uint256 GetID() const { return uint256(); }
229 
231  template<typename... Params>
232  void WalletLogPrintf(std::string fmt, Params... parameters) const {
233  LogPrintf(("%s " + fmt).c_str(), m_storage.GetDisplayName(), parameters...);
234  };
235 
237  boost::signals2::signal<void (bool fHaveWatchOnly)> NotifyWatchonlyChanged;
238 
240  boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
241 };
242 
244 static const std::unordered_set<OutputType> LEGACY_OUTPUT_TYPES {
248 };
249 
251 {
252 private:
255 
256  using WatchOnlySet = std::set<CScript>;
257  using WatchKeyMap = std::map<CKeyID, CPubKey>;
258 
259  WalletBatch *encrypted_batch GUARDED_BY(cs_KeyStore) = nullptr;
260 
261  using CryptedKeyMap = std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char>>>;
262 
263  CryptedKeyMap mapCryptedKeys GUARDED_BY(cs_KeyStore);
264  WatchOnlySet setWatchOnly GUARDED_BY(cs_KeyStore);
265  WatchKeyMap mapWatchKeys GUARDED_BY(cs_KeyStore);
266 
267  int64_t nTimeFirstKey GUARDED_BY(cs_KeyStore) = 0;
268 
269  bool AddKeyPubKeyInner(const CKey& key, const CPubKey &pubkey);
270  bool AddCryptedKeyInner(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
271 
283  bool AddWatchOnlyInMem(const CScript &dest);
285  bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript& dest, int64_t create_time) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
286 
288  bool AddKeyPubKeyWithDB(WalletBatch &batch,const CKey& key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
289 
290  void AddKeypoolPubkeyWithDB(const CPubKey& pubkey, const bool internal, WalletBatch& batch);
291 
293  bool AddCScriptWithDB(WalletBatch& batch, const CScript& script);
294 
296  bool AddKeyOriginWithDB(WalletBatch& batch, const CPubKey& pubkey, const KeyOriginInfo& info);
297 
298  /* the HD chain data model (external chain counters) */
300  std::unordered_map<CKeyID, CHDChain, SaltedSipHasher> m_inactive_hd_chains;
301 
302  /* HD derive new child key (on internal or external chain) */
303  void DeriveNewChildKey(WalletBatch& batch, CKeyMetadata& metadata, CKey& secret, CHDChain& hd_chain, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
304 
305  std::set<int64_t> setInternalKeyPool GUARDED_BY(cs_KeyStore);
306  std::set<int64_t> setExternalKeyPool GUARDED_BY(cs_KeyStore);
307  std::set<int64_t> set_pre_split_keypool GUARDED_BY(cs_KeyStore);
308  int64_t m_max_keypool_index GUARDED_BY(cs_KeyStore) = 0;
309  std::map<CKeyID, int64_t> m_pool_key_to_index;
310  // Tracks keypool indexes to CKeyIDs of keys that have been taken out of the keypool but may be returned to it
311  std::map<int64_t, CKeyID> m_index_to_reserved_key;
312 
314  bool GetKeyFromPool(CPubKey &key, const OutputType type, bool internal = false);
315 
330  bool ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool fRequestedInternal);
331 
342  bool TopUpInactiveHDChain(const CKeyID seed_id, int64_t index, bool internal);
343 
344 public:
346 
347  bool GetNewDestination(const OutputType type, CTxDestination& dest, bilingual_str& error) override;
348  isminetype IsMine(const CScript& script) const override;
349 
350  bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) override;
351  bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) override;
352 
353  bool GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool, bilingual_str& error) override;
354  void KeepDestination(int64_t index, const OutputType& type) override;
355  void ReturnDestination(int64_t index, bool internal, const CTxDestination&) override;
356 
357  bool TopUp(unsigned int size = 0) override;
358 
359  void MarkUnusedAddresses(const CScript& script) override;
360 
362  void UpgradeKeyMetadata();
363 
364  bool IsHDEnabled() const override;
365 
366  bool SetupGeneration(bool force = false) override;
367 
368  bool Upgrade(int prev_version, int new_version, bilingual_str& error) override;
369 
370  bool HavePrivateKeys() const override;
371 
372  void RewriteDB() override;
373 
374  int64_t GetOldestKeyPoolTime() const override;
375  size_t KeypoolCountExternalKeys() const;
376  unsigned int GetKeyPoolSize() const override;
377 
378  int64_t GetTimeFirstKey() const override;
379 
380  std::unique_ptr<CKeyMetadata> GetMetadata(const CTxDestination& dest) const override;
381 
382  bool CanGetAddresses(bool internal = false) const override;
383 
384  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const override;
385 
386  bool CanProvide(const CScript& script, SignatureData& sigdata) override;
387 
388  bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const override;
389  SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const override;
390  TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = 1 /* SIGHASH_ALL */, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr) const override;
391 
392  uint256 GetID() const override;
393 
394  // Map from Key ID to key metadata.
395  std::map<CKeyID, CKeyMetadata> mapKeyMetadata GUARDED_BY(cs_KeyStore);
396 
397  // Map from Script ID to key metadata (for watch-only keys).
398  std::map<CScriptID, CKeyMetadata> m_script_metadata GUARDED_BY(cs_KeyStore);
399 
401  bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
403  bool LoadKey(const CKey& key, const CPubKey &pubkey);
405  bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
407  bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret, bool checksum_valid);
408  void UpdateTimeFirstKey(int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
410  bool LoadCScript(const CScript& redeemScript);
412  void LoadKeyMetadata(const CKeyID& keyID, const CKeyMetadata &metadata);
413  void LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata &metadata);
415  CPubKey GenerateNewKey(WalletBatch& batch, CHDChain& hd_chain, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
416 
417  /* Set the HD chain model (chain child index counters) and writes it to the database */
418  void AddHDChain(const CHDChain& chain);
420  void LoadHDChain(const CHDChain& chain);
421  const CHDChain& GetHDChain() const { return m_hd_chain; }
422  void AddInactiveHDChain(const CHDChain& chain);
423 
425  bool LoadWatchOnly(const CScript &dest);
427  bool HaveWatchOnly(const CScript &dest) const;
429  bool HaveWatchOnly() const;
431  bool RemoveWatchOnly(const CScript &dest);
432  bool AddWatchOnly(const CScript& dest, int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
433 
435  bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const;
436 
437  /* SigningProvider overrides */
438  bool HaveKey(const CKeyID &address) const override;
439  bool GetKey(const CKeyID &address, CKey& keyOut) const override;
440  bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
441  bool AddCScript(const CScript& redeemScript) override;
442  bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override;
443 
445  void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool);
446  bool NewKeyPool();
448 
449  bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
450  bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
451  bool ImportPubKeys(const std::vector<CKeyID>& ordered_pubkeys, const std::map<CKeyID, CPubKey>& pubkey_map, const std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>>& key_origins, const bool add_keypool, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
452  bool ImportScriptPubKeys(const std::set<CScript>& script_pub_keys, const bool have_solving_data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
453 
454  /* Returns true if the wallet can generate new keys */
455  bool CanGenerateKeys() const;
456 
457  /* Generates a new HD seed (will not be activated) */
459 
460  /* Derives a new HD seed (will not be activated) */
461  CPubKey DeriveNewSeed(const CKey& key);
462 
463  /* Set the current HD seed (will reset the chain child index counters)
464  Sets the seed's version based on the current wallet version (so the
465  caller must ensure the current wallet version is correct before calling
466  this function). */
467  void SetHDSeed(const CPubKey& key);
468 
475  void LearnRelatedScripts(const CPubKey& key, OutputType);
476 
481  void LearnAllRelatedScripts(const CPubKey& key);
482 
487  const std::map<CKeyID, int64_t>& GetAllReserveKeys() const { return m_pool_key_to_index; }
488 
489  std::set<CKeyID> GetKeys() const override;
490 };
491 
494 {
495 private:
497 public:
498  explicit LegacySigningProvider(const LegacyScriptPubKeyMan& spk_man) : m_spk_man(spk_man) {}
499 
500  bool GetCScript(const CScriptID &scriptid, CScript& script) const override { return m_spk_man.GetCScript(scriptid, script); }
501  bool HaveCScript(const CScriptID &scriptid) const override { return m_spk_man.HaveCScript(scriptid); }
502  bool GetPubKey(const CKeyID &address, CPubKey& pubkey) const override { return m_spk_man.GetPubKey(address, pubkey); }
503  bool GetKey(const CKeyID &address, CKey& key) const override { return false; }
504  bool HaveKey(const CKeyID &address) const override { return false; }
505  bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override { return m_spk_man.GetKeyOrigin(keyid, info); }
506 };
507 
509 {
510 private:
511  using ScriptPubKeyMap = std::map<CScript, int32_t>; // Map of scripts to descriptor range index
512  using PubKeyMap = std::map<CPubKey, int32_t>; // Map of pubkeys involved in scripts to descriptor range index
513  using CryptedKeyMap = std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char>>>;
514  using KeyMap = std::map<CKeyID, CKey>;
515 
516  ScriptPubKeyMap m_map_script_pub_keys GUARDED_BY(cs_desc_man);
517  PubKeyMap m_map_pubkeys GUARDED_BY(cs_desc_man);
518  int32_t m_max_cached_index = -1;
519 
520  KeyMap m_map_keys GUARDED_BY(cs_desc_man);
521  CryptedKeyMap m_map_crypted_keys GUARDED_BY(cs_desc_man);
522 
525 
526  bool AddDescriptorKeyWithDB(WalletBatch& batch, const CKey& key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
527 
529 
530  // Fetch the SigningProvider for the given script and optionally include private keys
531  std::unique_ptr<FlatSigningProvider> GetSigningProvider(const CScript& script, bool include_private = false) const;
532  // Fetch the SigningProvider for the given pubkey and always include private keys. This should only be called by signing code.
533  std::unique_ptr<FlatSigningProvider> GetSigningProvider(const CPubKey& pubkey) const;
534  // Fetch the SigningProvider for a given index and optionally include private keys. Called by the above functions.
535  std::unique_ptr<FlatSigningProvider> GetSigningProvider(int32_t index, bool include_private = false) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
536 
537 protected:
538  WalletDescriptor m_wallet_descriptor GUARDED_BY(cs_desc_man);
539 
540 public:
542  : ScriptPubKeyMan(storage),
543  m_wallet_descriptor(descriptor)
544  {}
546  : ScriptPubKeyMan(storage)
547  {}
548 
550 
551  bool GetNewDestination(const OutputType type, CTxDestination& dest, bilingual_str& error) override;
552  isminetype IsMine(const CScript& script) const override;
553 
554  bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) override;
555  bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) override;
556 
557  bool GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool, bilingual_str& error) override;
558  void ReturnDestination(int64_t index, bool internal, const CTxDestination& addr) override;
559 
560  // Tops up the descriptor cache and m_map_script_pub_keys. The cache is stored in the wallet file
561  // and is used to expand the descriptor in GetNewDestination. DescriptorScriptPubKeyMan relies
562  // more on ephemeral data than LegacyScriptPubKeyMan. For wallets using unhardened derivation
563  // (with or without private keys), the "keypool" is a single xpub.
564  bool TopUp(unsigned int size = 0) override;
565 
566  void MarkUnusedAddresses(const CScript& script) override;
567 
568  bool IsHDEnabled() const override;
569 
571  bool SetupDescriptorGeneration(const CExtKey& master_key, OutputType addr_type, bool internal);
572 
576  bool SetupDescriptor(std::unique_ptr<Descriptor>desc);
577 
578  bool HavePrivateKeys() const override;
579 
580  int64_t GetOldestKeyPoolTime() const override;
581  unsigned int GetKeyPoolSize() const override;
582 
583  int64_t GetTimeFirstKey() const override;
584 
585  std::unique_ptr<CKeyMetadata> GetMetadata(const CTxDestination& dest) const override;
586 
587  bool CanGetAddresses(bool internal = false) const override;
588 
589  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const override;
590 
591  bool CanProvide(const CScript& script, SignatureData& sigdata) override;
592 
593  bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const override;
594  SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const override;
595  TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = 1 /* SIGHASH_ALL */, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr) const override;
596 
597  uint256 GetID() const override;
598 
599  void SetCache(const DescriptorCache& cache);
600 
601  bool AddKey(const CKeyID& key_id, const CKey& key);
602  bool AddCryptedKey(const CKeyID& key_id, const CPubKey& pubkey, const std::vector<unsigned char>& crypted_key);
603 
604  bool HasWalletDescriptor(const WalletDescriptor& desc) const;
605  void UpdateWalletDescriptor(WalletDescriptor& descriptor);
606  bool CanUpdateToWalletDescriptor(const WalletDescriptor& descriptor, std::string& error);
607  void AddDescriptorKey(const CKey& key, const CPubKey &pubkey);
608  void WriteDescriptor();
609 
611  const std::vector<CScript> GetScriptPubKeys() const;
612 
613  bool GetDescriptorString(std::string& out, const bool priv) const;
614 
615  void UpgradeDescriptorCache();
616 };
617 
618 #endif // BITCOIN_WALLET_SCRIPTPUBKEYMAN_H
LegacyScriptPubKeyMan::TopUp
bool TopUp(unsigned int size=0) override
Fills internal address pool.
Definition: scriptpubkeyman.cpp:1247
DescriptorScriptPubKeyMan::CheckDecryptionKey
bool CheckDecryptionKey(const CKeyingMaterial &master_key, bool accept_no_keys=false) override
Check that the given decryption key is valid for this ScriptPubKeyMan, i.e. it decrypts all of the ke...
Definition: scriptpubkeyman.cpp:1669
ScriptPubKeyMan::GetNewDestination
virtual bool GetNewDestination(const OutputType type, CTxDestination &dest, bilingual_str &error)
Definition: scriptpubkeyman.h:166
LegacyScriptPubKeyMan::KeepDestination
void KeepDestination(int64_t index, const OutputType &type) override
Definition: scriptpubkeyman.cpp:1309
DescriptorScriptPubKeyMan::SignMessage
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const override
Sign a message with the given script.
Definition: scriptpubkeyman.cpp:2063
ScriptPubKeyMan::m_storage
WalletStorage & m_storage
Definition: scriptpubkeyman.h:161
LegacyScriptPubKeyMan::AddKeypoolPubkeyWithDB
void AddKeypoolPubkeyWithDB(const CPubKey &pubkey, const bool internal, WalletBatch &batch)
Definition: scriptpubkeyman.cpp:1293
crypter.h
LegacyScriptPubKeyMan::HavePrivateKeys
bool HavePrivateKeys() const override
Definition: scriptpubkeyman.cpp:500
LegacyScriptPubKeyMan::TopUpInactiveHDChain
bool TopUpInactiveHDChain(const CKeyID seed_id, int64_t index, bool internal)
Like TopUp() but adds keys for inactive HD chains.
Definition: scriptpubkeyman.cpp:320
DescriptorScriptPubKeyMan::GUARDED_BY
ScriptPubKeyMap m_map_script_pub_keys GUARDED_BY(cs_desc_man)
LegacySigningProvider::GetCScript
bool GetCScript(const CScriptID &scriptid, CScript &script) const override
Definition: scriptpubkeyman.h:500
DescriptorScriptPubKeyMan::GetReservedDestination
bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool, bilingual_str &error) override
Definition: scriptpubkeyman.cpp:1724
LegacyScriptPubKeyMan::IsHDEnabled
bool IsHDEnabled() const override
Definition: scriptpubkeyman.cpp:437
LegacyScriptPubKeyMan::UpdateTimeFirstKey
void UpdateTimeFirstKey(int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Update wallet first key creation time.
Definition: scriptpubkeyman.cpp:691
OutputType
OutputType
Definition: outputtype.h:18
LegacySigningProvider::LegacySigningProvider
LegacySigningProvider(const LegacyScriptPubKeyMan &spk_man)
Definition: scriptpubkeyman.h:498
LegacyScriptPubKeyMan::GetWatchPubKey
bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const
Fetches a pubkey from mapWatchKeys if it exists there.
Definition: scriptpubkeyman.cpp:1007
DEFAULT_KEYPOOL_SIZE
static const unsigned int DEFAULT_KEYPOOL_SIZE
Default for -keypool.
Definition: scriptpubkeyman.h:48
LegacyScriptPubKeyMan::AddKeyPubKey
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override
Adds a key to the store, and saves it to disk.
Definition: scriptpubkeyman.cpp:708
LegacyScriptPubKeyMan::AddWatchOnly
bool AddWatchOnly(const CScript &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Private version of AddWatchOnly method which does not accept a timestamp, and which will reset the wa...
Definition: scriptpubkeyman.cpp:922
CKeyPool::Unserialize
void Unserialize(Stream &s)
Definition: scriptpubkeyman.h:127
ScriptPubKeyMan::RewriteDB
virtual void RewriteDB()
The action to do when the DB needs rewrite.
Definition: scriptpubkeyman.h:204
DescriptorScriptPubKeyMan::MarkUnusedAddresses
void MarkUnusedAddresses(const CScript &script) override
Mark unused addresses as being used.
Definition: scriptpubkeyman.cpp:1823
LegacyScriptPubKeyMan::MarkUnusedAddresses
void MarkUnusedAddresses(const CScript &script) override
Mark unused addresses as being used.
Definition: scriptpubkeyman.cpp:357
DescriptorScriptPubKeyMan::SignTransaction
bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, int sighash, std::map< int, bilingual_str > &input_errors) const override
Creates new signatures and adds them to the transaction.
Definition: scriptpubkeyman.cpp:2049
CKeyPool
A key from a CWallet's keypool.
Definition: scriptpubkeyman.h:101
LegacyScriptPubKeyMan::GetHDChain
const CHDChain & GetHDChain() const
Definition: scriptpubkeyman.h:421
DescriptorScriptPubKeyMan::SetupDescriptorGeneration
bool SetupDescriptorGeneration(const CExtKey &master_key, OutputType addr_type, bool internal)
Setup descriptors based on the given CExtkey.
Definition: scriptpubkeyman.cpp:1877
LegacyScriptPubKeyMan::GetKeyPoolSize
unsigned int GetKeyPoolSize() const override
Definition: scriptpubkeyman.cpp:555
LegacySigningProvider::GetKeyOrigin
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
Definition: scriptpubkeyman.h:505
DescriptorScriptPubKeyMan::DescriptorScriptPubKeyMan
DescriptorScriptPubKeyMan(WalletStorage &storage)
Definition: scriptpubkeyman.h:545
DescriptorScriptPubKeyMan::GetSolvingProvider
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const override
Definition: scriptpubkeyman.cpp:2039
LegacyScriptPubKeyMan::AddCryptedKeyInner
bool AddCryptedKeyInner(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret)
Definition: scriptpubkeyman.cpp:817
LegacyScriptPubKeyMan::m_index_to_reserved_key
std::map< int64_t, CKeyID > m_index_to_reserved_key
Definition: scriptpubkeyman.h:311
LegacyScriptPubKeyMan::CanGetAddresses
bool CanGetAddresses(bool internal=false) const override
Definition: scriptpubkeyman.cpp:442
OutputType::LEGACY
@ LEGACY
LegacyScriptPubKeyMan::GetNewDestination
bool GetNewDestination(const OutputType type, CTxDestination &dest, bilingual_str &error) override
Definition: scriptpubkeyman.cpp:23
LegacyScriptPubKeyMan::GUARDED_BY
WalletBatch *encrypted_batch GUARDED_BY(cs_KeyStore)
ScriptPubKeyMan::IsMine
virtual isminetype IsMine(const CScript &script) const
Definition: scriptpubkeyman.h:167
FillableSigningProvider
Fillable signing provider that keeps keys in an address->secret map.
Definition: signingprovider.h:91
LegacyScriptPubKeyMan::LoadKeyPool
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool)
Load a keypool entry.
Definition: scriptpubkeyman.cpp:1130
DescriptorScriptPubKeyMan::HasWalletDescriptor
bool HasWalletDescriptor(const WalletDescriptor &desc) const
Definition: scriptpubkeyman.cpp:2229
LegacyScriptPubKeyMan::LearnRelatedScripts
void LearnRelatedScripts(const CPubKey &key, OutputType)
Explicitly make the wallet learn the related scripts for outputs to the given key.
Definition: scriptpubkeyman.cpp:1412
DescriptorScriptPubKeyMan::SetupDescriptor
bool SetupDescriptor(std::unique_ptr< Descriptor >desc)
Provide a descriptor at setup time Returns false if already setup or setup fails, true if setup is su...
LegacyScriptPubKeyMan::WatchOnlySet
std::set< CScript > WatchOnlySet
Definition: scriptpubkeyman.h:256
bilingual_str
Bilingual messages:
Definition: translation.h:16
DescriptorScriptPubKeyMan::IsMine
isminetype IsMine(const CScript &script) const override
Definition: scriptpubkeyman.cpp:1660
CKeyingMaterial
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
Definition: crypter.h:61
DescriptorScriptPubKeyMan::UpdateWalletDescriptor
void UpdateWalletDescriptor(WalletDescriptor &descriptor)
Definition: scriptpubkeyman.cpp:2307
WalletStorage::GetDisplayName
virtual const std::string GetDisplayName() const =0
LegacyScriptPubKeyMan::UpgradeKeyMetadata
void UpgradeKeyMetadata()
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
Definition: scriptpubkeyman.cpp:389
LegacyScriptPubKeyMan::NewKeyPool
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
Definition: scriptpubkeyman.cpp:1213
LegacyScriptPubKeyMan::LoadKeyMetadata
void LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &metadata)
Load metadata (used by LoadWallet)
Definition: scriptpubkeyman.cpp:770
DescriptorScriptPubKeyMan::IsHDEnabled
bool IsHDEnabled() const override
Definition: scriptpubkeyman.cpp:1951
SigningProvider
An interface to be implemented by keystores that support signing.
Definition: signingprovider.h:18
LegacyScriptPubKeyMan::GetTimeFirstKey
int64_t GetTimeFirstKey() const override
Definition: scriptpubkeyman.cpp:561
GetTime
int64_t GetTime()
DEPRECATED Use either GetTimeSeconds (not mockable) or GetTime<T> (mockable)
Definition: time.cpp:26
LegacyScriptPubKeyMan::Encrypt
bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch) override
Definition: scriptpubkeyman.cpp:268
LegacyScriptPubKeyMan::GetKeyFromPool
bool GetKeyFromPool(CPubKey &key, const OutputType type, bool internal=false)
Fetches a key from the keypool.
Definition: scriptpubkeyman.cpp:1343
LegacyScriptPubKeyMan::SetHDSeed
void SetHDSeed(const CPubKey &key)
Definition: scriptpubkeyman.cpp:1194
AnnotatedMixin< std::recursive_mutex >
LegacyScriptPubKeyMan::FillPSBT
TransactionError FillPSBT(PartiallySignedTransaction &psbt, const PrecomputedTransactionData &txdata, int sighash_type=1, bool sign=true, bool bip32derivs=false, int *n_signed=nullptr) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
Definition: scriptpubkeyman.cpp:613
LegacySigningProvider::GetKey
bool GetKey(const CKeyID &address, CKey &key) const override
Definition: scriptpubkeyman.h:503
ScriptPubKeyMan::KeepDestination
virtual void KeepDestination(int64_t index, const OutputType &type)
Definition: scriptpubkeyman.h:174
ScriptPubKeyMan::WalletLogPrintf
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
Definition: scriptpubkeyman.h:232
LegacyScriptPubKeyMan::SignTransaction
bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, int sighash, std::map< int, bilingual_str > &input_errors) const override
Creates new signatures and adds them to the transaction.
Definition: scriptpubkeyman.cpp:595
DescriptorScriptPubKeyMan::UpgradeDescriptorCache
void UpgradeDescriptorCache()
Definition: scriptpubkeyman.cpp:2278
DescriptorScriptPubKeyMan::CanProvide
bool CanProvide(const CScript &script, SignatureData &sigdata) override
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that,...
Definition: scriptpubkeyman.cpp:2044
WalletDatabase
An instance of this class represents one database.
Definition: db.h:103
LegacyScriptPubKeyMan::GetKeys
std::set< CKeyID > GetKeys() const override
Definition: scriptpubkeyman.cpp:1603
LegacyScriptPubKeyMan::m_pool_key_to_index
std::map< CKeyID, int64_t > m_pool_key_to_index
Definition: scriptpubkeyman.h:309
CKeyID
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:22
ScriptPubKeyMan::~ScriptPubKeyMan
virtual ~ScriptPubKeyMan()
Definition: scriptpubkeyman.h:165
DescriptorScriptPubKeyMan::PubKeyMap
std::map< CPubKey, int32_t > PubKeyMap
Definition: scriptpubkeyman.h:512
ScriptPubKeyMan::HavePrivateKeys
virtual bool HavePrivateKeys() const
Definition: scriptpubkeyman.h:201
LegacyScriptPubKeyMan
Definition: scriptpubkeyman.h:250
DescriptorScriptPubKeyMan::GetSigningProvider
std::unique_ptr< FlatSigningProvider > GetSigningProvider(const CScript &script, bool include_private=false) const
Definition: scriptpubkeyman.cpp:1993
CKeyPool::nTime
int64_t nTime
The time at which the key was generated. Set in AddKeypoolPubKeyWithDB.
Definition: scriptpubkeyman.h:105
ScriptPubKeyMan::CanProvide
virtual bool CanProvide(const CScript &script, SignatureData &sigdata)
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that,...
Definition: scriptpubkeyman.h:219
DescriptorScriptPubKeyMan::KeyMap
std::map< CKeyID, CKey > KeyMap
Definition: scriptpubkeyman.h:514
LegacyScriptPubKeyMan::m_inactive_hd_chains
std::unordered_map< CKeyID, CHDChain, SaltedSipHasher > m_inactive_hd_chains
Definition: scriptpubkeyman.h:300
LegacyScriptPubKeyMan::LoadKey
bool LoadKey(const CKey &key, const CPubKey &pubkey)
Adds a key to the store, without saving it to disk (used by LoadWallet)
Definition: scriptpubkeyman.cpp:703
LegacyScriptPubKeyMan::GetKey
bool GetKey(const CKeyID &address, CKey &keyOut) const override
Definition: scriptpubkeyman.cpp:971
SigningResult
SigningResult
Definition: message.h:42
LegacyScriptPubKeyMan::ReturnDestination
void ReturnDestination(int64_t index, bool internal, const CTxDestination &) override
Definition: scriptpubkeyman.cpp:1323
LegacyScriptPubKeyMan::MarkPreSplitKeys
void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1466
DescriptorScriptPubKeyMan::m_decryption_thoroughly_checked
bool m_decryption_thoroughly_checked
keeps track of whether Unlock has run a thorough check before
Definition: scriptpubkeyman.h:524
DescriptorScriptPubKeyMan::HavePrivateKeys
bool HavePrivateKeys() const override
Definition: scriptpubkeyman.cpp:1967
LegacyScriptPubKeyMan::Upgrade
bool Upgrade(int prev_version, int new_version, bilingual_str &error) override
Upgrades the wallet to the specified version.
Definition: scriptpubkeyman.cpp:459
LegacyScriptPubKeyMan::KeypoolCountExternalKeys
size_t KeypoolCountExternalKeys() const
Definition: scriptpubkeyman.cpp:549
DescriptorScriptPubKeyMan
Definition: scriptpubkeyman.h:508
DescriptorScriptPubKeyMan::CanGetAddresses
bool CanGetAddresses(bool internal=false) const override
Definition: scriptpubkeyman.cpp:1957
signingprovider.h
ismine.h
TransactionError
TransactionError
Definition: error.h:22
WalletStorage::GetDatabase
virtual WalletDatabase & GetDatabase() const =0
DescriptorScriptPubKeyMan::ReturnDestination
void ReturnDestination(int64_t index, bool internal, const CTxDestination &addr) override
Definition: scriptpubkeyman.cpp:1732
DescriptorScriptPubKeyMan::AddDescriptorKey
void AddDescriptorKey(const CKey &key, const CPubKey &pubkey)
Definition: scriptpubkeyman.cpp:1838
LegacyScriptPubKeyMan::LoadCScript
bool LoadCScript(const CScript &redeemScript)
Adds a CScript to the store.
Definition: scriptpubkeyman.cpp:755
walletutil.h
DescriptorScriptPubKeyMan::FillPSBT
TransactionError FillPSBT(PartiallySignedTransaction &psbt, const PrecomputedTransactionData &txdata, int sighash_type=1, bool sign=true, bool bip32derivs=false, int *n_signed=nullptr) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
Definition: scriptpubkeyman.cpp:2081
ScriptPubKeyMan::FillPSBT
virtual TransactionError FillPSBT(PartiallySignedTransaction &psbt, const PrecomputedTransactionData &txdata, int sighash_type=1, bool sign=true, bool bip32derivs=false, int *n_signed=nullptr) const
Adds script and derivation path information to a PSBT, and optionally signs it.
Definition: scriptpubkeyman.h:226
WalletStorage
Definition: scriptpubkeyman.h:32
isminetype
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
Definition: ismine.h:38
CKeyPool::m_pre_split
bool m_pre_split
Whether this key was generated for a keypool before the wallet was upgraded to HD-split.
Definition: scriptpubkeyman.h:111
LegacyScriptPubKeyMan::LoadHDChain
void LoadHDChain(const CHDChain &chain)
Load a HD chain model (used by LoadWallet)
Definition: scriptpubkeyman.cpp:934
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
ScriptPubKeyMan::GetKeyPoolSize
virtual unsigned int GetKeyPoolSize() const
Definition: scriptpubkeyman.h:208
SignatureData
Definition: sign.h:65
LegacyScriptPubKeyMan::AddKeyPubKeyInner
bool AddKeyPubKeyInner(const CKey &key, const CPubKey &pubkey)
Definition: scriptpubkeyman.cpp:784
LegacyScriptPubKeyMan::DeriveNewSeed
CPubKey DeriveNewSeed(const CKey &key)
Definition: scriptpubkeyman.cpp:1166
CExtKey
Definition: key.h:160
Coin
A UTXO entry.
Definition: coins.h:30
ScriptPubKeyMan::SignTransaction
virtual bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, int sighash, std::map< int, bilingual_str > &input_errors) const
Creates new signatures and adds them to the transaction.
Definition: scriptpubkeyman.h:222
LegacyScriptPubKeyMan::GenerateNewSeed
CPubKey GenerateNewSeed()
Definition: scriptpubkeyman.cpp:1158
ScriptPubKeyMan::NotifyWatchonlyChanged
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition: scriptpubkeyman.h:234
LegacySigningProvider::GetPubKey
bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const override
Definition: scriptpubkeyman.h:502
LegacyScriptPubKeyMan::HaveKey
bool HaveKey(const CKeyID &address) const override
Definition: scriptpubkeyman.cpp:962
DescriptorScriptPubKeyMan::GetDescriptorString
bool GetDescriptorString(std::string &out, const bool priv) const
Definition: scriptpubkeyman.cpp:2261
LegacyScriptPubKeyMan::DeriveNewChildKey
void DeriveNewChildKey(WalletBatch &batch, CKeyMetadata &metadata, CKey &secret, CHDChain &hd_chain, bool internal=false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1075
LegacyScriptPubKeyMan::GenerateNewKey
CPubKey GenerateNewKey(WalletBatch &batch, CHDChain &hd_chain, bool internal=false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Generate a new key.
Definition: scriptpubkeyman.cpp:1038
ScriptPubKeyMan::IsHDEnabled
virtual bool IsHDEnabled() const
Definition: scriptpubkeyman.h:193
message.h
LegacyScriptPubKeyMan::SetupGeneration
bool SetupGeneration(bool force=false) override
Sets up the key generation stuff, i.e.
Definition: scriptpubkeyman.cpp:424
ScriptPubKeyMan::MarkUnusedAddresses
virtual void MarkUnusedAddresses(const CScript &script)
Mark unused addresses as being used.
Definition: scriptpubkeyman.h:184
DescriptorScriptPubKeyMan::GetNewDestination
bool GetNewDestination(const OutputType type, CTxDestination &dest, bilingual_str &error) override
Definition: scriptpubkeyman.cpp:1616
LegacySigningProvider::HaveKey
bool HaveKey(const CKeyID &address) const override
Definition: scriptpubkeyman.h:504
LegacyScriptPubKeyMan::RewriteDB
void RewriteDB() override
The action to do when the DB needs rewrite.
Definition: scriptpubkeyman.cpp:506
DescriptorScriptPubKeyMan::AddCryptedKey
bool AddCryptedKey(const CKeyID &key_id, const CPubKey &pubkey, const std::vector< unsigned char > &crypted_key)
Definition: scriptpubkeyman.cpp:2218
LegacyScriptPubKeyMan::m_hd_chain
CHDChain m_hd_chain
Definition: scriptpubkeyman.h:299
TransactionError::INVALID_PSBT
@ INVALID_PSBT
time.h
DescriptorScriptPubKeyMan::CryptedKeyMap
std::map< CKeyID, std::pair< CPubKey, std::vector< unsigned char > >> CryptedKeyMap
Definition: scriptpubkeyman.h:513
LegacyScriptPubKeyMan::CheckDecryptionKey
bool CheckDecryptionKey(const CKeyingMaterial &master_key, bool accept_no_keys=false) override
Check that the given decryption key is valid for this ScriptPubKeyMan, i.e. it decrypts all of the ke...
Definition: scriptpubkeyman.cpp:228
LogPrintf
#define LogPrintf(...)
Definition: logging.h:187
standard.h
LegacyScriptPubKeyMan::SignMessage
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const override
Sign a message with the given script.
Definition: scriptpubkeyman.cpp:600
FillableSigningProvider::HaveCScript
virtual bool HaveCScript(const CScriptID &hash) const override
Definition: signingprovider.cpp:163
WalletStorage::HasEncryptionKeys
virtual bool HasEncryptionKeys() const =0
CKeyPool::vchPubKey
CPubKey vchPubKey
The public key.
Definition: scriptpubkeyman.h:107
LegacySigningProvider::HaveCScript
bool HaveCScript(const CScriptID &scriptid) const override
Definition: scriptpubkeyman.h:501
error.h
LegacyScriptPubKeyMan::ImportPubKeys
bool ImportPubKeys(const std::vector< CKeyID > &ordered_pubkeys, const std::map< CKeyID, CPubKey > &pubkey_map, const std::map< CKeyID, std::pair< CPubKey, KeyOriginInfo >> &key_origins, const bool add_keypool, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1558
LegacyScriptPubKeyMan::GetOldestKeyPoolTime
int64_t GetOldestKeyPoolTime() const override
Definition: scriptpubkeyman.cpp:531
PrecomputedTransactionData
Definition: interpreter.h:150
LegacyScriptPubKeyMan::AddCScript
bool AddCScript(const CScript &redeemScript) override
Definition: scriptpubkeyman.cpp:1484
uint256
256-bit opaque blob.
Definition: uint256.h:124
ISMINE_NO
@ ISMINE_NO
Definition: ismine.h:40
LegacyScriptPubKeyMan::AddCScriptWithDB
bool AddCScriptWithDB(WalletBatch &batch, const CScript &script)
Adds a script to the store and saves it to disk.
Definition: scriptpubkeyman.cpp:1490
LegacyScriptPubKeyMan::WatchKeyMap
std::map< CKeyID, CPubKey > WatchKeyMap
Definition: scriptpubkeyman.h:257
LegacyScriptPubKeyMan::LearnAllRelatedScripts
void LearnAllRelatedScripts(const CPubKey &key)
Same as LearnRelatedScripts, but when the OutputType is not known (and could be anything).
Definition: scriptpubkeyman.cpp:1424
WalletStorage::UnsetBlankWalletFlag
virtual void UnsetBlankWalletFlag(WalletBatch &)=0
LegacyScriptPubKeyMan::CryptedKeyMap
std::map< CKeyID, std::pair< CPubKey, std::vector< unsigned char > >> CryptedKeyMap
Definition: scriptpubkeyman.h:261
ScriptPubKeyMan::GetID
virtual uint256 GetID() const
Definition: scriptpubkeyman.h:228
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
LegacyScriptPubKeyMan::IsMine
isminetype IsMine(const CScript &script) const override
Definition: scriptpubkeyman.cpp:214
DescriptorScriptPubKeyMan::GetOldestKeyPoolTime
int64_t GetOldestKeyPoolTime() const override
Definition: scriptpubkeyman.cpp:1973
LegacyScriptPubKeyMan::ImportPrivKeys
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1535
WalletStorage::IsWalletFlagSet
virtual bool IsWalletFlagSet(uint64_t) const =0
ScriptPubKeyMan::ScriptPubKeyMan
ScriptPubKeyMan(WalletStorage &storage)
Definition: scriptpubkeyman.h:164
ScriptPubKeyMan::Upgrade
virtual bool Upgrade(int prev_version, int new_version, bilingual_str &error)
Upgrades the wallet to the specified version.
Definition: scriptpubkeyman.h:199
LegacyScriptPubKeyMan::GetAllReserveKeys
const std::map< CKeyID, int64_t > & GetAllReserveKeys() const
Definition: scriptpubkeyman.h:487
LegacyScriptPubKeyMan::GetID
uint256 GetID() const override
Definition: scriptpubkeyman.cpp:682
DescriptorCache
Cache for single descriptor's derived extended pubkeys.
Definition: descriptor.h:19
LEGACY_OUTPUT_TYPES
static const std::unordered_set< OutputType > LEGACY_OUTPUT_TYPES
OutputTypes supported by the LegacyScriptPubKeyMan.
Definition: scriptpubkeyman.h:244
CKeyPool::CKeyPool
CKeyPool()
Definition: wallet.cpp:2929
LegacyScriptPubKeyMan::LoadCryptedKey
bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret, bool checksum_valid)
Adds an encrypted key to the store, without saving it to disk (used by LoadWallet)
Definition: scriptpubkeyman.cpp:807
LegacyScriptPubKeyMan::AddCryptedKey
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret)
Adds an encrypted key to the store, and saves it to disk.
Definition: scriptpubkeyman.cpp:827
OutputType::P2SH_SEGWIT
@ P2SH_SEGWIT
DescriptorScriptPubKeyMan::GetID
uint256 GetID() const override
Definition: scriptpubkeyman.cpp:2172
OutputType::BECH32
@ BECH32
PKHash
Definition: standard.h:79
DescriptorScriptPubKeyMan::AddDescriptorKeyWithDB
bool AddDescriptorKeyWithDB(WalletBatch &batch, const CKey &key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
Definition: scriptpubkeyman.cpp:1847
LegacyScriptPubKeyMan::LoadScriptMetadata
void LoadScriptMetadata(const CScriptID &script_id, const CKeyMetadata &metadata)
Definition: scriptpubkeyman.cpp:777
DescriptorScriptPubKeyMan::cs_desc_man
RecursiveMutex cs_desc_man
Definition: scriptpubkeyman.h:549
CPubKey
An encapsulated public key.
Definition: pubkey.h:32
LegacyScriptPubKeyMan::CanProvide
bool CanProvide(const CScript &script, SignatureData &sigdata) override
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that,...
Definition: scriptpubkeyman.cpp:572
DescriptorScriptPubKeyMan::ScriptPubKeyMap
std::map< CScript, int32_t > ScriptPubKeyMap
Definition: scriptpubkeyman.h:511
LegacyScriptPubKeyMan::ImportScriptPubKeys
bool ImportScriptPubKeys(const std::set< CScript > &script_pub_keys, const bool have_solving_data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1590
ScriptPubKeyMan
Definition: scriptpubkeyman.h:158
LegacyScriptPubKeyMan::AddKeyOriginWithDB
bool AddKeyOriginWithDB(WalletBatch &batch, const CPubKey &pubkey, const KeyOriginInfo &info)
Add a KeyOriginInfo to the wallet.
Definition: scriptpubkeyman.cpp:1501
CKey
An encapsulated private key.
Definition: key.h:26
DescriptorScriptPubKeyMan::GetKeyPoolSize
unsigned int GetKeyPoolSize() const override
Definition: scriptpubkeyman.cpp:1981
DescriptorScriptPubKeyMan::GetMetadata
std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const override
Definition: scriptpubkeyman.cpp:2154
CHDChain
Definition: walletdb.h:87
ScriptPubKeyMan::Encrypt
virtual bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch)
Definition: scriptpubkeyman.h:171
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
DescriptorScriptPubKeyMan::GetWalletDescriptor
const WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
Definition: scriptpubkeyman.cpp:2244
DescriptorScriptPubKeyMan::TopUp
bool TopUp(unsigned int size=0) override
Fills internal address pool.
Definition: scriptpubkeyman.cpp:1760
LegacyScriptPubKeyMan::GetSolvingProvider
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const override
Definition: scriptpubkeyman.cpp:567
PartiallySignedTransaction
A version of CTransaction with the PSBT format.
Definition: psbt.h:391
WalletStorage::~WalletStorage
virtual ~WalletStorage()=default
LegacyScriptPubKeyMan::LoadWatchOnly
bool LoadWatchOnly(const CScript &dest)
Adds a watch-only address to the store, without saving it to disk (used by LoadWallet)
Definition: scriptpubkeyman.cpp:885
WalletStorage::GetEncryptionKey
virtual const CKeyingMaterial & GetEncryptionKey() const =0
GetAffectedKeys
std::vector< CKeyID > GetAffectedKeys(const CScript &spk, const SigningProvider &provider)
Definition: scriptpubkeyman.cpp:1454
SigningResult::SIGNING_FAILED
@ SIGNING_FAILED
DescriptorScriptPubKeyMan::m_max_cached_index
int32_t m_max_cached_index
Definition: scriptpubkeyman.h:518
LegacyScriptPubKeyMan::GetPubKey
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
Definition: scriptpubkeyman.cpp:1018
LegacyScriptPubKeyMan::RemoveWatchOnly
bool RemoveWatchOnly(const CScript &dest)
Remove a watch only script from the keystore.
Definition: scriptpubkeyman.cpp:864
ScriptPubKeyMan::GetReservedDestination
virtual bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool, bilingual_str &error)
Definition: scriptpubkeyman.h:173
ScriptPubKeyMan::TopUp
virtual bool TopUp(unsigned int size=0)
Fills internal address pool.
Definition: scriptpubkeyman.h:181
ScriptPubKeyMan::SetupGeneration
virtual bool SetupGeneration(bool force=false)
Sets up the key generation stuff, i.e.
Definition: scriptpubkeyman.h:190
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:561
LegacySigningProvider::m_spk_man
const LegacyScriptPubKeyMan & m_spk_man
Definition: scriptpubkeyman.h:496
LegacyScriptPubKeyMan::HaveWatchOnly
bool HaveWatchOnly() const
Returns whether there are any watch-only things in the wallet.
Definition: scriptpubkeyman.cpp:851
ScriptPubKeyMan::GetOldestKeyPoolTime
virtual int64_t GetOldestKeyPoolTime() const
Definition: scriptpubkeyman.h:206
LegacyScriptPubKeyMan::ImportScripts
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1511
DescriptorScriptPubKeyMan::AddKey
bool AddKey(const CKeyID &key_id, const CKey &key)
Definition: scriptpubkeyman.cpp:2211
DescriptorScriptPubKeyMan::GetKeys
KeyMap GetKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
Definition: scriptpubkeyman.cpp:1743
CKeyPool::fInternal
bool fInternal
Whether this keypool entry is in the internal keypool (for change outputs)
Definition: scriptpubkeyman.h:109
ScriptPubKeyMan::GetSolvingProvider
virtual std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Definition: scriptpubkeyman.h:214
LegacyScriptPubKeyMan::MarkReserveKeysAsUsed
void MarkReserveKeysAsUsed(int64_t keypool_id) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Marks all keys in the keypool up to and including reserve_key as used.
Definition: scriptpubkeyman.cpp:1430
LegacyScriptPubKeyMan::AddHDChain
void AddHDChain(const CHDChain &chain)
Definition: scriptpubkeyman.cpp:940
FillableSigningProvider::GetCScript
virtual bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const override
Definition: signingprovider.cpp:179
ScriptPubKeyMan::ReturnDestination
virtual void ReturnDestination(int64_t index, bool internal, const CTxDestination &addr)
Definition: scriptpubkeyman.h:175
WalletDescriptor
Descriptor with some wallet metadata.
Definition: walletutil.h:75
walletdb.h
WalletFeature
WalletFeature
(client) version numbers for particular wallet features
Definition: walletutil.h:14
DescriptorScriptPubKeyMan::WriteDescriptor
void WriteDescriptor()
Definition: scriptpubkeyman.cpp:2235
LegacyScriptPubKeyMan::GetKeyOrigin
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
Definition: scriptpubkeyman.cpp:988
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
LegacyScriptPubKeyMan::fDecryptionThoroughlyChecked
bool fDecryptionThoroughlyChecked
keeps track of whether Unlock has run a thorough check before
Definition: scriptpubkeyman.h:254
ScriptPubKeyMan::GetMetadata
virtual std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const
Definition: scriptpubkeyman.h:212
DescriptorScriptPubKeyMan::GetTimeFirstKey
int64_t GetTimeFirstKey() const override
Definition: scriptpubkeyman.cpp:1987
DescriptorScriptPubKeyMan::GetScriptPubKeys
const std::vector< CScript > GetScriptPubKeys() const
Definition: scriptpubkeyman.cpp:2249
FillableSigningProvider::cs_KeyStore
RecursiveMutex cs_KeyStore
Definition: signingprovider.h:149
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
LegacyScriptPubKeyMan::AddWatchOnlyInMem
bool AddWatchOnlyInMem(const CScript &dest)
Definition: scriptpubkeyman.cpp:890
ScriptPubKeyMan::CheckDecryptionKey
virtual bool CheckDecryptionKey(const CKeyingMaterial &master_key, bool accept_no_keys=false)
Check that the given decryption key is valid for this ScriptPubKeyMan, i.e. it decrypts all of the ke...
Definition: scriptpubkeyman.h:170
WalletStorage::IsLocked
virtual bool IsLocked() const =0
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:344
LegacyScriptPubKeyMan::AddInactiveHDChain
void AddInactiveHDChain(const CHDChain &chain)
Definition: scriptpubkeyman.cpp:955
LegacyScriptPubKeyMan::GetReservedDestination
bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool, bilingual_str &error) override
Definition: scriptpubkeyman.cpp:298
LegacyScriptPubKeyMan::CanGenerateKeys
bool CanGenerateKeys() const
Definition: scriptpubkeyman.cpp:1151
ScriptPubKeyMan::SignMessage
virtual SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
Sign a message with the given script.
Definition: scriptpubkeyman.h:224
DescriptorScriptPubKeyMan::SetCache
void SetCache(const DescriptorCache &cache)
Definition: scriptpubkeyman.cpp:2181
CScriptID
A reference to a CScript: the Hash160 of its serialization (see script.h)
Definition: standard.h:25
DescriptorScriptPubKeyMan::Encrypt
bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch) override
Definition: scriptpubkeyman.cpp:1701
ScriptPubKeyMan::NotifyCanGetAddressesChanged
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
Definition: scriptpubkeyman.h:240
CKeyPool::Serialize
void Serialize(Stream &s) const
Definition: scriptpubkeyman.h:117
WalletBatch
Access to the wallet database.
Definition: walletdb.h:178
LegacyScriptPubKeyMan::GetMetadata
std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const override
Definition: scriptpubkeyman.cpp:661
LegacyScriptPubKeyMan::ReserveKeyFromKeyPool
bool ReserveKeyFromKeyPool(int64_t &nIndex, CKeyPool &keypool, bool fRequestedInternal)
Reserves a key from the keypool and sets nIndex to its index.
Definition: scriptpubkeyman.cpp:1366
ScriptPubKeyMan::CanGetAddresses
virtual bool CanGetAddresses(bool internal=false) const
Definition: scriptpubkeyman.h:196
WalletStorage::SetMinVersion
virtual void SetMinVersion(enum WalletFeature, WalletBatch *=nullptr)=0
LegacySigningProvider
Wraps a LegacyScriptPubKeyMan so that it can be returned in a new unique_ptr.
Definition: scriptpubkeyman.h:493
SER_GETHASH
@ SER_GETHASH
Definition: serialize.h:140
CKeyMetadata
Definition: walletdb.h:123
LegacyScriptPubKeyMan::AddKeyPubKeyWithDB
bool AddKeyPubKeyWithDB(WalletBatch &batch, const CKey &key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Adds a key to the store, and saves it to disk.
Definition: scriptpubkeyman.cpp:715
WalletStorage::CanSupportFeature
virtual bool CanSupportFeature(enum WalletFeature) const =0
DescriptorScriptPubKeyMan::CanUpdateToWalletDescriptor
bool CanUpdateToWalletDescriptor(const WalletDescriptor &descriptor, std::string &error)
Definition: scriptpubkeyman.cpp:2321
KeyOriginInfo
Definition: keyorigin.h:11
FlatSigningProvider
Definition: signingprovider.h:73
descriptor.h
ScriptPubKeyMan::GetTimeFirstKey
virtual int64_t GetTimeFirstKey() const
Definition: scriptpubkeyman.h:210
LegacyScriptPubKeyMan::AddWatchOnlyWithDB
bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:902