Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
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.
 
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.
 
void MarkUnusedAddresses (const CScript &script) override
 Mark unused addresses as being used.
 
bool IsHDEnabled () const override
 
bool SetupDescriptorGeneration (const CExtKey &master_key, OutputType addr_type)
 Setup descriptors based on the given CExtkey.
 
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
 Returns true if the wallet can give out new addresses.
 
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.
 
bool SignTransaction (CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, SigHashType sighash, std::map< int, std::string > &input_errors) const override
 Creates new signatures and adds them to the transaction.
 
SigningResult SignMessage (const std::string &message, const PKHash &pkhash, std::string &str_sig) const override
 Sign a message with the given script.
 
TransactionError FillPSBT (PartiallySignedTransaction &psbt, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=false) const override
 Adds script and derivation path information to a PSBT, and optionally signs it.
 
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< uint8_t > &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
 
- 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.
 
virtual bool Upgrade (int prev_version, bilingual_str &error)
 Upgrades the wallet to the specified version.
 
virtual void RewriteDB ()
 The action to do when the DB needs rewrite.
 
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.
 

Public Attributes

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

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< uint8_t > > >
 
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< 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_internal = false
 
bool m_decryption_thoroughly_checked = false
 keeps track of whether Unlock has run a thorough check before
 

Additional Inherited Members

- Protected Attributes inherited from ScriptPubKeyMan
WalletStoragem_storage
 

Detailed Description

Definition at line 651 of file scriptpubkeyman.h.

Member Typedef Documentation

◆ CryptedKeyMap

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

Definition at line 659 of file scriptpubkeyman.h.

◆ KeyMap

Definition at line 661 of file scriptpubkeyman.h.

◆ PubKeyMap

Definition at line 658 of file scriptpubkeyman.h.

◆ ScriptPubKeyMap

Definition at line 656 of file scriptpubkeyman.h.

Constructor & Destructor Documentation

◆ DescriptorScriptPubKeyMan() [1/2]

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

Definition at line 697 of file scriptpubkeyman.h.

◆ DescriptorScriptPubKeyMan() [2/2]

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

Definition at line 700 of file scriptpubkeyman.h.

Member Function Documentation

◆ AddCryptedKey()

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

Definition at line 2318 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ AddDescriptorKey()

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

Definition at line 1924 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ AddDescriptorKeyWithDB()

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

Definition at line 1934 of file scriptpubkeyman.cpp.

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

◆ AddKey()

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

Definition at line 2312 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ CanGetAddresses()

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

Returns true if the wallet can give out new addresses.

This means it has keys in the keypool or can generate new keys.

Reimplemented from ScriptPubKeyMan.

Definition at line 2033 of file scriptpubkeyman.cpp.

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

◆ CanProvide()

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 2132 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ CanUpdateToWalletDescriptor()

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

Definition at line 2377 of file scriptpubkeyman.cpp.

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

◆ CheckDecryptionKey()

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 1691 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ Encrypt()

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

Reimplemented from ScriptPubKeyMan.

Definition at line 1728 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ FillPSBT()

TransactionError DescriptorScriptPubKeyMan::FillPSBT ( PartiallySignedTransaction psbt,
SigHashType  sighash_type = SigHashType().withForkId(),
bool  sign = true,
bool  bip32derivs = false 
) const
overridevirtual

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

Reimplemented from ScriptPubKeyMan.

Definition at line 2176 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetID()

uint256 DescriptorScriptPubKeyMan::GetID ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2261 of file scriptpubkeyman.cpp.

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

◆ GetKeyPoolSize()

unsigned int DescriptorScriptPubKeyMan::GetKeyPoolSize ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2063 of file scriptpubkeyman.cpp.

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

◆ GetKeys()

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

Definition at line 1775 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 > DescriptorScriptPubKeyMan::GetMetadata ( const CTxDestination dest) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2242 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetNewDestination()

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

Reimplemented from ScriptPubKeyMan.

Definition at line 1626 of file scriptpubkeyman.cpp.

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

◆ GetOldestKeyPoolTime()

int64_t DescriptorScriptPubKeyMan::GetOldestKeyPoolTime ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2049 of file scriptpubkeyman.cpp.

◆ GetReservedDestination()

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

Reimplemented from ScriptPubKeyMan.

