Bitcoin Core  0.21.1
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules
Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
DescriptorScriptPubKeyMan Class Reference

#include <scriptpubkeyman.h>

Inheritance diagram for DescriptorScriptPubKeyMan:
[legend]
Collaboration diagram for DescriptorScriptPubKeyMan:
[legend]

Public Member Functions

 DescriptorScriptPubKeyMan (WalletStorage &storage, WalletDescriptor &descriptor)
 
 DescriptorScriptPubKeyMan (WalletStorage &storage, bool internal)
 
bool GetNewDestination (const OutputType type, CTxDestination &dest, std::string &error) override
 
isminetype IsMine (const CScript &script) const override
 
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 keys handled by it. More...
 
bool Encrypt (const CKeyingMaterial &master_key, WalletBatch *batch) override
 
bool GetReservedDestination (const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool) override
 
void ReturnDestination (int64_t index, bool internal, const CTxDestination &addr) override
 
bool TopUp (unsigned int size=0) override
 Fills internal address pool. More...
 
void MarkUnusedAddresses (const CScript &script) override
 Mark unused addresses as being used. More...
 
bool IsHDEnabled () const override
 
bool SetupDescriptorGeneration (const CExtKey &master_key, OutputType addr_type)
 Setup descriptors based on the given CExtkey. More...
 
bool HavePrivateKeys () const override
 
int64_t GetOldestKeyPoolTime () const override
 
size_t KeypoolCountExternalKeys () const override
 
unsigned int GetKeyPoolSize () const override
 
int64_t GetTimeFirstKey () const override
 
std::unique_ptr< CKeyMetadataGetMetadata (const CTxDestination &dest) const override
 
bool CanGetAddresses (bool internal=false) const override
 
std::unique_ptr< SigningProviderGetSolvingProvider (const CScript &script) const override
 
bool CanProvide (const CScript &script, SignatureData &sigdata) override
 Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that, combined with sigdata, can produce solving data. More...
 
bool SignTransaction (CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, int sighash, std::map< int, std::string > &input_errors) const override
 Creates new signatures and adds them to the transaction. More...
 
SigningResult SignMessage (const std::string &message, const PKHash &pkhash, std::string &str_sig) const override
 Sign a message with the given script. More...
 
TransactionError FillPSBT (PartiallySignedTransaction &psbt, int sighash_type=1, bool sign=true, bool bip32derivs=false, int *n_signed=nullptr) const override
 Adds script and derivation path information to a PSBT, and optionally signs it. More...
 
uint256 GetID () const override
 
void SetInternal (bool internal) override
 
void SetCache (const DescriptorCache &cache)
 
bool AddKey (const CKeyID &key_id, const CKey &key)
 
bool AddCryptedKey (const CKeyID &key_id, const CPubKey &pubkey, const std::vector< unsigned char > &crypted_key)
 
bool HasWalletDescriptor (const WalletDescriptor &desc) const
 
void AddDescriptorKey (const CKey &key, const CPubKey &pubkey)
 
void WriteDescriptor ()
 
const WalletDescriptor GetWalletDescriptor () const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
 
const std::vector< CScriptGetScriptPubKeys () const
 
- Public Member Functions inherited from ScriptPubKeyMan
 ScriptPubKeyMan (WalletStorage &storage)
 
virtual ~ScriptPubKeyMan ()
 
virtual void KeepDestination (int64_t index, const OutputType &type)
 
virtual bool SetupGeneration (bool force=false)
 Sets up the key generation stuff, i.e. More...
 
virtual bool Upgrade (int prev_version, int new_version, bilingual_str &error)
 Upgrades the wallet to the specified version. More...
 
virtual void RewriteDB ()
 The action to do when the DB needs rewrite. More...
 
template<typename... Params>
void WalletLogPrintf (std::string fmt, Params...parameters) const
 Prepends the wallet name in logging output to ease debugging in multi-wallet use cases. More...
 

Public Attributes

RecursiveMutex cs_desc_man
 
- Public Attributes inherited from ScriptPubKeyMan
boost::signals2::signal< void(bool
fHaveWatchOnly)> 
NotifyWatchonlyChanged
 Watch-only address added. More...
 
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
 Keypool has new keys. More...
 

Private Types

using ScriptPubKeyMap = std::map< CScript, int32_t >
 
using PubKeyMap = std::map< CPubKey, int32_t >
 
using CryptedKeyMap = std::map< CKeyID, std::pair< CPubKey, std::vector< unsigned char >>>
 
using KeyMap = std::map< CKeyID, CKey >
 

Private Member Functions

WalletDescriptor
m_wallet_descriptor 
GUARDED_BY (cs_desc_man)
 
ScriptPubKeyMap
m_map_script_pub_keys 
GUARDED_BY (cs_desc_man)
 
PubKeyMap m_map_pubkeys GUARDED_BY (cs_desc_man)
 
KeyMap m_map_keys GUARDED_BY (cs_desc_man)
 
CryptedKeyMap m_map_crypted_keys GUARDED_BY (cs_desc_man)
 
