Bitcoin ABC 0.30.5
P2P Digital Currency
Public Member Functions | Public Attributes | Protected Attributes | List of all members
ScriptPubKeyMan Class Reference

A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet. More...

#include <scriptpubkeyman.h>

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

Public Member Functions

 ScriptPubKeyMan (WalletStorage &storage)
 
virtual ~ScriptPubKeyMan ()
 
virtual bool GetNewDestination (const OutputType type, CTxDestination &dest, std::string &error)
 
virtual isminetype IsMine (const CScript &script) const
 
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. More...
 
virtual bool Encrypt (const CKeyingMaterial &master_key, WalletBatch *batch)
 
virtual bool GetReservedDestination (const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool)
 
virtual void KeepDestination (int64_t index, const OutputType &type)
 
virtual void ReturnDestination (int64_t index, bool internal, const CTxDestination &addr)
 
virtual bool TopUp (unsigned int size=0)
 Fills internal address pool. More...
 
virtual void MarkUnusedAddresses (const CScript &script)
 Mark unused addresses as being used. More...
 
virtual bool SetupGeneration (bool force=false)
 Sets up the key generation stuff, i.e. More...
 
virtual bool IsHDEnabled () const
 
virtual bool CanGetAddresses (bool internal=false) const
 Returns true if the wallet can give out new addresses. More...
 
virtual bool Upgrade (int prev_version, bilingual_str &error)
 Upgrades the wallet to the specified version. More...
 
virtual bool HavePrivateKeys () const
 
virtual void RewriteDB ()
 The action to do when the DB needs rewrite. More...
 
virtual int64_t GetOldestKeyPoolTime () const
 
virtual size_t KeypoolCountExternalKeys () const
 
virtual unsigned int GetKeyPoolSize () const
 
virtual int64_t GetTimeFirstKey () const
 
virtual std::unique_ptr< CKeyMetadataGetMetadata (const CTxDestination &dest) const
 
virtual std::unique_ptr< SigningProviderGetSolvingProvider (const CScript &script) const
 
virtual bool CanProvide (const CScript &script, SignatureData &sigdata)
 Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that, combined with sigdata, can produce solving data. More...
 
virtual bool SignTransaction (CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, SigHashType sighash, std::map< int, std::string > &input_errors) const
 Creates new signatures and adds them to the transaction. More...
 
virtual SigningResult SignMessage (const std::string &message, const PKHash &pkhash, std::string &str_sig) const
 Sign a message with the given script. More...
 
virtual TransactionError FillPSBT (PartiallySignedTransaction &psbt, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=false) const
 Adds script and derivation path information to a PSBT, and optionally signs it. More...
 
virtual uint256 GetID () const
 
virtual void SetInternal (bool internal)
 
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

boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
 Watch-only address added. More...
 
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
 Keypool has new keys. More...
 

Protected Attributes

WalletStoragem_storage
 

Detailed Description

A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.

It contains the scripts and keys related to the scriptPubKeys it manages. A ScriptPubKeyMan will be able to give out scriptPubKeys to be used, as well as marking when a scriptPubKey has been used. It also handles when and how to store a scriptPubKey and its related scripts and keys, including encryption.

Definition at line 171 of file scriptpubkeyman.h.

Constructor & Destructor Documentation

◆ ScriptPubKeyMan()

ScriptPubKeyMan::ScriptPubKeyMan ( WalletStorage storage)
inlineexplicit

Definition at line 176 of file scriptpubkeyman.h.

◆ ~ScriptPubKeyMan()

virtual ScriptPubKeyMan::~ScriptPubKeyMan ( )
inlinevirtual

Definition at line 177 of file scriptpubkeyman.h.

Member Function Documentation

◆ CanGetAddresses()

virtual bool ScriptPubKeyMan::CanGetAddresses ( bool  internal = false) const
inlinevirtual

Returns true if the wallet can give out new addresses.

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

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 231 of file scriptpubkeyman.h.

◆ CanProvide()

virtual bool ScriptPubKeyMan::CanProvide ( const CScript script,
SignatureData sigdata 
)
inlinevirtual

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

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 265 of file scriptpubkeyman.h.

◆ CheckDecryptionKey()

virtual bool ScriptPubKeyMan::CheckDecryptionKey ( const CKeyingMaterial master_key,
bool  accept_no_keys = false 
)
inlinevirtual

Check that the given decryption key is valid for this ScriptPubKeyMan, i.e.

it decrypts all of the keys handled by it.

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 186 of file scriptpubkeyman.h.

◆ Encrypt()

virtual bool ScriptPubKeyMan::Encrypt ( const CKeyingMaterial master_key,
WalletBatch batch 
)
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 190 of file scriptpubkeyman.h.

◆ FillPSBT()

virtual TransactionError ScriptPubKeyMan::FillPSBT ( PartiallySignedTransaction psbt,
SigHashType  sighash_type = SigHashType().withForkId(),
bool  sign = true,
bool  bip32derivs = false 
) const
inlinevirtual

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

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 290 of file scriptpubkeyman.h.

◆ GetID()

virtual uint256 ScriptPubKeyMan::GetID ( ) const
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 296 of file scriptpubkeyman.h.

◆ GetKeyPoolSize()

virtual unsigned int ScriptPubKeyMan::GetKeyPoolSize ( ) const
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 246 of file scriptpubkeyman.h.

◆ GetMetadata()

virtual std::unique_ptr< CKeyMetadata > ScriptPubKeyMan::GetMetadata ( const CTxDestination dest) const
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 251 of file scriptpubkeyman.h.

Here is the caller graph for this function:

