Bitcoin Core  22.99.0
P2P Digital Currency
scriptpubkeyman.h
Go to the documentation of this file.
1 // Copyright (c) 2019-2021 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 <optional>
23 #include <unordered_map>
24 
25 enum class OutputType;
26 struct bilingual_str;
27 
28 namespace wallet {
29 // Wallet storage things that ScriptPubKeyMans need in order to be able to store things to the wallet database.
30 // It provides access to things that are part of the entire wallet and not specific to a ScriptPubKeyMan such as
31 // wallet flags, wallet version, encryption keys, encryption status, and the database itself. This allows a
32 // ScriptPubKeyMan to have callbacks into CWallet without causing a circular dependency.
33 // WalletStorage should be the same for all ScriptPubKeyMans of a wallet.
35 {
36 public:
37  virtual ~WalletStorage() = default;
38  virtual const std::string GetDisplayName() const = 0;
39  virtual WalletDatabase& GetDatabase() 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) = 0;
44  virtual const CKeyingMaterial& GetEncryptionKey() const = 0;
45  virtual bool HasEncryptionKeys() const = 0;
46  virtual bool IsLocked() const = 0;
47 };
48 
50 static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000;
51 
52 std::vector<CKeyID> GetAffectedKeys(const CScript& spk, const SigningProvider& provider);
53 
103 class CKeyPool
104 {
105 public:
107  int64_t nTime;
111  bool fInternal;
114 
115  CKeyPool();
116  CKeyPool(const CPubKey& vchPubKeyIn, bool internalIn);
117 
118  template<typename Stream>
119  void Serialize(Stream& s) const
120  {
121  int nVersion = s.GetVersion();
122  if (!(s.GetType() & SER_GETHASH)) {
123  s << nVersion;
124  }
125  s << nTime << vchPubKey << fInternal << m_pre_split;
126  }
127 
128  template<typename Stream>
129  void Unserialize(Stream& s)
130  {
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&) {
139  /* flag as external address if we can't read the internal boolean
140  (this will be the case for any wallet before the HD chain split version) */
141  fInternal = false;
142  }
143  try {
144  s >> m_pre_split;
145  } catch (std::ios_base::failure&) {
146  /* flag as postsplit address if we can't read the m_pre_split boolean
147  (this will be the case for any wallet that upgrades to HD chain split) */
148  m_pre_split = false;
149  }
150  }
151 };
152 
154 {
156  std::optional<bool> internal;
157 };
158 
159 /*
160  * A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
161  * It contains the scripts and keys related to the scriptPubKeys it manages.
162  * A ScriptPubKeyMan will be able to give out scriptPubKeys to be used, as well as marking
163  * when a scriptPubKey has been used. It also handles when and how to store a scriptPubKey
164  * and its related scripts and keys, including encryption.
165  */
167 {
168 protected:
170 
171 public:
172  explicit ScriptPubKeyMan(WalletStorage& storage) : m_storage(storage) {}
173  virtual ~ScriptPubKeyMan() {};
174  virtual bool GetNewDestination(const OutputType type, CTxDestination& dest, bilingual_str& error) { return false; }
175  virtual isminetype IsMine(const CScript& script) const { return ISMINE_NO; }
176 
178  virtual bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) { return false; }
179  virtual bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) { return false; }
180 
181  virtual bool GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool, bilingual_str& error) { return false; }
182  virtual void KeepDestination(int64_t index, const OutputType& type) {}
183  virtual void ReturnDestination(int64_t index, bool internal, const CTxDestination& addr) {}
184 
189  virtual bool TopUp(unsigned int size = 0) { return false; }
190 
198  virtual std::vector<WalletDestination> MarkUnusedAddresses(const CScript& script) { return {}; }
199 
204  virtual bool SetupGeneration(bool force = false) { return false; }
205 
206  /* Returns true if HD is enabled */
207  virtual bool IsHDEnabled() const { return false; }
208 
209  /* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
210  virtual bool CanGetAddresses(bool internal = false) const { return false; }
211 
213  virtual bool Upgrade(int prev_version, int new_version, bilingual_str& error) { return true; }
214 
215  virtual bool HavePrivateKeys() const { return false; }
216 
218  virtual void RewriteDB() {}
219 
220  virtual std::optional<int64_t> GetOldestKeyPoolTime() const { return GetTime(); }
221 
222  virtual unsigned int GetKeyPoolSize() const { return 0; }
223 
224  virtual int64_t GetTimeFirstKey() const { return 0; }
225 
226  virtual std::unique_ptr<CKeyMetadata> GetMetadata(const CTxDestination& dest) const { return nullptr; }
227 
228  virtual std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const { return nullptr; }
229 
233  virtual bool CanProvide(const CScript& script, SignatureData& sigdata) { return false; }
234 
236  virtual bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const { return false; }
238  virtual SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const { return SigningResult::SIGNING_FAILED; };
240  virtual TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = SIGHASH_DEFAULT, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr, bool finalize = true) const { return TransactionError::INVALID_PSBT; }
241 
242  virtual uint256 GetID() const { return uint256(); }
243 
245  template<typename... Params>
246  void WalletLogPrintf(std::string fmt, Params... parameters) const {
247  LogPrintf(("%s " + fmt).c_str(), m_storage.GetDisplayName(), parameters...);
248  };
249 
251  boost::signals2::signal<void (bool fHaveWatchOnly)> NotifyWatchonlyChanged;
252 
254  boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
255 };
256 
258 static const std::unordered_set<OutputType> LEGACY_OUTPUT_TYPES {
262 };
263 
265 {
266 private:
269 
270  using WatchOnlySet = std::set<CScript>;
271  using WatchKeyMap = std::map<CKeyID, CPubKey>;
272 
273  WalletBatch *encrypted_batch GUARDED_BY(cs_KeyStore) = nullptr;
274 
275  using CryptedKeyMap = std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char>>>;
276 
277  CryptedKeyMap mapCryptedKeys GUARDED_BY(cs_KeyStore);
278  WatchOnlySet setWatchOnly GUARDED_BY(cs_KeyStore);
279  WatchKeyMap mapWatchKeys GUARDED_BY(cs_KeyStore);
280 
281  int64_t nTimeFirstKey GUARDED_BY(cs_KeyStore) = 0;
282 
283  bool AddKeyPubKeyInner(const CKey& key, const CPubKey &pubkey);
284  bool AddCryptedKeyInner(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
285 
297  bool AddWatchOnlyInMem(const CScript &dest);
299  bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript& dest, int64_t create_time) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
300 
302  bool AddKeyPubKeyWithDB(WalletBatch &batch,const CKey& key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
303 
304  void AddKeypoolPubkeyWithDB(const CPubKey& pubkey, const bool internal, WalletBatch& batch);
305 
307  bool AddCScriptWithDB(WalletBatch& batch, const CScript& script);
308 
310  bool AddKeyOriginWithDB(WalletBatch& batch, const CPubKey& pubkey, const KeyOriginInfo& info);
311 
312  /* the HD chain data model (external chain counters) */
314  std::unordered_map<CKeyID, CHDChain, SaltedSipHasher> m_inactive_hd_chains;
315 
316  /* HD derive new child key (on internal or external chain) */
317  void DeriveNewChildKey(WalletBatch& batch, CKeyMetadata& metadata, CKey& secret, CHDChain& hd_chain, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
318 
319  std::set<int64_t> setInternalKeyPool GUARDED_BY(cs_KeyStore);
320  std::set<int64_t> setExternalKeyPool GUARDED_BY(cs_KeyStore);
321  std::set<int64_t> set_pre_split_keypool GUARDED_BY(cs_KeyStore);
322  int64_t m_max_keypool_index GUARDED_BY(cs_KeyStore) = 0;
324  // Tracks keypool indexes to CKeyIDs of keys that have been taken out of the keypool but may be returned to it
326 
328  bool GetKeyFromPool(CPubKey &key, const OutputType type, bool internal = false);
329 
344  bool ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool fRequestedInternal);
345 
356  bool TopUpInactiveHDChain(const CKeyID seed_id, int64_t index, bool internal);
357 
358 public:
360 
361  bool GetNewDestination(const OutputType type, CTxDestination& dest, bilingual_str& error) override;
362  isminetype IsMine(const CScript& script) const override;
363 
364  bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) override;
365  bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) override;
366 
367  bool GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool, bilingual_str& error) override;
368  void KeepDestination(int64_t index, const OutputType& type) override;
369  void ReturnDestination(int64_t index, bool internal, const CTxDestination&) override;
370 
371  bool TopUp(unsigned int size = 0) override;
372 
373  std::vector<WalletDestination> MarkUnusedAddresses(const CScript& script) override;
374 
376  void UpgradeKeyMetadata();
377 
378  bool IsHDEnabled() const override;
379 
380  bool SetupGeneration(bool force = false) override;
381 
382  bool Upgrade(int prev_version, int new_version, bilingual_str& error) override;
383 
384  bool HavePrivateKeys() const override;
385 
386  void RewriteDB() override;
387 
388  std::optional<int64_t> GetOldestKeyPoolTime() const override;
389  size_t KeypoolCountExternalKeys() const;
390  unsigned int GetKeyPoolSize() const override;
391 
392  int64_t GetTimeFirstKey() const override;
393 
394  std::unique_ptr<CKeyMetadata> GetMetadata(const CTxDestination& dest) const override;
395 
396  bool CanGetAddresses(bool internal = false) const override;
397 
398  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const override;
399 
400  bool CanProvide(const CScript& script, SignatureData& sigdata) override;
401 
402  bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const override;
403  SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const override;
404  TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = SIGHASH_DEFAULT, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr, bool finalize = true) const override;
405 
406  uint256 GetID() const override;
407 
408  // Map from Key ID to key metadata.
409  std::map<CKeyID, CKeyMetadata> mapKeyMetadata GUARDED_BY(cs_KeyStore);
410 
411  // Map from Script ID to key metadata (for watch-only keys).
412  std::map<CScriptID, CKeyMetadata> m_script_metadata GUARDED_BY(cs_KeyStore);
413 
415  bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
417  bool LoadKey(const CKey& key, const CPubKey &pubkey);
419  bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
421  bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret, bool checksum_valid);
422  void UpdateTimeFirstKey(int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
424  bool LoadCScript(const CScript& redeemScript);
426  void LoadKeyMetadata(const CKeyID& keyID, const CKeyMetadata &metadata);
427  void LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata &metadata);
429  CPubKey GenerateNewKey(WalletBatch& batch, CHDChain& hd_chain, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
430 
431  /* Set the HD chain model (chain child index counters) and writes it to the database */
432  void AddHDChain(const CHDChain& chain);
434  void LoadHDChain(const CHDChain& chain);
435  const CHDChain& GetHDChain() const { return m_hd_chain; }
436  void AddInactiveHDChain(const CHDChain& chain);
437 
439  bool LoadWatchOnly(const CScript &dest);
441  bool HaveWatchOnly(const CScript &dest) const;
443  bool HaveWatchOnly() const;
445  bool RemoveWatchOnly(const CScript &dest);
446  bool AddWatchOnly(const CScript& dest, int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
447 
449  bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const;
450 
451  /* SigningProvider overrides */
452  bool HaveKey(const CKeyID &address) const override;
453  bool GetKey(const CKeyID &address, CKey& keyOut) const override;
454  bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
455  bool AddCScript(const CScript& redeemScript) override;
456  bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override;
457 
459  void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool);
460  bool NewKeyPool();
462 
463  bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
464  bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
465  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);
466  bool ImportScriptPubKeys(const std::set<CScript>& script_pub_keys, const bool have_solving_data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
467 
468  /* Returns true if the wallet can generate new keys */
469  bool CanGenerateKeys() const;
470 
471  /* Generates a new HD seed (will not be activated) */
473 
474  /* Derives a new HD seed (will not be activated) */
475  CPubKey DeriveNewSeed(const CKey& key);
476 
477  /* Set the current HD seed (will reset the chain child index counters)
478  Sets the seed's version based on the current wallet version (so the
479  caller must ensure the current wallet version is correct before calling
480  this function). */
481  void SetHDSeed(const CPubKey& key);
482 
489  void LearnRelatedScripts(const CPubKey& key, OutputType);
490 
495  void LearnAllRelatedScripts(const CPubKey& key);
496 
505  const std::map<CKeyID, int64_t>& GetAllReserveKeys() const { return m_pool_key_to_index; }
506 
507  std::set<CKeyID> GetKeys() const override;
508 };
509 
512 {
513 private:
515 public:
516  explicit LegacySigningProvider(const LegacyScriptPubKeyMan& spk_man) : m_spk_man(spk_man) {}
517 
518  bool GetCScript(const CScriptID &scriptid, CScript& script) const override { return m_spk_man.GetCScript(scriptid, script); }
519  bool HaveCScript(const CScriptID &scriptid) const override { return m_spk_man.HaveCScript(scriptid); }
520  bool GetPubKey(const CKeyID &address, CPubKey& pubkey) const override { return m_spk_man.GetPubKey(address, pubkey); }
521  bool GetKey(const CKeyID &address, CKey& key) const override { return false; }
522  bool HaveKey(const CKeyID &address) const override { return false; }
523  bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override { return m_spk_man.GetKeyOrigin(keyid, info); }
524 };
525 
527 {
528 private:
529  using ScriptPubKeyMap = std::map<CScript, int32_t>; // Map of scripts to descriptor range index
530  using PubKeyMap = std::map<CPubKey, int32_t>; // Map of pubkeys involved in scripts to descriptor range index
531  using CryptedKeyMap = std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char>>>;
532  using KeyMap = std::map<CKeyID, CKey>;
533 
534  ScriptPubKeyMap m_map_script_pub_keys GUARDED_BY(cs_desc_man);
535  PubKeyMap m_map_pubkeys GUARDED_BY(cs_desc_man);
536  int32_t m_max_cached_index = -1;
537 
538  KeyMap m_map_keys GUARDED_BY(cs_desc_man);
539  CryptedKeyMap m_map_crypted_keys GUARDED_BY(cs_desc_man);
540 
543 
544  bool AddDescriptorKeyWithDB(WalletBatch& batch, const CKey& key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
545 
547 
548  // Fetch the SigningProvider for the given script and optionally include private keys
549  std::unique_ptr<FlatSigningProvider> GetSigningProvider(const CScript& script, bool include_private = false) const;
550  // Fetch the SigningProvider for the given pubkey and always include private keys. This should only be called by signing code.
551  std::unique_ptr<FlatSigningProvider> GetSigningProvider(const CPubKey& pubkey) const;
552  // Fetch the SigningProvider for a given index and optionally include private keys. Called by the above functions.
553  std::unique_ptr<FlatSigningProvider> GetSigningProvider(int32_t index, bool include_private = false) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
554 
555 protected:
556  WalletDescriptor m_wallet_descriptor GUARDED_BY(cs_desc_man);
557 
558 public:
560  : ScriptPubKeyMan(storage),
561  m_wallet_descriptor(descriptor)
562  {}
564  : ScriptPubKeyMan(storage)
565  {}
566 
568 
569  bool GetNewDestination(const OutputType type, CTxDestination& dest, bilingual_str& error) override;
570  isminetype IsMine(const CScript& script) const override;
571 
572  bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) override;
573  bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) override;
574 
575  bool GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool, bilingual_str& error) override;
576  void ReturnDestination(int64_t index, bool internal, const CTxDestination& addr) override;
577 
578  // Tops up the descriptor cache and m_map_script_pub_keys. The cache is stored in the wallet file
579  // and is used to expand the descriptor in GetNewDestination. DescriptorScriptPubKeyMan relies
580  // more on ephemeral data than LegacyScriptPubKeyMan. For wallets using unhardened derivation
581  // (with or without private keys), the "keypool" is a single xpub.
582  bool TopUp(unsigned int size = 0) override;
583 
584  std::vector<WalletDestination> MarkUnusedAddresses(const CScript& script) override;
585 
586  bool IsHDEnabled() const override;
587 
589  bool SetupDescriptorGeneration(const CExtKey& master_key, OutputType addr_type, bool internal);
590 
594  bool SetupDescriptor(std::unique_ptr<Descriptor>desc);
595 
596  bool HavePrivateKeys() const override;
597 
598  std::optional<int64_t> GetOldestKeyPoolTime() const override;
599  unsigned int GetKeyPoolSize() const override;
600 
601  int64_t GetTimeFirstKey() const override;
602 
603  std::unique_ptr<CKeyMetadata> GetMetadata(const CTxDestination& dest) const override;
604 
605  bool CanGetAddresses(bool internal = false) const override;
606 
607  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const override;
608 
609  bool CanProvide(const CScript& script, SignatureData& sigdata) override;
610 
611  bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const override;
612  SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const override;
613  TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = SIGHASH_DEFAULT, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr, bool finalize = true) const override;
614 
615  uint256 GetID() const override;
616 
617  void SetCache(const DescriptorCache& cache);
618 
619  bool AddKey(const CKeyID& key_id, const CKey& key);
620  bool AddCryptedKey(const CKeyID& key_id, const CPubKey& pubkey, const std::vector<unsigned char>& crypted_key);
621 
622  bool HasWalletDescriptor(const WalletDescriptor& desc) const;
623  void UpdateWalletDescriptor(WalletDescriptor& descriptor);
624  bool CanUpdateToWalletDescriptor(const WalletDescriptor& descriptor, std::string& error);
625  void AddDescriptorKey(const CKey& key, const CPubKey &pubkey);
626  void WriteDescriptor();
627 
629  const std::vector<CScript> GetScriptPubKeys() const;
630 
631  bool GetDescriptorString(std::string& out, const bool priv) const;
632 
633  void UpgradeDescriptorCache();
634 };
635 } // namespace wallet
636 
637 #endif // BITCOIN_WALLET_SCRIPTPUBKEYMAN_H
wallet::DescriptorScriptPubKeyMan::GetSigningProvider
std::unique_ptr< FlatSigningProvider > GetSigningProvider(const CScript &script, bool include_private=false) const
Definition: scriptpubkeyman.cpp:2016
wallet::CKeyPool::Unserialize
void Unserialize(Stream &s)
Definition: scriptpubkeyman.h:129
wallet::LegacyScriptPubKeyMan::HavePrivateKeys
bool HavePrivateKeys() const override
Definition: scriptpubkeyman.cpp:510
wallet::LegacyScriptPubKeyMan::FillPSBT
TransactionError FillPSBT(PartiallySignedTransaction &psbt, const PrecomputedTransactionData &txdata, int sighash_type=SIGHASH_DEFAULT, bool sign=true, bool bip32derivs=false, int *n_signed=nullptr, bool finalize=true) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
Definition: scriptpubkeyman.cpp:623
wallet::WalletDatabase
An instance of this class represents one database.
Definition: db.h:104
wallet::LegacySigningProvider::GetKey
bool GetKey(const CKeyID &address, CKey &key) const override
Definition: scriptpubkeyman.h:521
wallet::DescriptorScriptPubKeyMan::AddKey
bool AddKey(const CKeyID &key_id, const CKey &key)
Definition: scriptpubkeyman.cpp:2234
crypter.h
wallet::LegacyScriptPubKeyMan::AddInactiveHDChain
void AddInactiveHDChain(const CHDChain &chain)
Definition: scriptpubkeyman.cpp:965
wallet::ScriptPubKeyMan::m_storage
WalletStorage & m_storage
Definition: scriptpubkeyman.h:169
wallet::LegacySigningProvider::GetKeyOrigin
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
Definition: scriptpubkeyman.h:523
wallet::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:238
wallet::WalletStorage::CanSupportFeature
virtual bool CanSupportFeature(enum WalletFeature) const =0
OutputType
OutputType
Definition: outputtype.h:18
wallet::LegacyScriptPubKeyMan::GetID
uint256 GetID() const override
Definition: scriptpubkeyman.cpp:692
wallet::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:113
wallet::LegacyScriptPubKeyMan::MarkReserveKeysAsUsed
std::vector< CKeyPool > MarkReserveKeysAsUsed(int64_t keypool_id) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Marks all keys in the keypool up to and including the provided key as used.
Definition: scriptpubkeyman.cpp:1440
wallet::isminetype
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
Definition: ismine.h:41
wallet::CKeyMetadata
Definition: walletdb.h:125
wallet::LegacyScriptPubKeyMan::AddCryptedKeyInner
bool AddCryptedKeyInner(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret)
Definition: scriptpubkeyman.cpp:827
wallet::DescriptorScriptPubKeyMan::GetNewDestination
bool GetNewDestination(const OutputType type, CTxDestination &dest, bilingual_str &error) override
Definition: scriptpubkeyman.cpp:1630
wallet::WalletStorage::SetMinVersion
virtual void SetMinVersion(enum WalletFeature, WalletBatch *=nullptr)=0
wallet::LegacyScriptPubKeyMan::AddWatchOnlyWithDB
bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:912
wallet::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:1376
wallet::DescriptorScriptPubKeyMan::CanGetAddresses
bool CanGetAddresses(bool internal=false) const override
Definition: scriptpubkeyman.cpp:1981
wallet::DescriptorScriptPubKeyMan::GetDescriptorString
bool GetDescriptorString(std::string &out, const bool priv) const
Definition: scriptpubkeyman.cpp:2284
wallet::DescriptorScriptPubKeyMan
Definition: scriptpubkeyman.h:526
wallet::GetAffectedKeys
std::vector< CKeyID > GetAffectedKeys(const CScript &spk, const SigningProvider &provider)
Definition: scriptpubkeyman.cpp:1468
wallet::LegacyScriptPubKeyMan::m_hd_chain
CHDChain m_hd_chain
Definition: scriptpubkeyman.h:313
wallet::LegacyScriptPubKeyMan::ReturnDestination
void ReturnDestination(int64_t index, bool internal, const CTxDestination &) override
Definition: scriptpubkeyman.cpp:1333
wallet::WalletStorage
Definition: scriptpubkeyman.h:34
wallet::LegacyScriptPubKeyMan::LoadKeyPool
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool)
Load a keypool entry.
Definition: scriptpubkeyman.cpp:1140
wallet::DescriptorScriptPubKeyMan::cs_desc_man
RecursiveMutex cs_desc_man
Definition: scriptpubkeyman.h:567
wallet::CKeyPool
A key from a CWallet's keypool.
Definition: scriptpubkeyman.h:103
wallet::ScriptPubKeyMan::FillPSBT
virtual TransactionError FillPSBT(PartiallySignedTransaction &psbt, const PrecomputedTransactionData &txdata, int sighash_type=SIGHASH_DEFAULT, bool sign=true, bool bip32derivs=false, int *n_signed=nullptr, bool finalize=true) const
Adds script and derivation path information to a PSBT, and optionally signs it.
Definition: scriptpubkeyman.h:240
OutputType::LEGACY
@ LEGACY
wallet::DescriptorScriptPubKeyMan::FillPSBT
TransactionError FillPSBT(PartiallySignedTransaction &psbt, const PrecomputedTransactionData &txdata, int sighash_type=SIGHASH_DEFAULT, bool sign=true, bool bip32derivs=false, int *n_signed=nullptr, bool finalize=true) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
Definition: scriptpubkeyman.cpp:2104
wallet::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:229
wallet::DescriptorScriptPubKeyMan::m_decryption_thoroughly_checked
bool m_decryption_thoroughly_checked
keeps track of whether Unlock has run a thorough check before
Definition: scriptpubkeyman.h:542
FillableSigningProvider
Fillable signing provider that keeps keys in an address->secret map.
Definition: signingprovider.h:90
wallet::LEGACY_OUTPUT_TYPES
static const std::unordered_set< OutputType > LEGACY_OUTPUT_TYPES
OutputTypes supported by the LegacyScriptPubKeyMan.
Definition: scriptpubkeyman.h:258
wallet::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:1572
bilingual_str
Bilingual messages:
Definition: translation.h:16
wallet::ScriptPubKeyMan::NotifyCanGetAddressesChanged
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
Definition: scriptpubkeyman.h:254
wallet::DescriptorScriptPubKeyMan::CanProvide
bool CanProvide(const CScript &script, SignatureData &sigdata) override
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that,...
Definition: scriptpubkeyman.cpp:2067
wallet::LegacyScriptPubKeyMan::UpdateTimeFirstKey
void UpdateTimeFirstKey(int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Update wallet first key creation time.
Definition: scriptpubkeyman.cpp:701
wallet::WalletStorage::GetDisplayName
virtual const std::string GetDisplayName() const =0
wallet::ScriptPubKeyMan::Encrypt
virtual bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch)
Definition: scriptpubkeyman.h:179
wallet::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:817
wallet::DescriptorScriptPubKeyMan::AddDescriptorKeyWithDB
bool AddDescriptorKeyWithDB(WalletBatch &batch, const CKey &key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
Definition: scriptpubkeyman.cpp:1874
wallet::LegacyScriptPubKeyMan::DeriveNewSeed
CPubKey DeriveNewSeed(const CKey &key)
Definition: scriptpubkeyman.cpp:1176
SigningProvider
An interface to be implemented by keystores that support signing.
Definition: signingprovider.h:17
wallet::LegacyScriptPubKeyMan::ImportScripts
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1525
wallet::LegacyScriptPubKeyMan::ImportPrivKeys
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1549
GetTime
int64_t GetTime()
DEPRECATED Use either GetTimeSeconds (not mockable) or GetTime<T> (mockable)
Definition: time.cpp:26
wallet::DescriptorScriptPubKeyMan::Encrypt
bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch) override
Definition: scriptpubkeyman.cpp:1715
wallet::LegacyScriptPubKeyMan::GenerateNewSeed
CPubKey GenerateNewSeed()
Definition: scriptpubkeyman.cpp:1168
wallet::LegacyScriptPubKeyMan::GetReservedDestination
bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool, bilingual_str &error) override
Definition: scriptpubkeyman.cpp:299
AnnotatedMixin< std::recursive_mutex >
wallet::ScriptPubKeyMan::~ScriptPubKeyMan
virtual ~ScriptPubKeyMan()
Definition: scriptpubkeyman.h:173
wallet::ScriptPubKeyMan::CanProvide
virtual bool CanProvide(const CScript &script, SignatureData &sigdata)
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that,...
Definition: scriptpubkeyman.h:233
wallet
Definition: node.h:38
wallet::LegacyScriptPubKeyMan::AddKeypoolPubkeyWithDB
void AddKeypoolPubkeyWithDB(const CPubKey &pubkey, const bool internal, WalletBatch &batch)
Definition: scriptpubkeyman.cpp:1303
CKeyID
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:23
wallet::LegacySigningProvider::HaveCScript
bool HaveCScript(const CScriptID &scriptid) const override
Definition: scriptpubkeyman.h:519
wallet::LegacyScriptPubKeyMan::Upgrade
bool Upgrade(int prev_version, int new_version, bilingual_str &error) override
Upgrades the wallet to the specified version.
Definition: scriptpubkeyman.cpp:469
wallet::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:2086
wallet::WalletStorage::GetDatabase
virtual WalletDatabase & GetDatabase() const =0
wallet::DescriptorScriptPubKeyMan::HasWalletDescriptor
bool HasWalletDescriptor(const WalletDescriptor &desc) const
Definition: scriptpubkeyman.cpp:2252
wallet::DescriptorScriptPubKeyMan::ScriptPubKeyMap
std::map< CScript, int32_t > ScriptPubKeyMap
Definition: scriptpubkeyman.h:529
SigningResult
SigningResult
Definition: message.h:42
wallet::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:895
wallet::CKeyingMaterial
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
Definition: crypter.h:62
wallet::LegacyScriptPubKeyMan::DeriveNewChildKey
void DeriveNewChildKey(WalletBatch &batch, CKeyMetadata &metadata, CKey &secret, CHDChain &hd_chain, bool internal=false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1085
wallet::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:246
wallet::LegacyScriptPubKeyMan::NewKeyPool
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
Definition: scriptpubkeyman.cpp:1223
wallet::LegacyScriptPubKeyMan::SetupGeneration
bool SetupGeneration(bool force=false) override
Sets up the key generation stuff, i.e.
Definition: scriptpubkeyman.cpp:434
wallet::LegacyScriptPubKeyMan::GetKeyPoolSize
unsigned int GetKeyPoolSize() const override
Definition: scriptpubkeyman.cpp:565
wallet::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:236
wallet::DescriptorScriptPubKeyMan::PubKeyMap
std::map< CPubKey, int32_t > PubKeyMap
Definition: scriptpubkeyman.h:530
wallet::DescriptorScriptPubKeyMan::GetTimeFirstKey
int64_t GetTimeFirstKey() const override
Definition: scriptpubkeyman.cpp:2010
signingprovider.h
wallet::DescriptorScriptPubKeyMan::GetOldestKeyPoolTime
std::optional< int64_t > GetOldestKeyPoolTime() const override
Definition: scriptpubkeyman.cpp:1997
ismine.h
wallet::LegacyScriptPubKeyMan::AddKeyPubKeyInner
bool AddKeyPubKeyInner(const CKey &key, const CPubKey &pubkey)
Definition: scriptpubkeyman.cpp:794
wallet::WalletFeature
WalletFeature
(client) version numbers for particular wallet features
Definition: walletutil.h:15
TransactionError
TransactionError
Definition: error.h:22
wallet::LegacyScriptPubKeyMan::AddCScript
bool AddCScript(const CScript &redeemScript) override
Definition: scriptpubkeyman.cpp:1498
wallet::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...
wallet::ScriptPubKeyMan::GetOldestKeyPoolTime
virtual std::optional< int64_t > GetOldestKeyPoolTime() const
Definition: scriptpubkeyman.h:220
walletutil.h
wallet::LegacySigningProvider
Wraps a LegacyScriptPubKeyMan so that it can be returned in a new unique_ptr.
Definition: scriptpubkeyman.h:511
wallet::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:725
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
wallet::ScriptPubKeyMan::IsMine
virtual isminetype IsMine(const CScript &script) const
Definition: scriptpubkeyman.h:175
SignatureData
Definition: sign.h:63
wallet::LegacyScriptPubKeyMan::AddKeyOriginWithDB
bool AddKeyOriginWithDB(WalletBatch &batch, const CPubKey &pubkey, const KeyOriginInfo &info)
Add a KeyOriginInfo to the wallet.
Definition: scriptpubkeyman.cpp:1515
CExtKey
Definition: key.h:161
Coin
A UTXO entry.
Definition: coins.h:30
wallet::ScriptPubKeyMan::MarkUnusedAddresses
virtual std::vector< WalletDestination > MarkUnusedAddresses(const CScript &script)
Mark unused addresses as being used Affects all keys up to and including the one determined by provid...
Definition: scriptpubkeyman.h:198
wallet::LegacyScriptPubKeyMan
Definition: scriptpubkeyman.h:264
wallet::LegacyScriptPubKeyMan::AddWatchOnlyInMem
bool AddWatchOnlyInMem(const CScript &dest)
Definition: scriptpubkeyman.cpp:900
wallet::LegacyScriptPubKeyMan::m_pool_key_to_index
std::map< CKeyID, int64_t > m_pool_key_to_index
Definition: scriptpubkeyman.h:323
wallet::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:1604
wallet::LegacyScriptPubKeyMan::MarkPreSplitKeys
void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Definition: scriptpubkeyman.cpp:1480
wallet::CKeyPool::nTime
int64_t nTime
The time at which the key was generated. Set in AddKeypoolPubKeyWithDB.
Definition: scriptpubkeyman.h:107
wallet::LegacyScriptPubKeyMan::GetOldestKeyPoolTime
std::optional< int64_t > GetOldestKeyPoolTime() const override
Definition: scriptpubkeyman.cpp:541
wallet::ScriptPubKeyMan::ScriptPubKeyMan
ScriptPubKeyMan(WalletStorage &storage)
Definition: scriptpubkeyman.h:172
message.h
wallet::LegacyScriptPubKeyMan::Encrypt
bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch) override
Definition: scriptpubkeyman.cpp:269
wallet::DescriptorScriptPubKeyMan::GetScriptPubKeys
const std::vector< CScript > GetScriptPubKeys() const
Definition: scriptpubkeyman.cpp:2272
wallet::ScriptPubKeyMan::GetSolvingProvider
virtual std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Definition: scriptpubkeyman.h:228
wallet::CKeyPool::fInternal
bool fInternal
Whether this keypool entry is in the internal keypool (for change outputs)
Definition: scriptpubkeyman.h:111
wallet::DEFAULT_KEYPOOL_SIZE
static const unsigned int DEFAULT_KEYPOOL_SIZE
Default for -keypool.
Definition: scriptpubkeyman.h:50
wallet::DescriptorScriptPubKeyMan::UpdateWalletDescriptor
void UpdateWalletDescriptor(WalletDescriptor &descriptor)
Definition: scriptpubkeyman.cpp:2330
TransactionError::INVALID_PSBT
@ INVALID_PSBT
time.h
wallet::LegacyScriptPubKeyMan::WatchKeyMap
std::map< CKeyID, CPubKey > WatchKeyMap
Definition: scriptpubkeyman.h:271
wallet::WalletBatch
Access to the wallet database.
Definition: walletdb.h:180
LogPrintf
#define LogPrintf(...)
Definition: logging.h:188
standard.h
wallet::LegacySigningProvider::HaveKey
bool HaveKey(const CKeyID &address) const override
Definition: scriptpubkeyman.h:522
wallet::ScriptPubKeyMan::IsHDEnabled
virtual bool IsHDEnabled() const
Definition: scriptpubkeyman.h:207
wallet::LegacyScriptPubKeyMan::RemoveWatchOnly
bool RemoveWatchOnly(const CScript &dest)
Remove a watch only script from the keystore.
Definition: scriptpubkeyman.cpp:874
wallet::LegacyScriptPubKeyMan::GetPubKey
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
Definition: scriptpubkeyman.cpp:1028
FillableSigningProvider::HaveCScript
virtual bool HaveCScript(const CScriptID &hash) const override
Definition: signingprovider.cpp:163
wallet::WalletStorage::~WalletStorage
virtual ~WalletStorage()=default
error.h
wallet::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:837
wallet::LegacyScriptPubKeyMan::GetTimeFirstKey
int64_t GetTimeFirstKey() const override
Definition: scriptpubkeyman.cpp:571
wallet::DescriptorScriptPubKeyMan::SetupDescriptorGeneration
bool SetupDescriptorGeneration(const CExtKey &master_key, OutputType addr_type, bool internal)
Setup descriptors based on the given CExtkey.
Definition: scriptpubkeyman.cpp:1904
wallet::ScriptPubKeyMan::GetMetadata
virtual std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const
Definition: scriptpubkeyman.h:226
PrecomputedTransactionData
Definition: interpreter.h:151
wallet::DescriptorScriptPubKeyMan::CanUpdateToWalletDescriptor
bool CanUpdateToWalletDescriptor(const WalletDescriptor &descriptor, std::string &error)
Definition: scriptpubkeyman.cpp:2344
wallet::LegacyScriptPubKeyMan::CanGenerateKeys
bool CanGenerateKeys() const
Definition: scriptpubkeyman.cpp:1161
wallet::CHDChain
Definition: walletdb.h:89
uint256
256-bit opaque blob.
Definition: uint256.h:126
wallet::DescriptorScriptPubKeyMan::IsHDEnabled
bool IsHDEnabled() const override
Definition: scriptpubkeyman.cpp:1975
wallet::DescriptorScriptPubKeyMan::GetWalletDescriptor
const WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
Definition: scriptpubkeyman.cpp:2267
wallet::DescriptorScriptPubKeyMan::IsMine
isminetype IsMine(const CScript &script) const override
Definition: scriptpubkeyman.cpp:1674
wallet::LegacyScriptPubKeyMan::CanProvide
bool CanProvide(const CScript &script, SignatureData &sigdata) override
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that,...
Definition: scriptpubkeyman.cpp:582
wallet::DescriptorScriptPubKeyMan::GetKeys
KeyMap GetKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
Definition: scriptpubkeyman.cpp:1757
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
wallet::ScriptPubKeyMan::GetReservedDestination
virtual bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool, bilingual_str &error)
Definition: scriptpubkeyman.h:181
wallet::DescriptorScriptPubKeyMan::ReturnDestination
void ReturnDestination(int64_t index, bool internal, const CTxDestination &addr) override
Definition: scriptpubkeyman.cpp:1746
wallet::ScriptPubKeyMan::KeepDestination
virtual void KeepDestination(int64_t index, const OutputType &type)
Definition: scriptpubkeyman.h:182
wallet::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:718
wallet::DescriptorScriptPubKeyMan::GetReservedDestination
bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool, bilingual_str &error) override
Definition: scriptpubkeyman.cpp:1738
wallet::LegacyScriptPubKeyMan::m_index_to_reserved_key
std::map< int64_t, CKeyID > m_index_to_reserved_key
Definition: scriptpubkeyman.h:325
wallet::LegacySigningProvider::m_spk_man
const LegacyScriptPubKeyMan & m_spk_man
Definition: scriptpubkeyman.h:514
wallet::CKeyPool::vchPubKey
CPubKey vchPubKey
The public key.
Definition: scriptpubkeyman.h:109
DescriptorCache
Cache for single descriptor's derived extended pubkeys.
Definition: descriptor.h:19
wallet::ScriptPubKeyMan::RewriteDB
virtual void RewriteDB()
The action to do when the DB needs rewrite.
Definition: scriptpubkeyman.h:218
wallet::ScriptPubKeyMan::CanGetAddresses
virtual bool CanGetAddresses(bool internal=false) const
Definition: scriptpubkeyman.h:210
wallet::DescriptorScriptPubKeyMan::SetCache
void SetCache(const DescriptorCache &cache)
Definition: scriptpubkeyman.cpp:2204
wallet::LegacyScriptPubKeyMan::fDecryptionThoroughlyChecked
bool fDecryptionThoroughlyChecked
keeps track of whether Unlock has run a thorough check before
Definition: scriptpubkeyman.h:268
wallet::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:1683
wallet::DescriptorScriptPubKeyMan::AddCryptedKey
bool AddCryptedKey(const CKeyID &key_id, const CPubKey &pubkey, const std::vector< unsigned char > &crypted_key)
Definition: scriptpubkeyman.cpp:2241
wallet::LegacyScriptPubKeyMan::GetHDChain
const CHDChain & GetHDChain() const
Definition: scriptpubkeyman.h:435
wallet::CKeyPool::CKeyPool
CKeyPool()
Definition: wallet.cpp:3061
wallet::LegacyScriptPubKeyMan::AddHDChain
void AddHDChain(const CHDChain &chain)
Definition: scriptpubkeyman.cpp:950
wallet::LegacyScriptPubKeyMan::GetSolvingProvider
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const override
Definition: scriptpubkeyman.cpp:577
OutputType::P2SH_SEGWIT
@ P2SH_SEGWIT
wallet::DescriptorScriptPubKeyMan::GetSolvingProvider
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const override
Definition: scriptpubkeyman.cpp:2062
OutputType::BECH32
@ BECH32
wallet::LegacyScriptPubKeyMan::CanGetAddresses
bool CanGetAddresses(bool internal=false) const override
Definition: scriptpubkeyman.cpp:452
PKHash
Definition: standard.h:79
wallet::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:321
wallet::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:713
wallet::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:610
wallet::ScriptPubKeyMan::HavePrivateKeys
virtual bool HavePrivateKeys() const
Definition: scriptpubkeyman.h:215
wallet::LegacyScriptPubKeyMan::GetKeyOrigin
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
Definition: scriptpubkeyman.cpp:998
wallet::DescriptorScriptPubKeyMan::GUARDED_BY
ScriptPubKeyMap m_map_script_pub_keys GUARDED_BY(cs_desc_man)
CPubKey
An encapsulated public key.
Definition: pubkey.h:33
wallet::LegacyScriptPubKeyMan::KeepDestination
void KeepDestination(int64_t index, const OutputType &type) override
Definition: scriptpubkeyman.cpp:1319
wallet::WalletStorage::IsLocked
virtual bool IsLocked() const =0
wallet::ScriptPubKeyMan::GetKeyPoolSize
virtual unsigned int GetKeyPoolSize() const
Definition: scriptpubkeyman.h:222
wallet::LegacyScriptPubKeyMan::TopUp
bool TopUp(unsigned int size=0) override
Fills internal address pool.
Definition: scriptpubkeyman.cpp:1257
wallet::DescriptorScriptPubKeyMan::TopUp
bool TopUp(unsigned int size=0) override
Fills internal address pool.
Definition: scriptpubkeyman.cpp:1774
CKey
An encapsulated private key.
Definition: key.h:26
wallet::LegacyScriptPubKeyMan::GUARDED_BY
WalletBatch *encrypted_batch GUARDED_BY(cs_KeyStore)
wallet::DescriptorScriptPubKeyMan::WriteDescriptor
void WriteDescriptor()
Definition: scriptpubkeyman.cpp:2258
wallet::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:2072
wallet::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:178
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
wallet::LegacyScriptPubKeyMan::GetKeyFromPool
bool GetKeyFromPool(CPubKey &key, const OutputType type, bool internal=false)
Fetches a key from the keypool.
Definition: scriptpubkeyman.cpp:1353
PartiallySignedTransaction
A version of CTransaction with the PSBT format.
Definition: psbt.h:668
wallet::LegacyScriptPubKeyMan::CryptedKeyMap
std::map< CKeyID, std::pair< CPubKey, std::vector< unsigned char > >> CryptedKeyMap
Definition: scriptpubkeyman.h:275
wallet::DescriptorScriptPubKeyMan::CryptedKeyMap
std::map< CKeyID, std::pair< CPubKey, std::vector< unsigned char > >> CryptedKeyMap
Definition: scriptpubkeyman.h:531
wallet::LegacyScriptPubKeyMan::IsHDEnabled
bool IsHDEnabled() const override
Definition: scriptpubkeyman.cpp:447
wallet::LegacyScriptPubKeyMan::LoadCScript
bool LoadCScript(const CScript &redeemScript)
Adds a CScript to the store.
Definition: scriptpubkeyman.cpp:765
std
Definition: setup_common.h:33
wallet::DescriptorScriptPubKeyMan::DescriptorScriptPubKeyMan
DescriptorScriptPubKeyMan(WalletStorage &storage)
Definition: scriptpubkeyman.h:563
wallet::LegacyScriptPubKeyMan::LoadScriptMetadata
void LoadScriptMetadata(const CScriptID &script_id, const CKeyMetadata &metadata)
Definition: scriptpubkeyman.cpp:787
wallet::WalletDestination
Definition: scriptpubkeyman.h:153
wallet::DescriptorScriptPubKeyMan::UpgradeDescriptorCache
void UpgradeDescriptorCache()
Definition: scriptpubkeyman.cpp:2301
wallet::DescriptorScriptPubKeyMan::GetID
uint256 GetID() const override
Definition: scriptpubkeyman.cpp:2195
wallet::ISMINE_NO
@ ISMINE_NO
Definition: ismine.h:42
SigningResult::SIGNING_FAILED
@ SIGNING_FAILED
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:561
wallet::DescriptorScriptPubKeyMan::MarkUnusedAddresses
std::vector< WalletDestination > MarkUnusedAddresses(const CScript &script) override
Mark unused addresses as being used Affects all keys up to and including the one determined by provid...
Definition: scriptpubkeyman.cpp:1837
wallet::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:932
wallet::LegacyScriptPubKeyMan::GetAllReserveKeys
const std::map< CKeyID, int64_t > & GetAllReserveKeys() const
Definition: scriptpubkeyman.h:505
wallet::DescriptorScriptPubKeyMan::AddDescriptorKey
void AddDescriptorKey(const CKey &key, const CPubKey &pubkey)
Definition: scriptpubkeyman.cpp:1865
wallet::LegacyScriptPubKeyMan::AddCScriptWithDB
bool AddCScriptWithDB(WalletBatch &batch, const CScript &script)
Adds a script to the store and saves it to disk.
Definition: scriptpubkeyman.cpp:1504
wallet::ScriptPubKeyMan::GetNewDestination
virtual bool GetNewDestination(const OutputType type, CTxDestination &dest, bilingual_str &error)
Definition: scriptpubkeyman.h:174
wallet::WalletStorage::GetEncryptionKey
virtual const CKeyingMaterial & GetEncryptionKey() const =0
wallet::WalletDestination::dest
CTxDestination dest
Definition: scriptpubkeyman.h:155
wallet::ScriptPubKeyMan::GetTimeFirstKey
virtual int64_t GetTimeFirstKey() const
Definition: scriptpubkeyman.h:224
wallet::LegacyScriptPubKeyMan::SetHDSeed
void SetHDSeed(const CPubKey &key)
Definition: scriptpubkeyman.cpp:1204
FillableSigningProvider::GetCScript
virtual bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const override
Definition: signingprovider.cpp:179
wallet::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:605
wallet::LegacyScriptPubKeyMan::WatchOnlySet
std::set< CScript > WatchOnlySet
Definition: scriptpubkeyman.h:270
wallet::WalletDescriptor
Descriptor with some wallet metadata.
Definition: walletutil.h:76
wallet::ScriptPubKeyMan::TopUp
virtual bool TopUp(unsigned int size=0)
Fills internal address pool.
Definition: scriptpubkeyman.h:189
walletdb.h
wallet::LegacyScriptPubKeyMan::GetKey
bool GetKey(const CKeyID &address, CKey &keyOut) const override
Definition: scriptpubkeyman.cpp:981
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
wallet::DescriptorScriptPubKeyMan::HavePrivateKeys
bool HavePrivateKeys() const override
Definition: scriptpubkeyman.cpp:1991
wallet::LegacyScriptPubKeyMan::MarkUnusedAddresses
std::vector< WalletDestination > MarkUnusedAddresses(const CScript &script) override
Mark unused addresses as being used Affects all keys up to and including the one determined by provid...
Definition: scriptpubkeyman.cpp:358
wallet::WalletStorage::IsWalletFlagSet
virtual bool IsWalletFlagSet(uint64_t) const =0
FillableSigningProvider::cs_KeyStore
RecursiveMutex cs_KeyStore
Definition: signingprovider.h:148
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
wallet::WalletStorage::UnsetBlankWalletFlag
virtual void UnsetBlankWalletFlag(WalletBatch &)=0
wallet::CKeyPool::Serialize
void Serialize(Stream &s) const
Definition: scriptpubkeyman.h:119
wallet::DescriptorScriptPubKeyMan::GetMetadata
std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const override
Definition: scriptpubkeyman.cpp:2177
wallet::WalletStorage::HasEncryptionKeys
virtual bool HasEncryptionKeys() const =0
wallet::LegacySigningProvider::GetPubKey
bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const override
Definition: scriptpubkeyman.h:520
wallet::LegacyScriptPubKeyMan::m_inactive_hd_chains
std::unordered_map< CKeyID, CHDChain, SaltedSipHasher > m_inactive_hd_chains
Definition: scriptpubkeyman.h:314
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:364
wallet::ScriptPubKeyMan::Upgrade
virtual bool Upgrade(int prev_version, int new_version, bilingual_str &error)
Upgrades the wallet to the specified version.
Definition: scriptpubkeyman.h:213
wallet::LegacyScriptPubKeyMan::IsMine
isminetype IsMine(const CScript &script) const override
Definition: scriptpubkeyman.cpp:215
wallet::ScriptPubKeyMan
Definition: scriptpubkeyman.h:166
wallet::ScriptPubKeyMan::ReturnDestination
virtual void ReturnDestination(int64_t index, bool internal, const CTxDestination &addr)
Definition: scriptpubkeyman.h:183
CScriptID
A reference to a CScript: the Hash160 of its serialization (see script.h)
Definition: standard.h:25
wallet::LegacyScriptPubKeyMan::UpgradeKeyMetadata
void UpgradeKeyMetadata()
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
Definition: scriptpubkeyman.cpp:399
wallet::ScriptPubKeyMan::SetupGeneration
virtual bool SetupGeneration(bool force=false)
Sets up the key generation stuff, i.e.
Definition: scriptpubkeyman.h:204
wallet::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:1422
wallet::LegacyScriptPubKeyMan::LoadHDChain
void LoadHDChain(const CHDChain &chain)
Load a HD chain model (used by LoadWallet)
Definition: scriptpubkeyman.cpp:944
wallet::LegacyScriptPubKeyMan::HaveKey
bool HaveKey(const CKeyID &address) const override
Definition: scriptpubkeyman.cpp:972
wallet::LegacyScriptPubKeyMan::LoadKeyMetadata
void LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &metadata)
Load metadata (used by LoadWallet)
Definition: scriptpubkeyman.cpp:780
wallet::DescriptorScriptPubKeyMan::m_max_cached_index
int32_t m_max_cached_index
Definition: scriptpubkeyman.h:536
wallet::LegacyScriptPubKeyMan::GetMetadata
std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const override
Definition: scriptpubkeyman.cpp:671
wallet::DescriptorScriptPubKeyMan::KeyMap
std::map< CKeyID, CKey > KeyMap
Definition: scriptpubkeyman.h:532
SER_GETHASH
@ SER_GETHASH
Definition: serialize.h:133
wallet::LegacySigningProvider::LegacySigningProvider
LegacySigningProvider(const LegacyScriptPubKeyMan &spk_man)
Definition: scriptpubkeyman.h:516
wallet::DescriptorScriptPubKeyMan::GetKeyPoolSize
unsigned int GetKeyPoolSize() const override
Definition: scriptpubkeyman.cpp:2004
wallet::LegacyScriptPubKeyMan::GetKeys
std::set< CKeyID > GetKeys() const override
Definition: scriptpubkeyman.cpp:1617
wallet::LegacyScriptPubKeyMan::RewriteDB
void RewriteDB() override
The action to do when the DB needs rewrite.
Definition: scriptpubkeyman.cpp:516
KeyOriginInfo
Definition: keyorigin.h:11
wallet::LegacyScriptPubKeyMan::GetWatchPubKey
bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const
Fetches a pubkey from mapWatchKeys if it exists there.
Definition: scriptpubkeyman.cpp:1017
FlatSigningProvider
Definition: signingprovider.h:72
wallet::LegacyScriptPubKeyMan::HaveWatchOnly
bool HaveWatchOnly() const
Returns whether there are any watch-only things in the wallet.
Definition: scriptpubkeyman.cpp:861
descriptor.h
wallet::LegacyScriptPubKeyMan::LearnAllRelatedScripts
void LearnAllRelatedScripts(const CPubKey &key)
Same as LearnRelatedScripts, but when the OutputType is not known (and could be anything).
Definition: scriptpubkeyman.cpp:1434
wallet::LegacySigningProvider::GetCScript
bool GetCScript(const CScriptID &scriptid, CScript &script) const override
Definition: scriptpubkeyman.h:518
wallet::ScriptPubKeyMan::GetID
virtual uint256 GetID() const
Definition: scriptpubkeyman.h:242
wallet::LegacyScriptPubKeyMan::GetNewDestination
bool GetNewDestination(const OutputType type, CTxDestination &dest, bilingual_str &error) override
Definition: scriptpubkeyman.cpp:24
wallet::LegacyScriptPubKeyMan::GenerateNewKey
CPubKey GenerateNewKey(WalletBatch &batch, CHDChain &hd_chain, bool internal=false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Generate a new key.
Definition: scriptpubkeyman.cpp:1048
wallet::ScriptPubKeyMan::NotifyWatchonlyChanged
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition: scriptpubkeyman.h:248
wallet::LegacyScriptPubKeyMan::KeypoolCountExternalKeys
size_t KeypoolCountExternalKeys() const
Definition: scriptpubkeyman.cpp:559
SIGHASH_DEFAULT
@ SIGHASH_DEFAULT
Taproot only; implied when sighash byte is missing, and equivalent to SIGHASH_ALL.
Definition: interpreter.h:33