Bitcoin ABC  0.24.10
P2P Digital Currency
scriptpubkeyman.h
Go to the documentation of this file.
1 // Copyright (c) 2019 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 <wallet/crypter.h>
15 #include <wallet/ismine.h>
16 #include <wallet/walletdb.h>
17 #include <wallet/walletutil.h>
18 
19 #include <boost/signals2/signal.hpp>
20 
21 #include <unordered_map>
22 
23 enum class OutputType;
24 class CChainParams;
25 struct bilingual_str;
26 
27 // Wallet storage things that ScriptPubKeyMans need in order to be able to store
28 // things to the wallet database. It provides access to things that are part of
29 // the entire wallet and not specific to a ScriptPubKeyMan such as wallet flags,
30 // wallet version, encryption keys, encryption status, and the database itself.
31 // This allows a ScriptPubKeyMan to have callbacks into CWallet without causing
32 // a circular dependency. WalletStorage should be the same for all
33 // ScriptPubKeyMans of a wallet.
35 public:
36  virtual ~WalletStorage() = default;
37  virtual const std::string GetDisplayName() const = 0;
38  virtual WalletDatabase &GetDatabase() = 0;
39  virtual const CChainParams &GetChainParams() const = 0;
40  virtual bool IsWalletFlagSet(uint64_t) const = 0;
41  virtual void UnsetBlankWalletFlag(WalletBatch &) = 0;
42  virtual bool CanSupportFeature(enum WalletFeature) const = 0;
43  virtual void SetMinVersion(enum WalletFeature, WalletBatch * = nullptr,
44  bool = false) = 0;
45  virtual const CKeyingMaterial &GetEncryptionKey() const = 0;
46  virtual bool HasEncryptionKeys() const = 0;
47  virtual bool IsLocked() const = 0;
48 };
49 
51 static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000;
52 
53 std::vector<CKeyID> GetAffectedKeys(const CScript &spk,
54  const SigningProvider &provider);
55 
106 class CKeyPool {
107 public:
109  int64_t nTime;
114  bool fInternal;
118 
119  CKeyPool();
120  CKeyPool(const CPubKey &vchPubKeyIn, bool internalIn);
121 
122  template <typename Stream> void Serialize(Stream &s) const {
123  int nVersion = s.GetVersion();
124  if (!(s.GetType() & SER_GETHASH)) {
125  s << nVersion;
126  }
127  s << nTime << vchPubKey << fInternal << m_pre_split;
128  }
129 
130  template <typename Stream> void Unserialize(Stream &s) {
131  int nVersion = s.GetVersion();
132  if (!(s.GetType() & SER_GETHASH)) {
133  s >> nVersion;
134  }
135  s >> nTime >> vchPubKey;
136  try {
137  s >> fInternal;
138  } catch (std::ios_base::failure &) {
144  fInternal = false;
145  }
146  try {
147  s >> m_pre_split;
148  } catch (std::ios_base::failure &) {
154  m_pre_split = false;
155  }
156  }
157 };
158 
159 class KeyIDHasher {
160 public:
162 
163  size_t operator()(const CKeyID &id) const { return id.GetUint64(0); }
164 };
165 
175 protected:
177 
178 public:
179  ScriptPubKeyMan(WalletStorage &storage) : m_storage(storage) {}
180  virtual ~ScriptPubKeyMan(){};
181  virtual bool GetNewDestination(const OutputType type, CTxDestination &dest,
182  std::string &error) {
183  return false;
184  }
185  virtual isminetype IsMine(const CScript &script) const { return ISMINE_NO; }
186 
189  virtual bool CheckDecryptionKey(const CKeyingMaterial &master_key,
190  bool accept_no_keys = false) {
191  return false;
192  }
193  virtual bool Encrypt(const CKeyingMaterial &master_key,
194  WalletBatch *batch) {
195  return false;
196  }
197 
198  virtual bool GetReservedDestination(const OutputType type, bool internal,
199  CTxDestination &address, int64_t &index,
200  CKeyPool &keypool) {
201  return false;
202  }
203  virtual void KeepDestination(int64_t index, const OutputType &type) {}
204  virtual void ReturnDestination(int64_t index, bool internal,
205  const CTxDestination &addr) {}
206 
214  virtual bool TopUp(unsigned int size = 0) { return false; }
215 
217  virtual void MarkUnusedAddresses(const CScript &script) {}
218 
225  virtual bool SetupGeneration(bool force = false) { return false; }
226 
227  /* Returns true if HD is enabled */
228  virtual bool IsHDEnabled() const { return false; }
229 
234  virtual bool CanGetAddresses(bool internal = false) const { return false; }
235 
237  virtual bool Upgrade(int prev_version, bilingual_str &error) {
238  return false;
239  }
240 
241  virtual bool HavePrivateKeys() const { return false; }
242 
244  virtual void RewriteDB() {}
245 
246  virtual int64_t GetOldestKeyPoolTime() const { return GetTime(); }
247 
248  virtual size_t KeypoolCountExternalKeys() const { return 0; }
249  virtual unsigned int GetKeyPoolSize() const { return 0; }
250 
251  virtual int64_t GetTimeFirstKey() const { return 0; }
252 
253  virtual std::unique_ptr<CKeyMetadata>
254  GetMetadata(const CTxDestination &dest) const {
255  return nullptr;
256  }
257 
258  virtual std::unique_ptr<SigningProvider>
259  GetSolvingProvider(const CScript &script) const {
260  return nullptr;
261  }
262 
268  virtual bool CanProvide(const CScript &script, SignatureData &sigdata) {
269  return false;
270  }
271 
276  virtual bool
278  const std::map<COutPoint, Coin> &coins, SigHashType sighash,
279  std::map<int, std::string> &input_errors) const {
280  return false;
281  }
283  virtual SigningResult SignMessage(const std::string &message,
284  const PKHash &pkhash,
285  std::string &str_sig) const {
287  };
292  virtual TransactionError
294  SigHashType sighash_type = SigHashType().withForkId(),
295  bool sign = true, bool bip32derivs = false) const {
297  }
298 
299  virtual uint256 GetID() const { return uint256(); }
300 
301  virtual void SetInternal(bool internal) {}
302 
307  template <typename... Params>
308  void WalletLogPrintf(std::string fmt, Params... parameters) const {
309  LogPrintf(("%s " + fmt).c_str(), m_storage.GetDisplayName(),
310  parameters...);
311  };
312 
314  boost::signals2::signal<void(bool fHaveWatchOnly)> NotifyWatchonlyChanged;
315 
317  boost::signals2::signal<void()> NotifyCanGetAddressesChanged;
318 };
319 
321  public FillableSigningProvider {
322 private:
325 
326  using WatchOnlySet = std::set<CScript>;
327  using WatchKeyMap = std::map<CKeyID, CPubKey>;
328 
329  WalletBatch *encrypted_batch GUARDED_BY(cs_KeyStore) = nullptr;
330 
331  using CryptedKeyMap =
332  std::map<CKeyID, std::pair<CPubKey, std::vector<uint8_t>>>;
333 
334  CryptedKeyMap mapCryptedKeys GUARDED_BY(cs_KeyStore);
335  WatchOnlySet setWatchOnly GUARDED_BY(cs_KeyStore);
336  WatchKeyMap mapWatchKeys GUARDED_BY(cs_KeyStore);
337 
338  int64_t nTimeFirstKey GUARDED_BY(cs_KeyStore) = 0;
339 
340  bool AddKeyPubKeyInner(const CKey &key, const CPubKey &pubkey);
341  bool AddCryptedKeyInner(const CPubKey &vchPubKey,
342  const std::vector<uint8_t> &vchCryptedSecret);
343 
353  bool AddWatchOnly(const CScript &dest)
355  bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript &dest)
357  bool AddWatchOnlyInMem(const CScript &dest);
359  bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript &dest,
360  int64_t create_time)
362 
364  bool AddKeyPubKeyWithDB(WalletBatch &batch, const CKey &key,
365  const CPubKey &pubkey)
367 
368  void AddKeypoolPubkeyWithDB(const CPubKey &pubkey, const bool internal,
369  WalletBatch &batch);
370 
372  bool AddCScriptWithDB(WalletBatch &batch, const CScript &script);
373 
375  bool AddKeyOriginWithDB(WalletBatch &batch, const CPubKey &pubkey,
376  const KeyOriginInfo &info);
377 
378  /* the HD chain data model (external chain counters) */
380  std::unordered_map<CKeyID, CHDChain, KeyIDHasher> m_inactive_hd_chains;
381 
382  /* HD derive new child key (on internal or external chain) */
383  void DeriveNewChildKey(WalletBatch &batch, CKeyMetadata &metadata,
384  CKey &secret, CHDChain &hd_chain,
385  bool internal = false)
387 
388  std::set<int64_t> setInternalKeyPool GUARDED_BY(cs_KeyStore);
389  std::set<int64_t> setExternalKeyPool GUARDED_BY(cs_KeyStore);
390  std::set<int64_t> set_pre_split_keypool GUARDED_BY(cs_KeyStore);
391  int64_t m_max_keypool_index GUARDED_BY(cs_KeyStore) = 0;
392  std::map<CKeyID, int64_t> m_pool_key_to_index;
393  // Tracks keypool indexes to CKeyIDs of keys that have been taken out of the
394  // keypool but may be returned to it
395  std::map<int64_t, CKeyID> m_index_to_reserved_key;
396 
398  bool GetKeyFromPool(CPubKey &key, const OutputType type,
399  bool internal = false);
400 
415  bool ReserveKeyFromKeyPool(int64_t &nIndex, CKeyPool &keypool,
416  bool fRequestedInternal);
417 
431  bool TopUpInactiveHDChain(const CKeyID seed_id, int64_t index,
432  bool internal);
433 
434 public:
436 
437  bool GetNewDestination(const OutputType type, CTxDestination &dest,
438  std::string &error) override;
439  isminetype IsMine(const CScript &script) const override;
440 
441  bool CheckDecryptionKey(const CKeyingMaterial &master_key,
442  bool accept_no_keys = false) override;
443  bool Encrypt(const CKeyingMaterial &master_key,
444  WalletBatch *batch) override;
445 
446  bool GetReservedDestination(const OutputType type, bool internal,
447  CTxDestination &address, int64_t &index,
448  CKeyPool &keypool) override;
449  void KeepDestination(int64_t index, const OutputType &type) override;
450  void ReturnDestination(int64_t index, bool internal,
451  const CTxDestination &) override;
452 
453  bool TopUp(unsigned int size = 0) override;
454 
455  void MarkUnusedAddresses(const CScript &script) override;
456 
459  void UpgradeKeyMetadata();
460 
461  bool IsHDEnabled() const override;
462 
463  bool SetupGeneration(bool force = false) override;
464 
465  bool Upgrade(int prev_version, bilingual_str &error) override;
466 
467  bool HavePrivateKeys() const override;
468 
469  void RewriteDB() override;
470 
471  int64_t GetOldestKeyPoolTime() const override;
472  size_t KeypoolCountExternalKeys() const override;
473  unsigned int GetKeyPoolSize() const override;
474 
475  int64_t GetTimeFirstKey() const override;
476 
477  std::unique_ptr<CKeyMetadata>
478  GetMetadata(const CTxDestination &dest) const override;
479 
480  bool CanGetAddresses(bool internal = false) const override;
481 
482  std::unique_ptr<SigningProvider>
483  GetSolvingProvider(const CScript &script) const override;
484 
485  bool CanProvide(const CScript &script, SignatureData &sigdata) override;
486 
487  bool
489  const std::map<COutPoint, Coin> &coins, SigHashType sighash,
490  std::map<int, std::string> &input_errors) const override;
491  SigningResult SignMessage(const std::string &message, const PKHash &pkhash,
492  std::string &str_sig) const override;
495  SigHashType sighash_type = SigHashType().withForkId(),
496  bool sign = true, bool bip32derivs = false) const override;
497 
498  uint256 GetID() const override;
499 
500  void SetInternal(bool internal) override;
501 
502  // Map from Key ID to key metadata.
503  std::map<CKeyID, CKeyMetadata> mapKeyMetadata GUARDED_BY(cs_KeyStore);
504 
505  // Map from Script ID to key metadata (for watch-only keys).
506  std::map<CScriptID, CKeyMetadata> m_script_metadata GUARDED_BY(cs_KeyStore);
507 
509  bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override;
511  bool LoadKey(const CKey &key, const CPubKey &pubkey);
513  bool AddCryptedKey(const CPubKey &vchPubKey,
514  const std::vector<uint8_t> &vchCryptedSecret);
517  bool LoadCryptedKey(const CPubKey &vchPubKey,
518  const std::vector<uint8_t> &vchCryptedSecret,
519  bool checksum_valid);
520  void UpdateTimeFirstKey(int64_t nCreateTime)
523  bool LoadCScript(const CScript &redeemScript);
525  void LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &metadata);
526  void LoadScriptMetadata(const CScriptID &script_id,
527  const CKeyMetadata &metadata);
529  CPubKey GenerateNewKey(WalletBatch &batch, CHDChain &hd_chain,
530  bool internal = false)
532 
537  void AddHDChain(const CHDChain &chain);
539  void LoadHDChain(const CHDChain &chain);
540  const CHDChain &GetHDChain() const { return m_hd_chain; }
541  void AddInactiveHDChain(const CHDChain &chain);
542 
545  bool LoadWatchOnly(const CScript &dest);
547  bool HaveWatchOnly(const CScript &dest) const;
549  bool HaveWatchOnly() const;
551  bool RemoveWatchOnly(const CScript &dest);
552  bool AddWatchOnly(const CScript &dest, int64_t nCreateTime)
554 
556  bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const;
557 
558  /* SigningProvider overrides */
559  bool HaveKey(const CKeyID &address) const override;
560  bool GetKey(const CKeyID &address, CKey &keyOut) const override;
561  bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override;
562  bool AddCScript(const CScript &redeemScript) override;
563  bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override;
564 
566  void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool);
567  bool NewKeyPool();
569 
570  bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp)
572  bool ImportPrivKeys(const std::map<CKeyID, CKey> &privkey_map,
573  const int64_t timestamp)
575  bool ImportPubKeys(
576  const std::vector<CKeyID> &ordered_pubkeys,
577  const std::map<CKeyID, CPubKey> &pubkey_map,
578  const std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>> &key_origins,
579  const bool add_keypool, const bool internal, const int64_t timestamp)
581  bool ImportScriptPubKeys(const std::set<CScript> &script_pub_keys,
582  const bool have_solving_data,
583  const int64_t timestamp)
585 
586  /* Returns true if the wallet can generate new keys */
587  bool CanGenerateKeys() const;
588 
589  /* Generates a new HD seed (will not be activated) */
591 
592  /* Derives a new HD seed (will not be activated) */
593  CPubKey DeriveNewSeed(const CKey &key);
594 
595  /* Set the current HD seed (will reset the chain child index counters)
596  Sets the seed's version based on the current wallet version (so the
597  caller must ensure the current wallet version is correct before calling
598  this function). */
599  void SetHDSeed(const CPubKey &key);
600 
607  void LearnRelatedScripts(const CPubKey &key, OutputType);
608 
613  void LearnAllRelatedScripts(const CPubKey &key);
614 
618  void MarkReserveKeysAsUsed(int64_t keypool_id)
620  const std::map<CKeyID, int64_t> &GetAllReserveKeys() const {
621  return m_pool_key_to_index;
622  }
623 
624  std::set<CKeyID> GetKeys() const override;
625 };
626 
632 private:
634 
635 public:
637  : m_spk_man(spk_man) {}
638 
639  bool GetCScript(const CScriptID &scriptid, CScript &script) const override {
640  return m_spk_man.GetCScript(scriptid, script);
641  }
642  bool HaveCScript(const CScriptID &scriptid) const override {
643  return m_spk_man.HaveCScript(scriptid);
644  }
645  bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const override {
646  return m_spk_man.GetPubKey(address, pubkey);
647  }
648  bool GetKey(const CKeyID &address, CKey &key) const override {
649  return false;
650  }
651  bool HaveKey(const CKeyID &address) const override { return false; }
652  bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override {
653  return m_spk_man.GetKeyOrigin(keyid, info);
654  }
655 };
656 
658 private:
659  WalletDescriptor m_wallet_descriptor GUARDED_BY(cs_desc_man);
660 
661  // Map of scripts to descriptor range index
662  using ScriptPubKeyMap = std::map<CScript, int32_t>;
663  // Map of pubkeys involved in scripts to descriptor range index
664  using PubKeyMap = std::map<CPubKey, int32_t>;
665  using CryptedKeyMap =
666  std::map<CKeyID, std::pair<CPubKey, std::vector<uint8_t>>>;
667  using KeyMap = std::map<CKeyID, CKey>;
668 
669  ScriptPubKeyMap m_map_script_pub_keys GUARDED_BY(cs_desc_man);
670  PubKeyMap m_map_pubkeys GUARDED_BY(cs_desc_man);
671  int32_t m_max_cached_index = -1;
672 
673  bool m_internal = false;
674 
675  KeyMap m_map_keys GUARDED_BY(cs_desc_man);
676  CryptedKeyMap m_map_crypted_keys GUARDED_BY(cs_desc_man);
677 
680 
681  bool AddDescriptorKeyWithDB(WalletBatch &batch, const CKey &key,
682  const CPubKey &pubkey)
684 
686 
687  // Fetch the SigningProvider for the given script and optionally include
688  // private keys
689  std::unique_ptr<FlatSigningProvider>
690  GetSigningProvider(const CScript &script,
691  bool include_private = false) const;
692  // Fetch the SigningProvider for the given pubkey and always include private
693  // keys. This should only be called by signing code.
694  std::unique_ptr<FlatSigningProvider>
695  GetSigningProvider(const CPubKey &pubkey) const;
696  // Fetch the SigningProvider for a given index and optionally include
697  // private keys. Called by the above functions.
698  std::unique_ptr<FlatSigningProvider>
699  GetSigningProvider(int32_t index, bool include_private = false) const
701 
702 public:
704  WalletDescriptor &descriptor)
705  : ScriptPubKeyMan(storage), m_wallet_descriptor(descriptor) {}
706  DescriptorScriptPubKeyMan(WalletStorage &storage, bool internal)
707  : ScriptPubKeyMan(storage), m_internal(internal) {}
708 
710 
711  bool GetNewDestination(const OutputType type, CTxDestination &dest,
712  std::string &error) override;
713  isminetype IsMine(const CScript &script) const override;
714 
715  bool CheckDecryptionKey(const CKeyingMaterial &master_key,
716  bool accept_no_keys = false) override;
717  bool Encrypt(const CKeyingMaterial &master_key,
718  WalletBatch *batch) override;
719 
720  bool GetReservedDestination(const OutputType type, bool internal,
721  CTxDestination &address, int64_t &index,
722  CKeyPool &keypool) override;
723  void ReturnDestination(int64_t index, bool internal,
724  const CTxDestination &addr) override;
725 
726  // Tops up the descriptor cache and m_map_script_pub_keys. The cache is
727  // stored in the wallet file and is used to expand the descriptor in
728  // GetNewDestination. DescriptorScriptPubKeyMan relies more on ephemeral
729  // data than LegacyScriptPubKeyMan. For wallets using unhardened derivation
730  // (with or without private keys), the "keypool" is a single xpub.
731  bool TopUp(unsigned int size = 0) override;
732 
733  void MarkUnusedAddresses(const CScript &script) override;
734 
735  bool IsHDEnabled() const override;
736 
738  bool SetupDescriptorGeneration(const CExtKey &master_key,
739  OutputType addr_type);
740 
741  bool HavePrivateKeys() const override;
742 
743  int64_t GetOldestKeyPoolTime() const override;
744  size_t KeypoolCountExternalKeys() const override;
745  unsigned int GetKeyPoolSize() const override;
746 
747  int64_t GetTimeFirstKey() const override;
748 
749  std::unique_ptr<CKeyMetadata>
750  GetMetadata(const CTxDestination &dest) const override;
751 
752  bool CanGetAddresses(bool internal = false) const override;
753 
754  std::unique_ptr<SigningProvider>
755  GetSolvingProvider(const CScript &script) const override;
756 
757  bool CanProvide(const CScript &script, SignatureData &sigdata) override;
758 
759  bool
761  const std::map<COutPoint, Coin> &coins, SigHashType sighash,
762  std::map<int, std::string> &input_errors) const override;
763  SigningResult SignMessage(const std::string &message, const PKHash &pkhash,
764  std::string &str_sig) const override;
767  SigHashType sighash_type = SigHashType().withForkId(),
768  bool sign = true, bool bip32derivs = false) const override;
769 
770  uint256 GetID() const override;
771 
772  void SetInternal(bool internal) override;
773 
774  void SetCache(const DescriptorCache &cache);
775 
776  bool AddKey(const CKeyID &key_id, const CKey &key);
777  bool AddCryptedKey(const CKeyID &key_id, const CPubKey &pubkey,
778  const std::vector<uint8_t> &crypted_key);
779 
780  bool HasWalletDescriptor(const WalletDescriptor &desc) const;
781  void AddDescriptorKey(const CKey &key, const CPubKey &pubkey);
782  void WriteDescriptor();
783 
786  const std::vector<CScript> GetScriptPubKeys() const;
787 };
788 
789 #endif // BITCOIN_WALLET_SCRIPTPUBKEYMAN_H
LegacyScriptPubKeyMan::TopUp
bool TopUp(unsigned int size=0) override
Fills internal address pool.
Definition: scriptpubkeyman.cpp:1215
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.
Definition: scriptpubkeyman.cpp:1689
LegacyScriptPubKeyMan::SetInternal
void SetInternal(bool internal) override
Definition: scriptpubkeyman.cpp:1622
LegacyScriptPubKeyMan::KeepDestination
void KeepDestination(int64_t index, const OutputType &type) override
Definition: scriptpubkeyman.cpp:1289
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:2147
ScriptPubKeyMan::m_storage
WalletStorage & m_storage
Definition: scriptpubkeyman.h:176
LegacyScriptPubKeyMan::AddKeypoolPubkeyWithDB
void AddKeypoolPubkeyWithDB(const CPubKey &pubkey, const bool internal, WalletBatch &batch)
Definition: scriptpubkeyman.cpp:1270
crypter.h
LegacyScriptPubKeyMan::HavePrivateKeys
bool HavePrivateKeys() const override
Definition: scriptpubkeyman.cpp:451
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:261
LegacySigningProvider::GetCScript
bool GetCScript(const CScriptID &scriptid, CScript &script) const override
Definition: scriptpubkeyman.h:639
LegacyScriptPubKeyMan::IsHDEnabled
bool IsHDEnabled() const override
Definition: scriptpubkeyman.cpp:398
LegacyScriptPubKeyMan::UpdateTimeFirstKey
void UpdateTimeFirstKey(int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Update wallet first key creation time.
Definition: scriptpubkeyman.cpp:636
OutputType
OutputType
Definition: outputtype.h:17
WalletStorage::GetChainParams
virtual const CChainParams & GetChainParams() const =0
LegacySigningProvider::LegacySigningProvider
LegacySigningProvider(const LegacyScriptPubKeyMan &spk_man)
Definition: scriptpubkeyman.h:636
DescriptorScriptPubKeyMan::SetInternal
void SetInternal(bool internal) override
Definition: scriptpubkeyman.cpp:2263
LegacyScriptPubKeyMan::GetWatchPubKey
bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const
Fetches a pubkey from mapWatchKeys if it exists there.
Definition: scriptpubkeyman.cpp:952
DEFAULT_KEYPOOL_SIZE
static const unsigned int DEFAULT_KEYPOOL_SIZE
Default for -keypool.
Definition: scriptpubkeyman.h:51
LegacyScriptPubKeyMan::GetReservedDestination
bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool) override
Definition: scriptpubkeyman.cpp:244
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:651
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:869
CKeyPool::Unserialize
void Unserialize(Stream &s)
Definition: scriptpubkeyman.h:130
ScriptPubKeyMan::RewriteDB
virtual void RewriteDB()
The action to do when the DB needs rewrite.
Definition: scriptpubkeyman.h:244
DescriptorScriptPubKeyMan::MarkUnusedAddresses
void MarkUnusedAddresses(const CScript &script) override
Mark unused addresses as being used.
Definition: scriptpubkeyman.cpp:1905
LegacyScriptPubKeyMan::CryptedKeyMap
std::map< CKeyID, std::pair< CPubKey, std::vector< uint8_t > >> CryptedKeyMap
Definition: scriptpubkeyman.h:332
LegacyScriptPubKeyMan::MarkUnusedAddresses
void MarkUnusedAddresses(const CScript &script) override
Mark unused addresses as being used.
Definition: scriptpubkeyman.cpp:306
CKeyPool
A key from a CWallet's keypool.
Definition: scriptpubkeyman.h:106
LegacyScriptPubKeyMan::GetHDChain
const CHDChain & GetHDChain() const
Definition: scriptpubkeyman.h:540
DescriptorScriptPubKeyMan::SignTransaction
bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, SigHashType sighash, std::map< int, std::string > &input_errors) const override
Creates new signatures and adds them to the transaction.
Definition: scriptpubkeyman.cpp:2129
LegacyScriptPubKeyMan::GetKeyPoolSize
unsigned int GetKeyPoolSize() const override
Definition: scriptpubkeyman.cpp:508
LegacySigningProvider::GetKeyOrigin
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
Definition: scriptpubkeyman.h:652
DescriptorScriptPubKeyMan::GetSolvingProvider
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const override
Definition: scriptpubkeyman.cpp:2120
LegacyScriptPubKeyMan::m_index_to_reserved_key
std::map< int64_t, CKeyID > m_index_to_reserved_key
Definition: scriptpubkeyman.h:395
KeyIDHasher::operator()
size_t operator()(const CKeyID &id) const
Definition: scriptpubkeyman.h:163
LegacyScriptPubKeyMan::CanGetAddresses
bool CanGetAddresses(bool internal=false) const override
Returns true if the wallet can give out new addresses.
Definition: scriptpubkeyman.cpp:402
LegacyScriptPubKeyMan::GUARDED_BY
WalletBatch *encrypted_batch GUARDED_BY(cs_KeyStore)
ScriptPubKeyMan::IsMine
virtual isminetype IsMine(const CScript &script) const
Definition: scriptpubkeyman.h:185
FillableSigningProvider
Fillable signing provider that keeps keys in an address->secret map.
Definition: signingprovider.h:76
LegacyScriptPubKeyMan::LoadKeyPool
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool)
Load a keypool entry.
Definition: scriptpubkeyman.cpp:1101
DescriptorScriptPubKeyMan::HasWalletDescriptor
bool HasWalletDescriptor(const WalletDescriptor &desc) const
Definition: scriptpubkeyman.cpp:2322
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:1404
LegacyScriptPubKeyMan::WatchOnlySet
std::set< CScript > WatchOnlySet
Definition: scriptpubkeyman.h:326
bilingual_str
Bilingual messages:
Definition: translation.h:17
DescriptorScriptPubKeyMan::IsMine
isminetype IsMine(const CScript &script) const override
Definition: scriptpubkeyman.cpp:1681
LegacyScriptPubKeyMan::SignTransaction
bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, SigHashType sighash, std::map< int, std::string > &input_errors) const override
Creates new signatures and adds them to the transaction.
Definition: scriptpubkeyman.cpp:550
WalletStorage::GetDatabase
virtual WalletDatabase & GetDatabase()=0
WalletStorage::GetDisplayName
virtual const std::string GetDisplayName() const =0
LegacyScriptPubKeyMan::KeypoolCountExternalKeys
size_t KeypoolCountExternalKeys() const override
Definition: scriptpubkeyman.cpp:503
LegacyScriptPubKeyMan::UpgradeKeyMetadata
void UpgradeKeyMetadata()
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
Definition: scriptpubkeyman.cpp:347
CKeyingMaterial
std::vector< uint8_t, secure_allocator< uint8_t > > CKeyingMaterial
Definition: crypter.h:57
LegacyScriptPubKeyMan::NewKeyPool
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
Definition: scriptpubkeyman.cpp:1183
LegacyScriptPubKeyMan::LoadKeyMetadata
void LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &metadata)
Load metadata (used by LoadWallet)
Definition: scriptpubkeyman.cpp:724
CChainParams
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:47
DescriptorScriptPubKeyMan::IsHDEnabled
bool IsHDEnabled() const override
Definition: scriptpubkeyman.cpp:2020
SigningProvider
An interface to be implemented by keystores that support signing.
Definition: signingprovider.h:20
LegacyScriptPubKeyMan::GetTimeFirstKey
int64_t GetTimeFirstKey() const override
Definition: scriptpubkeyman.cpp:514
GetTime
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
Definition: time.cpp:27
LegacyScriptPubKeyMan::Encrypt
bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch) override
Definition: scriptpubkeyman.cpp:213
LegacyScriptPubKeyMan::GetKeyFromPool
bool GetKeyFromPool(CPubKey &key, const OutputType type, bool internal=false)
Fetches a key from the keypool.
Definition: scriptpubkeyman.cpp:1323
LegacyScriptPubKeyMan::SetHDSeed
void SetHDSeed(const CPubKey &key)
Definition: scriptpubkeyman.cpp:1164
AnnotatedMixin< std::recursive_mutex >
KeyIDHasher::KeyIDHasher
KeyIDHasher()
Definition: scriptpubkeyman.h:161
LegacySigningProvider::GetKey
bool GetKey(const CKeyID &address, CKey &key) const override
Definition: scriptpubkeyman.h:648
ScriptPubKeyMan::KeepDestination
virtual void KeepDestination(int64_t index, const OutputType &type)
Definition: scriptpubkeyman.h:203
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:308
DescriptorScriptPubKeyMan::CanProvide
bool CanProvide(const CScript &script, SignatureData &sigdata) override
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that,...
Definition: scriptpubkeyman.cpp:2124
WalletDatabase
An instance of this class represents one database.
Definition: db.h:100
LegacyScriptPubKeyMan::GetKeys
std::set< CKeyID > GetKeys() const override
Definition: scriptpubkeyman.cpp:1610
LegacyScriptPubKeyMan::m_pool_key_to_index
std::map< CKeyID, int64_t > m_pool_key_to_index
Definition: scriptpubkeyman.h:392
CKeyID
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:22
ScriptPubKeyMan::~ScriptPubKeyMan
virtual ~ScriptPubKeyMan()
Definition: scriptpubkeyman.h:180
DescriptorScriptPubKeyMan::PubKeyMap
std::map< CPubKey, int32_t > PubKeyMap
Definition: scriptpubkeyman.h:664
ScriptPubKeyMan::HavePrivateKeys
virtual bool HavePrivateKeys() const
Definition: scriptpubkeyman.h:241
LegacyScriptPubKeyMan
Definition: scriptpubkeyman.h:320
DescriptorScriptPubKeyMan::GetSigningProvider
std::unique_ptr< FlatSigningProvider > GetSigningProvider(const CScript &script, bool include_private=false) const
Definition: scriptpubkeyman.cpp:2066
CKeyPool::nTime
int64_t nTime
The time at which the key was generated. Set in AddKeypoolPubKeyWithDB.
Definition: scriptpubkeyman.h:109
ScriptPubKeyMan::CanProvide
virtual bool CanProvide(const CScript &script, SignatureData &sigdata)
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that,...
Definition: scriptpubkeyman.h:268
DescriptorScriptPubKeyMan::KeyMap
std::map< CKeyID, CKey > KeyMap
Definition: scriptpubkeyman.h:667
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:647
LegacyScriptPubKeyMan::GetKey
bool GetKey(const CKeyID &address, CKey &keyOut) const override
Definition: scriptpubkeyman.cpp:915
SigningResult
SigningResult
Definition: message.h:47
LegacyScriptPubKeyMan::ReturnDestination
void ReturnDestination(int64_t index, bool internal, const CTxDestination &) override
Definition: scriptpubkeyman.cpp:1302
LegacyScriptPubKeyMan::MarkPreSplitKeys
void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1460
DescriptorScriptPubKeyMan::m_decryption_thoroughly_checked
bool m_decryption_thoroughly_checked
keeps track of whether Unlock has run a thorough check before
Definition: scriptpubkeyman.h:679
DescriptorScriptPubKeyMan::HavePrivateKeys
bool HavePrivateKeys() const override
Definition: scriptpubkeyman.cpp:2036
ScriptPubKeyMan::Upgrade
virtual bool Upgrade(int prev_version, bilingual_str &error)
Upgrades the wallet to the specified version.
Definition: scriptpubkeyman.h:237
KeyIDHasher
Definition: scriptpubkeyman.h:159
DescriptorScriptPubKeyMan
Definition: scriptpubkeyman.h:657
DescriptorScriptPubKeyMan::CanGetAddresses
bool CanGetAddresses(bool internal=false) const override
Returns true if the wallet can give out new addresses.
Definition: scriptpubkeyman.cpp:2025
signingprovider.h
ismine.h
LegacyScriptPubKeyMan::Upgrade
bool Upgrade(int prev_version, bilingual_str &error) override
Upgrades the wallet to the specified version.
Definition: scriptpubkeyman.cpp:418
TransactionError
TransactionError
Definition: error.h:22
DescriptorScriptPubKeyMan::m_internal
bool m_internal
Definition: scriptpubkeyman.h:673
DescriptorScriptPubKeyMan::ReturnDestination
void ReturnDestination(int64_t index, bool internal, const CTxDestination &addr) override
Definition: scriptpubkeyman.cpp:1761
DescriptorScriptPubKeyMan::AddDescriptorKey
void AddDescriptorKey(const CKey &key, const CPubKey &pubkey)
Definition: scriptpubkeyman.cpp:1922
LegacyScriptPubKeyMan::LoadCScript
bool LoadCScript(const CScript &redeemScript)
Adds a CScript to the store.
Definition: scriptpubkeyman.cpp:704
walletutil.h
WalletStorage
Definition: scriptpubkeyman.h:34
isminetype
isminetype
IsMine() return codes.
Definition: ismine.h:18
ScriptPubKeyMan::FillPSBT
virtual TransactionError FillPSBT(PartiallySignedTransaction &psbt, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=false) const
Adds script and derivation path information to a PSBT, and optionally signs it.
Definition: scriptpubkeyman.h:293
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:117
LegacyScriptPubKeyMan::LoadHDChain
void LoadHDChain(const CHDChain &chain)
Load a HD chain model (used by LoadWallet)
Definition: scriptpubkeyman.cpp:880
ScriptPubKeyMan::GetKeyPoolSize
virtual unsigned int GetKeyPoolSize() const
Definition: scriptpubkeyman.h:249
SignatureData
Definition: sign.h:66
LegacyScriptPubKeyMan::AddKeyPubKeyInner
bool AddKeyPubKeyInner(const CKey &key, const CPubKey &pubkey)
Definition: scriptpubkeyman.cpp:738
LegacyScriptPubKeyMan::DeriveNewSeed
CPubKey DeriveNewSeed(const CKey &key)
Definition: scriptpubkeyman.cpp:1137
DescriptorScriptPubKeyMan::GUARDED_BY
WalletDescriptor m_wallet_descriptor GUARDED_BY(cs_desc_man)
CExtKey
Definition: key.h:164
Coin
A UTXO entry.
Definition: coins.h:27
LegacyScriptPubKeyMan::GenerateNewSeed
CPubKey GenerateNewSeed()
Definition: scriptpubkeyman.cpp:1130
LegacySigningProvider::GetPubKey
bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const override
Definition: scriptpubkeyman.h:645
LegacyScriptPubKeyMan::HaveKey
bool HaveKey(const CKeyID &address) const override
Definition: scriptpubkeyman.cpp:907
LegacyScriptPubKeyMan::DeriveNewChildKey
void DeriveNewChildKey(WalletBatch &batch, CKeyMetadata &metadata, CKey &secret, CHDChain &hd_chain, bool internal=false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1026
LegacyScriptPubKeyMan::GenerateNewKey
CPubKey GenerateNewKey(WalletBatch &batch, CHDChain &hd_chain, bool internal=false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Generate a new key.
Definition: scriptpubkeyman.cpp:983
ScriptPubKeyMan::IsHDEnabled
virtual bool IsHDEnabled() const
Definition: scriptpubkeyman.h:228
message.h
LegacyScriptPubKeyMan::SetupGeneration
bool SetupGeneration(bool force=false) override
Sets up the key generation stuff, i.e.
Definition: scriptpubkeyman.cpp:386
ScriptPubKeyMan::MarkUnusedAddresses
virtual void MarkUnusedAddresses(const CScript &script)
Mark unused addresses as being used.
Definition: scriptpubkeyman.h:217
LegacyScriptPubKeyMan::GetNewDestination
bool GetNewDestination(const OutputType type, CTxDestination &dest, std::string &error) override
Definition: scriptpubkeyman.cpp:21
LegacySigningProvider::HaveKey
bool HaveKey(const CKeyID &address) const override
Definition: scriptpubkeyman.h:651
LegacyScriptPubKeyMan::RewriteDB
void RewriteDB() override
The action to do when the DB needs rewrite.
Definition: scriptpubkeyman.cpp:456
LegacyScriptPubKeyMan::m_hd_chain
CHDChain m_hd_chain
Definition: scriptpubkeyman.h:379
TransactionError::INVALID_PSBT
@ INVALID_PSBT
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.
Definition: scriptpubkeyman.cpp:170
DescriptorScriptPubKeyMan::FillPSBT
TransactionError FillPSBT(PartiallySignedTransaction &psbt, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=false) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
Definition: scriptpubkeyman.cpp:2168
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:556
LegacyScriptPubKeyMan::AddCryptedKeyInner
bool AddCryptedKeyInner(const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret)
Definition: scriptpubkeyman.cpp:773
ScriptPubKeyMan::KeypoolCountExternalKeys
virtual size_t KeypoolCountExternalKeys() const
Definition: scriptpubkeyman.h:248
FillableSigningProvider::HaveCScript
virtual bool HaveCScript(const CScriptID &hash) const override
Definition: signingprovider.cpp:138
WalletStorage::HasEncryptionKeys
virtual bool HasEncryptionKeys() const =0
SigHashType
Signature hash type wrapper class.
Definition: sighashtype.h:37
CKeyPool::vchPubKey
CPubKey vchPubKey
The public key.
Definition: scriptpubkeyman.h:111
LegacySigningProvider::HaveCScript
bool HaveCScript(const CScriptID &scriptid) const override
Definition: scriptpubkeyman.h:642
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:483
LegacyScriptPubKeyMan::FillPSBT
TransactionError FillPSBT(PartiallySignedTransaction &psbt, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=false) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
Definition: scriptpubkeyman.cpp:571
ScriptPubKeyMan::GetReservedDestination
virtual bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool)
Definition: scriptpubkeyman.h:198
LegacyScriptPubKeyMan::AddCScript
bool AddCScript(const CScript &redeemScript) override
Definition: scriptpubkeyman.cpp:1480
uint256
256-bit opaque blob.
Definition: uint256.h:127
ISMINE_NO
@ ISMINE_NO
Definition: ismine.h:19
LegacyScriptPubKeyMan::AddCScriptWithDB
bool AddCScriptWithDB(WalletBatch &batch, const CScript &script)
Adds a script to the store and saves it to disk.
Definition: scriptpubkeyman.cpp:1485
LegacyScriptPubKeyMan::WatchKeyMap
std::map< CKeyID, CPubKey > WatchKeyMap
Definition: scriptpubkeyman.h:327
LegacyScriptPubKeyMan::LearnAllRelatedScripts
void LearnAllRelatedScripts(const CPubKey &key)
Same as LearnRelatedScripts, but when the OutputType is not known (and could be anything).
Definition: scriptpubkeyman.cpp:1409
WalletStorage::UnsetBlankWalletFlag
virtual void UnsetBlankWalletFlag(WalletBatch &)=0
LegacyScriptPubKeyMan::AddCryptedKey
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret)
Adds an encrypted key to the store, and saves it to disk.
Definition: scriptpubkeyman.cpp:782
ScriptPubKeyMan::GetID
virtual uint256 GetID() const
Definition: scriptpubkeyman.h:299
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:430
LegacyScriptPubKeyMan::IsMine
isminetype IsMine(const CScript &script) const override
Definition: scriptpubkeyman.cpp:157
DescriptorScriptPubKeyMan::GetOldestKeyPoolTime
int64_t GetOldestKeyPoolTime() const override
Definition: scriptpubkeyman.cpp:2041
LegacyScriptPubKeyMan::ImportPrivKeys
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1534
WalletStorage::IsWalletFlagSet
virtual bool IsWalletFlagSet(uint64_t) const =0
ScriptPubKeyMan::ScriptPubKeyMan
ScriptPubKeyMan(WalletStorage &storage)
Definition: scriptpubkeyman.h:179
LegacyScriptPubKeyMan::GetAllReserveKeys
const std::map< CKeyID, int64_t > & GetAllReserveKeys() const
Definition: scriptpubkeyman.h:620
LegacyScriptPubKeyMan::GetID
uint256 GetID() const override
Definition: scriptpubkeyman.cpp:628
DescriptorScriptPubKeyMan::CryptedKeyMap
std::map< CKeyID, std::pair< CPubKey, std::vector< uint8_t > >> CryptedKeyMap
Definition: scriptpubkeyman.h:666
DescriptorCache
Cache for single descriptor's derived extended pubkeys.
Definition: descriptor.h:19
WalletStorage::SetMinVersion
virtual void SetMinVersion(enum WalletFeature, WalletBatch *=nullptr, bool=false)=0
ScriptPubKeyMan::NotifyCanGetAddressesChanged
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
Definition: scriptpubkeyman.h:317
DescriptorScriptPubKeyMan::KeypoolCountExternalKeys
size_t KeypoolCountExternalKeys() const override
Definition: scriptpubkeyman.cpp:2048
CKeyPool::CKeyPool
CKeyPool()
Definition: wallet.cpp:4649
DescriptorScriptPubKeyMan::SetupDescriptorGeneration
bool SetupDescriptorGeneration(const CExtKey &master_key, OutputType addr_type)
Setup descriptors based on the given CExtkey.
Definition: scriptpubkeyman.cpp:1958
DescriptorScriptPubKeyMan::GetID
uint256 GetID() const override
Definition: scriptpubkeyman.cpp:2253
PKHash
Definition: standard.h:106
DescriptorScriptPubKeyMan::AddDescriptorKeyWithDB
bool AddDescriptorKeyWithDB(WalletBatch &batch, const CKey &key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
Definition: scriptpubkeyman.cpp:1932
SER_GETHASH
@ SER_GETHASH
Definition: serialize.h:167
LegacyScriptPubKeyMan::LoadScriptMetadata
void LoadScriptMetadata(const CScriptID &script_id, const CKeyMetadata &metadata)
Definition: scriptpubkeyman.cpp:731
DescriptorScriptPubKeyMan::cs_desc_man
RecursiveMutex cs_desc_man
Definition: scriptpubkeyman.h:709
CPubKey
An encapsulated public key.
Definition: pubkey.h:31
LegacyScriptPubKeyMan::LoadCryptedKey
bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret, bool checksum_valid)
Adds an encrypted key to the store, without saving it to disk (used by LoadWallet)
Definition: scriptpubkeyman.cpp:762
LegacyScriptPubKeyMan::CanProvide
bool CanProvide(const CScript &script, SignatureData &sigdata) override
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that,...
Definition: scriptpubkeyman.cpp:524
DescriptorScriptPubKeyMan::ScriptPubKeyMap
std::map< CScript, int32_t > ScriptPubKeyMap
Definition: scriptpubkeyman.h:662
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:1594
ScriptPubKeyMan
A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
Definition: scriptpubkeyman.h:174
LegacyScriptPubKeyMan::AddKeyOriginWithDB
bool AddKeyOriginWithDB(WalletBatch &batch, const CPubKey &pubkey, const KeyOriginInfo &info)
Add a KeyOriginInfo to the wallet.
Definition: scriptpubkeyman.cpp:1497
DescriptorScriptPubKeyMan::DescriptorScriptPubKeyMan
DescriptorScriptPubKeyMan(WalletStorage &storage, bool internal)
Definition: scriptpubkeyman.h:706
CKey
An encapsulated secp256k1 private key.
Definition: key.h:28
DescriptorScriptPubKeyMan::GetKeyPoolSize
unsigned int GetKeyPoolSize() const override
Definition: scriptpubkeyman.cpp:2055
DescriptorScriptPubKeyMan::GetMetadata
std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const override
Definition: scriptpubkeyman.cpp:2234
ScriptPubKeyMan::SignTransaction
virtual bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, SigHashType sighash, std::map< int, std::string > &input_errors) const
Creates new signatures and adds them to the transaction.
Definition: scriptpubkeyman.h:277
CHDChain
Definition: walletdb.h:88
ScriptPubKeyMan::Encrypt
virtual bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch)
Definition: scriptpubkeyman.h:193
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:56
DescriptorScriptPubKeyMan::GetWalletDescriptor
const WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
Definition: scriptpubkeyman.cpp:2340
ScriptPubKeyMan::SetInternal
virtual void SetInternal(bool internal)
Definition: scriptpubkeyman.h:301
DescriptorScriptPubKeyMan::TopUp
bool TopUp(unsigned int size=0) override
Fills internal address pool.
Definition: scriptpubkeyman.cpp:1790
LegacyScriptPubKeyMan::GetSolvingProvider
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const override
Definition: scriptpubkeyman.cpp:520
PartiallySignedTransaction
A version of CTransaction with the PSBT format.
Definition: psbt.h:335
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:832
WalletStorage::GetEncryptionKey
virtual const CKeyingMaterial & GetEncryptionKey() const =0
GetAffectedKeys
std::vector< CKeyID > GetAffectedKeys(const CScript &spk, const SigningProvider &provider)
Definition: scriptpubkeyman.cpp:1447
SigningResult::SIGNING_FAILED
@ SIGNING_FAILED
DescriptorScriptPubKeyMan::m_max_cached_index
int32_t m_max_cached_index
Definition: scriptpubkeyman.h:671
LegacyScriptPubKeyMan::GetPubKey
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
Definition: scriptpubkeyman.cpp:963
LegacyScriptPubKeyMan::RemoveWatchOnly
bool RemoveWatchOnly(const CScript &dest)
Remove a watch only script from the keystore.
Definition: scriptpubkeyman.cpp:815
ScriptPubKeyMan::TopUp
virtual bool TopUp(unsigned int size=0)
Fills internal address pool.
Definition: scriptpubkeyman.h:214
ScriptPubKeyMan::SetupGeneration
virtual bool SetupGeneration(bool force=false)
Sets up the key generation stuff, i.e.
Definition: scriptpubkeyman.h:225
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:508
LegacySigningProvider::m_spk_man
const LegacyScriptPubKeyMan & m_spk_man
Definition: scriptpubkeyman.h:633
LegacyScriptPubKeyMan::HaveWatchOnly
bool HaveWatchOnly() const
Returns whether there are any watch-only things in the wallet.
Definition: scriptpubkeyman.cpp:804
ScriptPubKeyMan::GetOldestKeyPoolTime
virtual int64_t GetOldestKeyPoolTime() const
Definition: scriptpubkeyman.h:246
LegacyScriptPubKeyMan::ImportScripts
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1509
DescriptorScriptPubKeyMan::AddKey
bool AddKey(const CKeyID &key_id, const CKey &key)
Definition: scriptpubkeyman.cpp:2304
DescriptorScriptPubKeyMan::GetKeys
KeyMap GetKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
Definition: scriptpubkeyman.cpp:1773
CKeyPool::fInternal
bool fInternal
Whether this keypool entry is in the internal keypool (for change outputs)
Definition: scriptpubkeyman.h:114
ScriptPubKeyMan::GetSolvingProvider
virtual std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Definition: scriptpubkeyman.h:259
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:1413
LegacyScriptPubKeyMan::AddHDChain
void AddHDChain(const CHDChain &chain)
Set the HD chain model (chain child index counters) and writes it to the database.
Definition: scriptpubkeyman.cpp:885
FillableSigningProvider::GetCScript
virtual bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const override
Definition: signingprovider.cpp:152
ScriptPubKeyMan::ReturnDestination
virtual void ReturnDestination(int64_t index, bool internal, const CTxDestination &addr)
Definition: scriptpubkeyman.h:204
ScriptPubKeyMan::NotifyWatchonlyChanged
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition: scriptpubkeyman.h:311
WalletDescriptor
Descriptor with some wallet metadata.
Definition: walletutil.h:80
ScriptPubKeyMan::GetNewDestination
virtual bool GetNewDestination(const OutputType type, CTxDestination &dest, std::string &error)
Definition: scriptpubkeyman.h:181
walletdb.h
WalletFeature
WalletFeature
(client) version numbers for particular wallet features
Definition: walletutil.h:14
DescriptorScriptPubKeyMan::WriteDescriptor
void WriteDescriptor()
Definition: scriptpubkeyman.cpp:2331
LegacyScriptPubKeyMan::GetKeyOrigin
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
Definition: scriptpubkeyman.cpp:931
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:22
LegacyScriptPubKeyMan::fDecryptionThoroughlyChecked
bool fDecryptionThoroughlyChecked
keeps track of whether Unlock has run a thorough check before
Definition: scriptpubkeyman.h:324
ScriptPubKeyMan::GetMetadata
virtual std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const
Definition: scriptpubkeyman.h:254
LegacyScriptPubKeyMan::m_inactive_hd_chains
std::unordered_map< CKeyID, CHDChain, KeyIDHasher > m_inactive_hd_chains
Definition: scriptpubkeyman.h:380
DescriptorScriptPubKeyMan::GetTimeFirstKey
int64_t GetTimeFirstKey() const override
Definition: scriptpubkeyman.cpp:2060
DescriptorScriptPubKeyMan::GetReservedDestination
bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool) override
Definition: scriptpubkeyman.cpp:1749
DescriptorScriptPubKeyMan::GetScriptPubKeys
const std::vector< CScript > GetScriptPubKeys() const
Definition: scriptpubkeyman.cpp:2344
FillableSigningProvider::cs_KeyStore
RecursiveMutex cs_KeyStore
Definition: signingprovider.h:107
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:48
LegacyScriptPubKeyMan::AddWatchOnlyInMem
bool AddWatchOnlyInMem(const CScript &dest)
Definition: scriptpubkeyman.cpp:836
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.
Definition: scriptpubkeyman.h:189
WalletStorage::IsLocked
virtual bool IsLocked() const =0
LegacyScriptPubKeyMan::AddInactiveHDChain
void AddInactiveHDChain(const CHDChain &chain)
Definition: scriptpubkeyman.cpp:901
LegacyScriptPubKeyMan::CanGenerateKeys
bool CanGenerateKeys() const
Definition: scriptpubkeyman.cpp:1123
DescriptorScriptPubKeyMan::GetNewDestination
bool GetNewDestination(const OutputType type, CTxDestination &dest, std::string &error) override
Definition: scriptpubkeyman.cpp:1624
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:283
DescriptorScriptPubKeyMan::SetCache
void SetCache(const DescriptorCache &cache)
Definition: scriptpubkeyman.cpp:2267
CScriptID
A reference to a CScript: the Hash160 of its serialization (see script.h)
Definition: standard.h:65
DescriptorScriptPubKeyMan::Encrypt
bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch) override
Definition: scriptpubkeyman.cpp:1726
CKeyPool::Serialize
void Serialize(Stream &s) const
Definition: scriptpubkeyman.h:122
WalletBatch
Access to the wallet database.
Definition: walletdb.h:176
LegacyScriptPubKeyMan::GetMetadata
std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const override
Definition: scriptpubkeyman.cpp:608
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:1349
ScriptPubKeyMan::CanGetAddresses
virtual bool CanGetAddresses(bool internal=false) const
Returns true if the wallet can give out new addresses.
Definition: scriptpubkeyman.h:234
LegacySigningProvider
Wraps a LegacyScriptPubKeyMan so that it can be returned in a new unique_ptr.
Definition: scriptpubkeyman.h:631
CTxDestination
boost::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:132
CKeyMetadata
Definition: walletdb.h:121
LogPrintf
static void LogPrintf(const char *fmt, const Args &... args)
Definition: logging.h:175
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:658
WalletStorage::CanSupportFeature
virtual bool CanSupportFeature(enum WalletFeature) const =0
DescriptorScriptPubKeyMan::AddCryptedKey
bool AddCryptedKey(const CKeyID &key_id, const CPubKey &pubkey, const std::vector< uint8_t > &crypted_key)
Definition: scriptpubkeyman.cpp:2310
KeyOriginInfo
Definition: keyorigin.h:11
FlatSigningProvider
Definition: signingprovider.h:58
descriptor.h
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:278
ScriptPubKeyMan::GetTimeFirstKey
virtual int64_t GetTimeFirstKey() const
Definition: scriptpubkeyman.h:251
LegacyScriptPubKeyMan::AddWatchOnlyWithDB
bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:846