Bitcoin Core  22.99.0
P2P Digital Currency
Public Member Functions | Public Attributes | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
wallet::DescriptorScriptPubKeyMan Class Reference

#include <scriptpubkeyman.h>

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

Public Member Functions

 DescriptorScriptPubKeyMan (WalletStorage &storage, WalletDescriptor &descriptor)
 
 DescriptorScriptPubKeyMan (WalletStorage &storage)
 
bool GetNewDestination (const OutputType type, CTxDestination &dest, bilingual_str &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, bilingual_str &error) override
 
void ReturnDestination (int64_t index, bool internal, const CTxDestination &addr) override
 
bool TopUp (unsigned int size=0) override
 Fills internal address pool. More...
 
std::vector< WalletDestinationMarkUnusedAddresses (const CScript &script) override
 Mark unused addresses as being used Affects all keys up to and including the one determined by provided script. More...
 
bool IsHDEnabled () const override
 
bool SetupDescriptorGeneration (const CExtKey &master_key, OutputType addr_type, bool internal)
 Setup descriptors based on the given CExtkey. More...
 
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 successful. More...
 
bool HavePrivateKeys () const override
 
std::optional< int64_t > GetOldestKeyPoolTime () 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, bilingual_str > &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, 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. More...
 
uint256 GetID () const 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 UpdateWalletDescriptor (WalletDescriptor &descriptor)
 
bool CanUpdateToWalletDescriptor (const WalletDescriptor &descriptor, std::string &error)
 
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
 
bool GetDescriptorString (std::string &out, const bool priv) const
 
void UpgradeDescriptorCache ()
 
- Public Member Functions inherited from wallet::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 wallet::ScriptPubKeyMan
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
 Watch-only address added. More...
 
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
 Keypool has new keys. More...
 

Protected Member Functions

WalletDescriptor m_wallet_descriptor GUARDED_BY (cs_desc_man)
 

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

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< FlatSigningProviderGetSigningProvider (const CScript &script, bool include_private=false) const
 
std::unique_ptr< FlatSigningProviderGetSigningProvider (const CPubKey &pubkey) const
 