bool AddDescriptorKeyWithDB (WalletBatch &batch, const CKey &key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
 
KeyMap GetKeys () const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
 
std::unique_ptr
< FlatSigningProvider
GetSigningProvider (const CScript &script, bool include_private=false) const
 
std::unique_ptr
< FlatSigningProvider
GetSigningProvider (const CPubKey &pubkey) const
 
std::unique_ptr
< FlatSigningProvider
GetSigningProvider (int32_t index, bool include_private=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
 

Private Attributes

int32_t m_max_cached_index = -1
 
bool m_internal = false
 
bool m_decryption_thoroughly_checked = false
 keeps track of whether Unlock has run a thorough check before More...
 

Additional Inherited Members

- Protected Attributes inherited from ScriptPubKeyMan
WalletStoragem_storage
 

Detailed Description

Definition at line 516 of file scriptpubkeyman.h.

Member Typedef Documentation

using DescriptorScriptPubKeyMan::CryptedKeyMap = std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char>>>
private

Definition at line 523 of file scriptpubkeyman.h.

using DescriptorScriptPubKeyMan::KeyMap = std::map<CKeyID, CKey>
private

Definition at line 524 of file scriptpubkeyman.h.

using DescriptorScriptPubKeyMan::PubKeyMap = std::map<CPubKey, int32_t>
private

Definition at line 522 of file scriptpubkeyman.h.

using DescriptorScriptPubKeyMan::ScriptPubKeyMap = std::map<CScript, int32_t>
private

Definition at line 521 of file scriptpubkeyman.h.

Constructor & Destructor Documentation

DescriptorScriptPubKeyMan::DescriptorScriptPubKeyMan ( WalletStorage storage,
WalletDescriptor descriptor 
)
inline

Definition at line 550 of file scriptpubkeyman.h.

DescriptorScriptPubKeyMan::DescriptorScriptPubKeyMan ( WalletStorage storage,
bool  internal 
)
inline

Definition at line 554 of file scriptpubkeyman.h.

Member Function Documentation

bool DescriptorScriptPubKeyMan::AddCryptedKey ( const CKeyID key_id,
const CPubKey pubkey,
const std::vector< unsigned char > &  crypted_key 
)

Definition at line 2223 of file scriptpubkeyman.cpp.

void DescriptorScriptPubKeyMan::AddDescriptorKey ( const CKey key,
const CPubKey pubkey 
)

Definition at line 1844 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

bool DescriptorScriptPubKeyMan::AddDescriptorKeyWithDB ( WalletBatch batch,
const CKey key,
const CPubKey pubkey 
)
private

Definition at line 1853 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool DescriptorScriptPubKeyMan::AddKey ( const CKeyID key_id,
const CKey key 
)

Definition at line 2216 of file scriptpubkeyman.cpp.

bool DescriptorScriptPubKeyMan::CanGetAddresses ( bool  internal = false) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1950 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool DescriptorScriptPubKeyMan::CanProvide ( const CScript script,
SignatureData sigdata 
)
overridevirtual

Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that, combined with sigdata, can produce solving data.

Reimplemented from ScriptPubKeyMan.

Definition at line 2044 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

bool DescriptorScriptPubKeyMan::CheckDecryptionKey ( const CKeyingMaterial master_key,
bool  accept_no_keys = false 
)
overridevirtual

Check that the given decryption key is valid for this ScriptPubKeyMan, i.e. it decrypts all of the keys handled by it.

Reimplemented from ScriptPubKeyMan.

Definition at line 1650 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

bool DescriptorScriptPubKeyMan::Encrypt ( const CKeyingMaterial master_key,
WalletBatch batch 
)
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1682 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

TransactionError DescriptorScriptPubKeyMan::FillPSBT ( PartiallySignedTransaction psbt,
int  sighash_type = 1,
bool  sign = true,
bool  bip32derivs = false,
int *  n_signed = nullptr 
) const
overridevirtual

Adds script and derivation path information to a PSBT, and optionally signs it.

Reimplemented from ScriptPubKeyMan.

Definition at line 2081 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

uint256 DescriptorScriptPubKeyMan::GetID ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2172 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int DescriptorScriptPubKeyMan::GetKeyPoolSize ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1981 of file scriptpubkeyman.cpp.

Here is the caller graph for this function:

std::map< CKeyID, CKey > DescriptorScriptPubKeyMan::GetKeys ( ) const
private

Definition at line 1725 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::unique_ptr< CKeyMetadata > DescriptorScriptPubKeyMan::GetMetadata ( const CTxDestination dest) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2154 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

bool DescriptorScriptPubKeyMan::GetNewDestination ( const OutputType  type,
CTxDestination dest,
std::string &  error 
)
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1597 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int64_t DescriptorScriptPubKeyMan::GetOldestKeyPoolTime ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1966 of file scriptpubkeyman.cpp.

bool DescriptorScriptPubKeyMan::GetReservedDestination ( const OutputType  type,
bool  internal,
CTxDestination address,
int64_t &  index,
CKeyPool keypool 
)
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1705 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

const std::vector< CScript > DescriptorScriptPubKeyMan::GetScriptPubKeys ( ) const

Definition at line 2254 of file scriptpubkeyman.cpp.

std::unique_ptr< FlatSigningProvider > DescriptorScriptPubKeyMan::GetSigningProvider ( const CScript script,
bool  include_private = false 
) const
private

Definition at line 1993 of file scriptpubkeyman.cpp.

Here is the caller graph for this function:

std::unique_ptr< FlatSigningProvider > DescriptorScriptPubKeyMan::GetSigningProvider ( const CPubKey pubkey) const
private

Definition at line 2007 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

std::unique_ptr< FlatSigningProvider > DescriptorScriptPubKeyMan::GetSigningProvider ( int32_t  index,
bool  include_private = false 
) const
private

Definition at line 2022 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

std::unique_ptr< SigningProvider > DescriptorScriptPubKeyMan::GetSolvingProvider ( const CScript script) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2039 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int64_t DescriptorScriptPubKeyMan::GetTimeFirstKey ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1987 of file scriptpubkeyman.cpp.

const WalletDescriptor DescriptorScriptPubKeyMan::GetWalletDescriptor ( ) const

Definition at line 2249 of file scriptpubkeyman.cpp.

WalletDescriptor m_wallet_descriptor DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private
ScriptPubKeyMap m_map_script_pub_keys DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private
PubKeyMap m_map_pubkeys DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private
KeyMap m_map_keys DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private
CryptedKeyMap m_map_crypted_keys DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private
bool DescriptorScriptPubKeyMan::HasWalletDescriptor ( const WalletDescriptor desc) const

Definition at line 2234 of file scriptpubkeyman.cpp.

Here is the caller graph for this function:

bool DescriptorScriptPubKeyMan::HavePrivateKeys ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1960 of file scriptpubkeyman.cpp.

Here is the caller graph for this function:

bool DescriptorScriptPubKeyMan::IsHDEnabled ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1944 of file scriptpubkeyman.cpp.

isminetype DescriptorScriptPubKeyMan::IsMine ( const CScript script) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1641 of file scriptpubkeyman.cpp.

Here is the caller graph for this function:

size_t DescriptorScriptPubKeyMan::KeypoolCountExternalKeys ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1973 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

void DescriptorScriptPubKeyMan::MarkUnusedAddresses ( const CScript script)
overridevirtual

Mark unused addresses as being used.

Reimplemented from ScriptPubKeyMan.

Definition at line 1829 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

void DescriptorScriptPubKeyMan::ReturnDestination ( int64_t  index,
bool  internal,
const CTxDestination addr 
)
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 1714 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

void DescriptorScriptPubKeyMan::SetCache ( const DescriptorCache cache)

Definition at line 2186 of file scriptpubkeyman.cpp.

void DescriptorScriptPubKeyMan::SetInternal ( bool  internal)
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2181 of file scriptpubkeyman.cpp.

bool DescriptorScriptPubKeyMan::SetupDescriptorGeneration ( const CExtKey master_key,
OutputType  addr_type 
)

Setup descriptors based on the given CExtkey.

Definition at line 1877 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

SigningResult DescriptorScriptPubKeyMan::SignMessage ( const std::string &  message,
const PKHash pkhash,
std::string &  str_sig 
) const
overridevirtual

Sign a message with the given script.

Reimplemented from ScriptPubKeyMan.

Definition at line 2063 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

bool DescriptorScriptPubKeyMan::SignTransaction ( CMutableTransaction tx,
const std::map< COutPoint, Coin > &  coins,
int  sighash,
std::map< int, std::string > &  input_errors 
) const
overridevirtual

Creates new signatures and adds them to the transaction.

Returns whether all inputs were signed

Reimplemented from ScriptPubKeyMan.

Definition at line 2049 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

bool DescriptorScriptPubKeyMan::TopUp ( unsigned int  size = 0)
overridevirtual

Fills internal address pool.

Use within ScriptPubKeyMan implementations should be used sparingly and only when something from the address pool is removed, excluding GetNewDestination and GetReservedDestination. External wallet code is primarily responsible for topping up prior to fetching new addresses

Reimplemented from ScriptPubKeyMan.

Definition at line 1742 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void DescriptorScriptPubKeyMan::WriteDescriptor ( )

Definition at line 2240 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

RecursiveMutex DescriptorScriptPubKeyMan::cs_desc_man
mutable

Definition at line 559 of file scriptpubkeyman.h.

bool DescriptorScriptPubKeyMan::m_decryption_thoroughly_checked = false
private

keeps track of whether Unlock has run a thorough check before

Definition at line 536 of file scriptpubkeyman.h.

bool DescriptorScriptPubKeyMan::m_internal = false
private

Definition at line 530 of file scriptpubkeyman.h.

int32_t DescriptorScriptPubKeyMan::m_max_cached_index = -1
private

Definition at line 528 of file scriptpubkeyman.h.


The documentation for this class was generated from the following files: