Bitcoin Core  0.19.99
P2P Digital Currency
scriptpubkeyman.h
Go to the documentation of this file.
1 // Copyright (c) 2019-2020 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_WALLET_SCRIPTPUBKEYMAN_H
6 #define BITCOIN_WALLET_SCRIPTPUBKEYMAN_H
7 
8 #include <psbt.h>
10 #include <script/standard.h>
11 #include <util/error.h>
12 #include <util/message.h>
13 #include <wallet/crypter.h>
14 #include <wallet/ismine.h>
15 #include <wallet/walletdb.h>
16 #include <wallet/walletutil.h>
17 
18 #include <boost/signals2/signal.hpp>
19 
20 enum class OutputType;
21 
22 // Wallet storage things that ScriptPubKeyMans need in order to be able to store things to the wallet database.
23 // It provides access to things that are part of the entire wallet and not specific to a ScriptPubKeyMan such as
24 // wallet flags, wallet version, encryption keys, encryption status, and the database itself. This allows a
25 // ScriptPubKeyMan to have callbacks into CWallet without causing a circular dependency.
26 // WalletStorage should be the same for all ScriptPubKeyMans of a wallet.
28 {
29 public:
30  virtual ~WalletStorage() = default;
31  virtual const std::string GetDisplayName() const = 0;
32  virtual WalletDatabase& GetDatabase() = 0;
33  virtual bool IsWalletFlagSet(uint64_t) const = 0;
34  virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
35  virtual bool CanSupportFeature(enum WalletFeature) const = 0;
36  virtual void SetMinVersion(enum WalletFeature, WalletBatch* = nullptr, bool = false) = 0;
37  virtual const CKeyingMaterial& GetEncryptionKey() const = 0;
38  virtual bool HasEncryptionKeys() const = 0;
39  virtual bool IsLocked() const = 0;
40 };
41 
43 static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000;
44 
45 std::vector<CKeyID> GetAffectedKeys(const CScript& spk, const SigningProvider& provider);
46 
96 class CKeyPool
97 {
98 public:
100  int64_t nTime;
104  bool fInternal;
107 
108  CKeyPool();
109  CKeyPool(const CPubKey& vchPubKeyIn, bool internalIn);
110 
112 
113  template <typename Stream, typename Operation>
114  inline void SerializationOp(Stream& s, Operation ser_action) {
115  int nVersion = s.GetVersion();
116  if (!(s.GetType() & SER_GETHASH))
117  READWRITE(nVersion);
118  READWRITE(nTime);
119  READWRITE(vchPubKey);
120  if (ser_action.ForRead()) {
121  try {
122  READWRITE(fInternal);
123  }
124  catch (std::ios_base::failure&) {
125  /* flag as external address if we can't read the internal boolean
126  (this will be the case for any wallet before the HD chain split version) */
127  fInternal = false;
128  }
129  try {
130  READWRITE(m_pre_split);
131  }
132  catch (std::ios_base::failure&) {
133  /* flag as postsplit address if we can't read the m_pre_split boolean
134  (this will be the case for any wallet that upgrades to HD chain split)*/
135  m_pre_split = false;
136  }
137  }
138  else {
139  READWRITE(fInternal);
140  READWRITE(m_pre_split);
141  }
142  }
143 };
144 
145 /*
146  * A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
147  * It contains the scripts and keys related to the scriptPubKeys it manages.
148  * A ScriptPubKeyMan will be able to give out scriptPubKeys to be used, as well as marking
149  * when a scriptPubKey has been used. It also handles when and how to store a scriptPubKey
150  * and its related scripts and keys, including encryption.
151  */
153 {
154 protected:
156 
157 public:
158  ScriptPubKeyMan(WalletStorage& storage) : m_storage(storage) {}
159  virtual ~ScriptPubKeyMan() {};
160  virtual bool GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error) { return false; }
161  virtual isminetype IsMine(const CScript& script) const { return ISMINE_NO; }
162 
164  virtual bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) { return false; }
165  virtual bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) { return false; }
166 
167  virtual bool GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool) { return false; }
168  virtual void KeepDestination(int64_t index, const OutputType& type) {}
169  virtual void ReturnDestination(int64_t index, bool internal, const CTxDestination& addr) {}
170 
175  virtual bool TopUp(unsigned int size = 0) { return false; }
176 
178  virtual void MarkUnusedAddresses(const CScript& script) {}
179 
184  virtual bool SetupGeneration(bool force = false) { return false; }
185 
186  /* Returns true if HD is enabled */
187  virtual bool IsHDEnabled() const { return false; }
188 
189  /* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
190  virtual bool CanGetAddresses(bool internal = false) const { return false; }
191 
193  virtual bool Upgrade(int prev_version, std::string& error) { return false; }
194 
195  virtual bool HavePrivateKeys() const { return false; }
196 
198  virtual void RewriteDB() {}
199 
200  virtual int64_t GetOldestKeyPoolTime() const { return GetTime(); }
201 
202  virtual size_t KeypoolCountExternalKeys() const { return 0; }
203  virtual unsigned int GetKeyPoolSize() const { return 0; }
204 
205  virtual int64_t GetTimeFirstKey() const { return 0; }
206 
207  virtual const CKeyMetadata* GetMetadata(const CTxDestination& dest) const { return nullptr; }
208 
209  virtual std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const { return nullptr; }
210 
214  virtual bool CanProvide(const CScript& script, SignatureData& sigdata) { return false; }
215 
217  virtual bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, std::string>& input_errors) const { return false; }
219  virtual SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const { return SigningResult::SIGNING_FAILED; };
221  virtual TransactionError FillPSBT(PartiallySignedTransaction& psbt, int sighash_type = 1 /* SIGHASH_ALL */, bool sign = true, bool bip32derivs = false) const { return TransactionError::INVALID_PSBT; }
222 
223  virtual uint256 GetID() const { return uint256(); }
224 
226  template<typename... Params>
227  void WalletLogPrintf(std::string fmt, Params... parameters) const {
228  LogPrintf(("%s " + fmt).c_str(), m_storage.GetDisplayName(), parameters...);
229  };
230 
232  boost::signals2::signal<void (bool fHaveWatchOnly)> NotifyWatchonlyChanged;
233 
235  boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
236 };
237 
239 {
240 private:
242  bool fDecryptionThoroughlyChecked = false;
243 
244  using WatchOnlySet = std::set<CScript>;
245  using WatchKeyMap = std::map<CKeyID, CPubKey>;
246 
247  WalletBatch *encrypted_batch GUARDED_BY(cs_KeyStore) = nullptr;
248 
249  using CryptedKeyMap = std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char>>>;
250 
251  CryptedKeyMap mapCryptedKeys GUARDED_BY(cs_KeyStore);
252  WatchOnlySet setWatchOnly GUARDED_BY(cs_KeyStore);
253  WatchKeyMap mapWatchKeys GUARDED_BY(cs_KeyStore);
254 
255  int64_t nTimeFirstKey GUARDED_BY(cs_KeyStore) = 0;
256 
257  bool AddKeyPubKeyInner(const CKey& key, const CPubKey &pubkey);
258  bool AddCryptedKeyInner(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
259 
269  bool AddWatchOnly(const CScript& dest) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
270  bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript& dest) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
271  bool AddWatchOnlyInMem(const CScript &dest);
273  bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript& dest, int64_t create_time) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
274 
276  bool AddKeyPubKeyWithDB(WalletBatch &batch,const CKey& key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
277 
278  void AddKeypoolPubkeyWithDB(const CPubKey& pubkey, const bool internal, WalletBatch& batch);
279 
281  bool AddCScriptWithDB(WalletBatch& batch, const CScript& script);
282 
284  bool AddKeyOriginWithDB(WalletBatch& batch, const CPubKey& pubkey, const KeyOriginInfo& info);
285 
286  /* the HD chain data model (external chain counters) */
288 
289  /* HD derive new child key (on internal or external chain) */
290  void DeriveNewChildKey(WalletBatch& batch, CKeyMetadata& metadata, CKey& secret, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
291 
292  std::set<int64_t> setInternalKeyPool GUARDED_BY(cs_KeyStore);
293  std::set<int64_t> setExternalKeyPool GUARDED_BY(cs_KeyStore);
294  std::set<int64_t> set_pre_split_keypool GUARDED_BY(cs_KeyStore);
295  int64_t m_max_keypool_index GUARDED_BY(cs_KeyStore) = 0;
296  std::map<CKeyID, int64_t> m_pool_key_to_index;
297  // Tracks keypool indexes to CKeyIDs of keys that have been taken out of the keypool but may be returned to it
298  std::map<int64_t, CKeyID> m_index_to_reserved_key;
299 
301  bool GetKeyFromPool(CPubKey &key, const OutputType type, bool internal = false);
302 
317  bool ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool fRequestedInternal);
318 
319 public:
321 
322  bool GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error) override;
323  isminetype IsMine(const CScript& script) const override;
324 
325  bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) override;
326  bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) override;
327 
328  bool GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool) override;
329  void KeepDestination(int64_t index, const OutputType& type) override;
330  void ReturnDestination(int64_t index, bool internal, const CTxDestination&) override;
331 
332  bool TopUp(unsigned int size = 0) override;
333 
334  void MarkUnusedAddresses(const CScript& script) override;
335 
337  void UpgradeKeyMetadata();
338 
339  bool IsHDEnabled() const override;
340 
341  bool SetupGeneration(bool force = false) override;
342 
343  bool Upgrade(int prev_version, std::string& error) override;
344 
345  bool HavePrivateKeys() const override;
346 
347  void RewriteDB() override;
348 
349  int64_t GetOldestKeyPoolTime() const override;
350  size_t KeypoolCountExternalKeys() const override;
351  unsigned int GetKeyPoolSize() const override;
352 
353  int64_t GetTimeFirstKey() const override;
354 
355  const CKeyMetadata* GetMetadata(const CTxDestination& dest) const override;
356 
357  bool CanGetAddresses(bool internal = false) const override;
358 
359  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const override;
360 
361  bool CanProvide(const CScript& script, SignatureData& sigdata) override;
362 
363  bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, std::string>& input_errors) const override;
364  SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const override;
365  TransactionError FillPSBT(PartiallySignedTransaction& psbt, int sighash_type = 1 /* SIGHASH_ALL */, bool sign = true, bool bip32derivs = false) const override;
366 
367  uint256 GetID() const override;
368 
369  // Map from Key ID to key metadata.
370  std::map<CKeyID, CKeyMetadata> mapKeyMetadata GUARDED_BY(cs_KeyStore);
371 
372  // Map from Script ID to key metadata (for watch-only keys).
373  std::map<CScriptID, CKeyMetadata> m_script_metadata GUARDED_BY(cs_KeyStore);
374 
376  bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
378  bool LoadKey(const CKey& key, const CPubKey &pubkey);
380  bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
382  bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
383  void UpdateTimeFirstKey(int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
385  bool LoadCScript(const CScript& redeemScript);
387  void LoadKeyMetadata(const CKeyID& keyID, const CKeyMetadata &metadata);
388  void LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata &metadata);
390  CPubKey GenerateNewKey(WalletBatch& batch, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
391 
392  /* Set the HD chain model (chain child index counters) */
393  void SetHDChain(const CHDChain& chain, bool memonly);
394  const CHDChain& GetHDChain() const { return hdChain; }
395 
397  bool LoadWatchOnly(const CScript &dest);
399  bool HaveWatchOnly(const CScript &dest) const;
401  bool HaveWatchOnly() const;
403  bool RemoveWatchOnly(const CScript &dest);
404  bool AddWatchOnly(const CScript& dest, int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
405 
407  bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const;
408 
409  /* SigningProvider overrides */
410  bool HaveKey(const CKeyID &address) const override;
411  bool GetKey(const CKeyID &address, CKey& keyOut) const override;
412  bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
413  bool AddCScript(const CScript& redeemScript) override;
414  bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override;
415 
417  void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool);
418  bool NewKeyPool();
419  void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
420 
421  bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
422  bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
423  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);
424  bool ImportScriptPubKeys(const std::set<CScript>& script_pub_keys, const bool have_solving_data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
425 
426  /* Returns true if the wallet can generate new keys */
427  bool CanGenerateKeys() const;
428 
429  /* Generates a new HD seed (will not be activated) */
430  CPubKey GenerateNewSeed();
431 
432  /* Derives a new HD seed (will not be activated) */
433  CPubKey DeriveNewSeed(const CKey& key);
434 
435  /* Set the current HD seed (will reset the chain child index counters)
436  Sets the seed's version based on the current wallet version (so the
437  caller must ensure the current wallet version is correct before calling
438  this function). */
439  void SetHDSeed(const CPubKey& key);
440 
447  void LearnRelatedScripts(const CPubKey& key, OutputType);
448 
453  void LearnAllRelatedScripts(const CPubKey& key);
454 
458  void MarkReserveKeysAsUsed(int64_t keypool_id) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
459  const std::map<CKeyID, int64_t>& GetAllReserveKeys() const { return m_pool_key_to_index; }
460 
461  std::set<CKeyID> GetKeys() const override;
462 };
463 
466 {
467 private:
469 public:
470  LegacySigningProvider(const LegacyScriptPubKeyMan& spk_man) : m_spk_man(spk_man) {}
471 
472  bool GetCScript(const CScriptID &scriptid, CScript& script) const override { return m_spk_man.GetCScript(scriptid, script); }
473  bool HaveCScript(const CScriptID &scriptid) const override { return m_spk_man.HaveCScript(scriptid); }
474  bool GetPubKey(const CKeyID &address, CPubKey& pubkey) const override { return m_spk_man.GetPubKey(address, pubkey); }
475  bool GetKey(const CKeyID &address, CKey& key) const override { return false; }
476  bool HaveKey(const CKeyID &address) const override { return false; }
477  bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override { return m_spk_man.GetKeyOrigin(keyid, info); }
478 };
479 
480 #endif // BITCOIN_WALLET_SCRIPTPUBKEYMAN_H
void SignTransaction(CMutableTransaction &mtx, const SigningProvider *keystore, const std::map< COutPoint, Coin > &coins, const UniValue &hashType, UniValue &result)
Sign a transaction with the given keystore and previous transactions.
const LegacyScriptPubKeyMan & m_spk_man
virtual const CKeyingMaterial & GetEncryptionKey() const =0
bool GetCScript(const CScriptID &scriptid, CScript &script) const override
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
virtual void UnsetBlankWalletFlag(WalletBatch &)=0
virtual bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const override
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
virtual TransactionError FillPSBT(PartiallySignedTransaction &psbt, int sighash_type=1, bool sign=true, bool bip32derivs=false) const
Adds script and derivation path information to a PSBT, and optionally signs it.
virtual const std::string GetDisplayName() const =0
A UTXO entry.
Definition: coins.h:30
virtual ~ScriptPubKeyMan()
SigningResult
Definition: message.h:42
bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const override
virtual size_t KeypoolCountExternalKeys() const
bool HaveKey(const SigningProvider &wallet, const CKey &key)
Checks if a CKey is in the given CWallet compressed or otherwise.
Definition: rpcwallet.cpp:71
std::set< CScript > WatchOnlySet
An instance of this class represents one database.
Definition: db.h:111
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
Definition: crypter.h:67
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
virtual void RewriteDB()
The action to do when the DB needs rewrite.
static void LogPrintf(const char *fmt, const Args &... args)
Definition: logging.h:163
bool GetKey(const CKeyID &address, CKey &key) const override
bool HaveKey(const CKeyID &address) const override
virtual WalletDatabase & GetDatabase()=0
A version of CTransaction with the PSBT format.
Definition: psbt.h:388
virtual const CKeyMetadata * GetMetadata(const CTxDestination &dest) const
std::map< CKeyID, std::pair< CPubKey, std::vector< unsigned char > >> CryptedKeyMap
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
virtual bool IsWalletFlagSet(uint64_t) const =0
virtual int64_t GetTimeFirstKey() const
OutputType
Definition: outputtype.h:17
virtual bool Upgrade(int prev_version, std::string &error)
Upgrades the wallet to the specified version.
WalletFeature
(client) version numbers for particular wallet features
Definition: walletutil.h:13
const std::map< CKeyID, int64_t > & GetAllReserveKeys() const
virtual unsigned int GetKeyPoolSize() const
Access to the wallet database.
Definition: walletdb.h:175
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
virtual void KeepDestination(int64_t index, const OutputType &type)
virtual bool CanProvide(const CScript &script, SignatureData &sigdata)
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that...
int64_t nTime
The time at which the key was generated. Set in AddKeypoolPubKeyWithDB.
virtual uint256 GetID() const
ScriptPubKeyMan(WalletStorage &storage)
virtual ~WalletStorage()=default
static const unsigned int DEFAULT_KEYPOOL_SIZE
Default for -keypool.
virtual bool IsHDEnabled() const
An encapsulated public key.
Definition: pubkey.h:30
std::map< CKeyID, CPubKey > WatchKeyMap
Fillable signing provider that keeps keys in an address->secret map.
virtual void MarkUnusedAddresses(const CScript &script)
Mark unused addresses as being used.
Wraps a LegacyScriptPubKeyMan so that it can be returned in a new unique_ptr.
LegacySigningProvider(const LegacyScriptPubKeyMan &spk_man)
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...
bool m_pre_split
Whether this key was generated for a keypool before the wallet was upgraded to HD-split.
isminetype
IsMine() return codes.
Definition: ismine.h:18
virtual bool HavePrivateKeys() const
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:18
virtual bool IsLocked() const =0
virtual void ReturnDestination(int64_t index, bool internal, const CTxDestination &addr)
256-bit opaque blob.
Definition: uint256.h:120
CPubKey vchPubKey
The public key.
virtual bool CanSupportFeature(enum WalletFeature) const =0
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51
An interface to be implemented by keystores that support signing.
virtual bool TopUp(unsigned int size=0)
Fills internal address pool.
const CChainParams & Params()
Return the currently selected parameters.
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:390
static bool GetPubKey(const SigningProvider &provider, const SignatureData &sigdata, const CKeyID &address, CPubKey &pubkey)
Definition: sign.cpp:52
bool HaveCScript(const CScriptID &scriptid) const override
virtual SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
Sign a message with the given script.
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:20
virtual bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch)
TransactionError
Definition: error.h:22
virtual bool HaveCScript(const CScriptID &hash) const override
virtual isminetype IsMine(const CScript &script) const
#define GUARDED_BY(x)
Definition: threadsafety.h:38
A reference to a CScript: the Hash160 of its serialization (see script.h)
Definition: standard.h:21
void SerializationOp(Stream &s, Operation ser_action)
virtual bool HasEncryptionKeys() const =0
A mutable version of CTransaction.
Definition: transaction.h:366
virtual int64_t GetOldestKeyPoolTime() const
An encapsulated private key.
Definition: key.h:27
virtual bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool)
WalletStorage & m_storage
boost::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:143
virtual bool GetNewDestination(const OutputType type, CTxDestination &dest, std::string &error)
#define READWRITE(...)
Definition: serialize.h:191
int64_t GetTime()
Return system time (or mocked time, if set)
Definition: time.cpp:23
virtual bool SetupGeneration(bool force=false)
Sets up the key generation stuff, i.e.
virtual void SetMinVersion(enum WalletFeature, WalletBatch *=nullptr, bool=false)=0
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
virtual std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
virtual bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, int sighash, std::map< int, std::string > &input_errors) const
Creates new signatures and adds them to the transaction.
bool fInternal
Whether this keypool entry is in the internal keypool (for change outputs)
virtual bool CanGetAddresses(bool internal=false) const
std::vector< CKeyID > GetAffectedKeys(const CScript &spk, const SigningProvider &provider)
A key from a CWallet&#39;s keypool.