◆ GetNewDestination()

virtual bool ScriptPubKeyMan::GetNewDestination ( const OutputType  type,
CTxDestination dest,
std::string &  error 
)
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 178 of file scriptpubkeyman.h.

◆ GetOldestKeyPoolTime()

virtual int64_t ScriptPubKeyMan::GetOldestKeyPoolTime ( ) const
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 243 of file scriptpubkeyman.h.

Here is the call graph for this function:

◆ GetReservedDestination()

virtual bool ScriptPubKeyMan::GetReservedDestination ( const OutputType  type,
bool  internal,
CTxDestination address,
int64_t &  index,
CKeyPool keypool 
)
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 195 of file scriptpubkeyman.h.

Here is the caller graph for this function:

◆ GetSolvingProvider()

virtual std::unique_ptr< SigningProvider > ScriptPubKeyMan::GetSolvingProvider ( const CScript script) const
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 256 of file scriptpubkeyman.h.

◆ GetTimeFirstKey()

virtual int64_t ScriptPubKeyMan::GetTimeFirstKey ( ) const
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 248 of file scriptpubkeyman.h.

◆ HavePrivateKeys()

virtual bool ScriptPubKeyMan::HavePrivateKeys ( ) const
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 238 of file scriptpubkeyman.h.

◆ IsHDEnabled()

virtual bool ScriptPubKeyMan::IsHDEnabled ( ) const
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 225 of file scriptpubkeyman.h.

◆ IsMine()

virtual isminetype ScriptPubKeyMan::IsMine ( const CScript script) const
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 182 of file scriptpubkeyman.h.

◆ KeepDestination()

virtual void ScriptPubKeyMan::KeepDestination ( int64_t  index,
const OutputType type 
)
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan.

Definition at line 200 of file scriptpubkeyman.h.

Here is the caller graph for this function:

◆ KeypoolCountExternalKeys()

virtual size_t ScriptPubKeyMan::KeypoolCountExternalKeys ( ) const
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 245 of file scriptpubkeyman.h.

◆ MarkUnusedAddresses()

virtual void ScriptPubKeyMan::MarkUnusedAddresses ( const CScript script)
inlinevirtual

Mark unused addresses as being used.

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 214 of file scriptpubkeyman.h.

◆ ReturnDestination()

virtual void ScriptPubKeyMan::ReturnDestination ( int64_t  index,
bool  internal,
const CTxDestination addr 
)
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 201 of file scriptpubkeyman.h.

Here is the caller graph for this function:

◆ RewriteDB()

virtual void ScriptPubKeyMan::RewriteDB ( )
inlinevirtual

The action to do when the DB needs rewrite.

Reimplemented in LegacyScriptPubKeyMan.

Definition at line 241 of file scriptpubkeyman.h.

◆ SetInternal()

virtual void ScriptPubKeyMan::SetInternal ( bool  internal)
inlinevirtual

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 298 of file scriptpubkeyman.h.

◆ SetupGeneration()

virtual bool ScriptPubKeyMan::SetupGeneration ( bool  force = false)
inlinevirtual

Sets up the key generation stuff, i.e.

generates new HD seeds and sets them as active. Returns false if already setup or setup fails, true if setup is successful Set force=true to make it re-setup if already setup, used for upgrades

Reimplemented in LegacyScriptPubKeyMan.

Definition at line 222 of file scriptpubkeyman.h.

◆ SignMessage()

virtual SigningResult ScriptPubKeyMan::SignMessage ( const std::string &  message,
const PKHash pkhash,
std::string &  str_sig 
) const
inlinevirtual

Sign a message with the given script.

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 280 of file scriptpubkeyman.h.

◆ SignTransaction()

virtual bool ScriptPubKeyMan::SignTransaction ( CMutableTransaction tx,
const std::map< COutPoint, Coin > &  coins,
SigHashType  sighash,
std::map< int, std::string > &  input_errors 
) const
inlinevirtual

Creates new signatures and adds them to the transaction.

Returns whether all inputs were signed

Reimplemented in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 274 of file scriptpubkeyman.h.

◆ TopUp()

virtual bool ScriptPubKeyMan::TopUp ( unsigned int  size = 0)
inlinevirtual

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 in LegacyScriptPubKeyMan, and DescriptorScriptPubKeyMan.

Definition at line 211 of file scriptpubkeyman.h.

Here is the caller graph for this function:

◆ Upgrade()

virtual bool ScriptPubKeyMan::Upgrade ( int  prev_version,
bilingual_str error 
)
inlinevirtual

Upgrades the wallet to the specified version.

Reimplemented in LegacyScriptPubKeyMan.

Definition at line 234 of file scriptpubkeyman.h.

◆ WalletLogPrintf()

template<typename... Params>
void ScriptPubKeyMan::WalletLogPrintf ( std::string  fmt,
Params...  parameters 
) const
inline

Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.

Definition at line 305 of file scriptpubkeyman.h.

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

Member Data Documentation

◆ m_storage

WalletStorage& ScriptPubKeyMan::m_storage
protected

Definition at line 173 of file scriptpubkeyman.h.

◆ NotifyCanGetAddressesChanged

boost::signals2::signal<void()> ScriptPubKeyMan::NotifyCanGetAddressesChanged

Keypool has new keys.

Definition at line 314 of file scriptpubkeyman.h.

◆ NotifyWatchonlyChanged

boost::signals2::signal<void(bool fHaveWatchOnly)> ScriptPubKeyMan::NotifyWatchonlyChanged

Watch-only address added.

Definition at line 311 of file scriptpubkeyman.h.


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