std::unique_ptr< FlatSigningProviderGetSigningProvider (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_decryption_thoroughly_checked = false
 keeps track of whether Unlock has run a thorough check before More...
 

Additional Inherited Members

- Protected Attributes inherited from wallet::ScriptPubKeyMan
WalletStoragem_storage
 

Detailed Description

Definition at line 526 of file scriptpubkeyman.h.

Member Typedef Documentation

◆ CryptedKeyMap

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

Definition at line 531 of file scriptpubkeyman.h.

◆ KeyMap

Definition at line 532 of file scriptpubkeyman.h.

◆ PubKeyMap

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

Definition at line 530 of file scriptpubkeyman.h.

◆ ScriptPubKeyMap

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

Definition at line 529 of file scriptpubkeyman.h.

Constructor & Destructor Documentation

◆ DescriptorScriptPubKeyMan() [1/2]

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

Definition at line 559 of file scriptpubkeyman.h.

◆ DescriptorScriptPubKeyMan() [2/2]

wallet::DescriptorScriptPubKeyMan::DescriptorScriptPubKeyMan ( WalletStorage storage)
inline

Definition at line 563 of file scriptpubkeyman.h.

Member Function Documentation

◆ AddCryptedKey()

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

Definition at line 2241 of file scriptpubkeyman.cpp.

◆ AddDescriptorKey()

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

Definition at line 1865 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ AddDescriptorKeyWithDB()

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

Definition at line 1874 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddKey()

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

Definition at line 2234 of file scriptpubkeyman.cpp.

◆ CanGetAddresses()

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

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 1981 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CanProvide()

bool wallet::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 wallet::ScriptPubKeyMan.

Definition at line 2067 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ CanUpdateToWalletDescriptor()

bool wallet::DescriptorScriptPubKeyMan::CanUpdateToWalletDescriptor ( const WalletDescriptor descriptor,
std::string &  error 
)

Definition at line 2344 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckDecryptionKey()

bool wallet::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 wallet::ScriptPubKeyMan.

Definition at line 1683 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ Encrypt()

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

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 1715 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ FillPSBT()

TransactionError wallet::DescriptorScriptPubKeyMan::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
overridevirtual

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

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 2104 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDescriptorString()

bool wallet::DescriptorScriptPubKeyMan::GetDescriptorString ( std::string &  out,
const bool  priv 
) const

Definition at line 2284 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetID()

uint256 wallet::DescriptorScriptPubKeyMan::GetID ( ) const
overridevirtual

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 2195 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetKeyPoolSize()

unsigned int wallet::DescriptorScriptPubKeyMan::GetKeyPoolSize ( ) const
overridevirtual

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 2004 of file scriptpubkeyman.cpp.

◆ GetKeys()

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

Definition at line 1757 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMetadata()

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

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 2177 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetNewDestination()

bool wallet::DescriptorScriptPubKeyMan::GetNewDestination ( const OutputType  type,
CTxDestination dest,
bilingual_str error 
)
overridevirtual

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 1630 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetOldestKeyPoolTime()

std::optional< int64_t > wallet::DescriptorScriptPubKeyMan::GetOldestKeyPoolTime ( ) const
overridevirtual

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 1997 of file scriptpubkeyman.cpp.

◆ GetReservedDestination()

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

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 1738 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetScriptPubKeys()

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

Definition at line 2272 of file scriptpubkeyman.cpp.

◆ GetSigningProvider() [1/3]

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

Definition at line 2030 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetSigningProvider() [2/3]

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

Definition at line 2016 of file scriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ GetSigningProvider() [3/3]

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

Definition at line 2045 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetSolvingProvider()

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

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 2062 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTimeFirstKey()

int64_t wallet::DescriptorScriptPubKeyMan::GetTimeFirstKey ( ) const
overridevirtual

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 2010 of file scriptpubkeyman.cpp.

◆ GetWalletDescriptor()

const WalletDescriptor wallet::DescriptorScriptPubKeyMan::GetWalletDescriptor ( ) const

Definition at line 2267 of file scriptpubkeyman.cpp.

◆ GUARDED_BY() [1/5]

ScriptPubKeyMap m_map_script_pub_keys wallet::DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private

◆ GUARDED_BY() [2/5]

PubKeyMap m_map_pubkeys wallet::DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private

◆ GUARDED_BY() [3/5]

KeyMap m_map_keys wallet::DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private

◆ GUARDED_BY() [4/5]

CryptedKeyMap m_map_crypted_keys wallet::DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private

◆ GUARDED_BY() [5/5]

WalletDescriptor m_wallet_descriptor wallet::DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
protected

◆ HasWalletDescriptor()

bool wallet::DescriptorScriptPubKeyMan::HasWalletDescriptor ( const WalletDescriptor desc) const

Definition at line 2252 of file scriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ HavePrivateKeys()

bool wallet::DescriptorScriptPubKeyMan::HavePrivateKeys ( ) const
overridevirtual

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 1991 of file scriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ IsHDEnabled()

bool wallet::DescriptorScriptPubKeyMan::IsHDEnabled ( ) const
overridevirtual

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 1975 of file scriptpubkeyman.cpp.

◆ IsMine()

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

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 1674 of file scriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ MarkUnusedAddresses()

std::vector< WalletDestination > wallet::DescriptorScriptPubKeyMan::MarkUnusedAddresses ( const CScript script)
overridevirtual

Mark unused addresses as being used Affects all keys up to and including the one determined by provided script.

Parameters
scriptdetermines the last key to mark as used
Returns
All of the addresses affected

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 1837 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ ReturnDestination()

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

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 1746 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ SetCache()

void wallet::DescriptorScriptPubKeyMan::SetCache ( const DescriptorCache cache)

Definition at line 2204 of file scriptpubkeyman.cpp.

◆ SetupDescriptor()

bool wallet::DescriptorScriptPubKeyMan::SetupDescriptor ( std::unique_ptr< Descriptor desc)

Provide a descriptor at setup time Returns false if already setup or setup fails, true if setup is successful.

◆ SetupDescriptorGeneration()

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

Setup descriptors based on the given CExtkey.

Definition at line 1904 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ SignMessage()

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

Sign a message with the given script.

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 2086 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ SignTransaction()

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

Creates new signatures and adds them to the transaction.

Returns whether all inputs were signed

Reimplemented from wallet::ScriptPubKeyMan.

Definition at line 2072 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TopUp()

bool wallet::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 wallet::ScriptPubKeyMan.

Definition at line 1774 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateWalletDescriptor()

void wallet::DescriptorScriptPubKeyMan::UpdateWalletDescriptor ( WalletDescriptor descriptor)

Definition at line 2330 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ UpgradeDescriptorCache()

void wallet::DescriptorScriptPubKeyMan::UpgradeDescriptorCache ( )

Definition at line 2301 of file scriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteDescriptor()

void wallet::DescriptorScriptPubKeyMan::WriteDescriptor ( )

Definition at line 2258 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ cs_desc_man

RecursiveMutex wallet::DescriptorScriptPubKeyMan::cs_desc_man
mutable

Definition at line 567 of file scriptpubkeyman.h.

◆ m_decryption_thoroughly_checked

bool wallet::DescriptorScriptPubKeyMan::m_decryption_thoroughly_checked = false
private

keeps track of whether Unlock has run a thorough check before

Definition at line 542 of file scriptpubkeyman.h.

◆ m_max_cached_index

int32_t wallet::DescriptorScriptPubKeyMan::m_max_cached_index = -1
private

Definition at line 536 of file scriptpubkeyman.h.


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