Definition at line 1751 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetScriptPubKeys()

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

Definition at line 2352 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetSigningProvider() [1/3]

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

Definition at line 2089 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetSigningProvider() [2/3]

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

Definition at line 2074 of file scriptpubkeyman.cpp.

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

◆ GetSigningProvider() [3/3]

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

Definition at line 2105 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetSolvingProvider()

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

Reimplemented from ScriptPubKeyMan.

Definition at line 2128 of file scriptpubkeyman.cpp.

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

◆ GetTimeFirstKey()

int64_t DescriptorScriptPubKeyMan::GetTimeFirstKey ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2068 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetWalletDescriptor()

const WalletDescriptor DescriptorScriptPubKeyMan::GetWalletDescriptor ( ) const

Definition at line 2348 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GUARDED_BY() [1/5]

WalletDescriptor m_wallet_descriptor DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private

◆ GUARDED_BY() [2/5]

ScriptPubKeyMap m_map_script_pub_keys DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private

◆ GUARDED_BY() [3/5]

PubKeyMap m_map_pubkeys DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private

◆ GUARDED_BY() [4/5]

KeyMap m_map_keys DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private

◆ GUARDED_BY() [5/5]

CryptedKeyMap m_map_crypted_keys DescriptorScriptPubKeyMan::GUARDED_BY ( cs_desc_man  )
private

◆ HasWalletDescriptor()

bool DescriptorScriptPubKeyMan::HasWalletDescriptor ( const WalletDescriptor desc) const

Definition at line 2330 of file scriptpubkeyman.cpp.

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

◆ HavePrivateKeys()

bool DescriptorScriptPubKeyMan::HavePrivateKeys ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2044 of file scriptpubkeyman.cpp.

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

◆ IsHDEnabled()

bool DescriptorScriptPubKeyMan::IsHDEnabled ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2028 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ IsMine()

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

Reimplemented from ScriptPubKeyMan.

Definition at line 1683 of file scriptpubkeyman.cpp.

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

◆ KeypoolCountExternalKeys()

size_t DescriptorScriptPubKeyMan::KeypoolCountExternalKeys ( ) const
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2056 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ MarkUnusedAddresses()

void DescriptorScriptPubKeyMan::MarkUnusedAddresses ( const CScript script)
overridevirtual

Mark unused addresses as being used.

Reimplemented from ScriptPubKeyMan.

Definition at line 1907 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ ReturnDestination()

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

Reimplemented from ScriptPubKeyMan.

Definition at line 1763 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ SetCache()

void DescriptorScriptPubKeyMan::SetCache ( const DescriptorCache cache)

Definition at line 2275 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ SetInternal()

void DescriptorScriptPubKeyMan::SetInternal ( bool  internal)
overridevirtual

Reimplemented from ScriptPubKeyMan.

Definition at line 2271 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ SetupDescriptorGeneration()

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

Setup descriptors based on the given CExtkey.

Definition at line 1966 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ SignMessage()

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 2155 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ SignTransaction()

bool DescriptorScriptPubKeyMan::SignTransaction ( CMutableTransaction tx,
const std::map< COutPoint, Coin > &  coins,
SigHashType  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 2137 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ TopUp()

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 1792 of file scriptpubkeyman.cpp.

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

◆ UpdateWalletDescriptor()

void DescriptorScriptPubKeyMan::UpdateWalletDescriptor ( WalletDescriptor descriptor)

Definition at line 2363 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

◆ WriteDescriptor()

void DescriptorScriptPubKeyMan::WriteDescriptor ( )

Definition at line 2339 of file scriptpubkeyman.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ cs_desc_man

RecursiveMutex DescriptorScriptPubKeyMan::cs_desc_man
mutable

Definition at line 703 of file scriptpubkeyman.h.

◆ m_decryption_thoroughly_checked

bool DescriptorScriptPubKeyMan::m_decryption_thoroughly_checked = false
private

keeps track of whether Unlock has run a thorough check before

Definition at line 673 of file scriptpubkeyman.h.

◆ m_internal

bool DescriptorScriptPubKeyMan::m_internal = false
private

Definition at line 667 of file scriptpubkeyman.h.

◆ m_max_cached_index

int32_t DescriptorScriptPubKeyMan::m_max_cached_index = -1
private

Definition at line 665 of file scriptpubkeyman.h.


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