![]() |
Bitcoin Core 28.99.0
P2P Digital Currency
|
#include <scriptpubkeyman.h>
Public Member Functions | |
DescriptorScriptPubKeyMan (WalletStorage &storage, WalletDescriptor &descriptor, int64_t keypool_size) | |
DescriptorScriptPubKeyMan (WalletStorage &storage, int64_t keypool_size) | |
util::Result< CTxDestination > | GetNewDestination (const OutputType type) override |
isminetype | IsMine (const CScript &script) const override |
bool | CheckDecryptionKey (const CKeyingMaterial &master_key) 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 |
util::Result< CTxDestination > | GetReservedDestination (const OutputType type, bool internal, 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... | |
std::vector< WalletDestination > | MarkUnusedAddresses (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 (WalletBatch &batch, const CExtKey &master_key, OutputType addr_type, bool internal) |
Setup descriptors based on the given CExtkey. More... | |
bool | HavePrivateKeys () const override |
bool | HasPrivKey (const CKeyID &keyid) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man) |
std::optional< CKey > | GetKey (const CKeyID &keyid) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man) |
Retrieve the particular key if it is available. Returns nullopt if the key is not in the wallet, or if the wallet is locked. More... | |
bool | HaveCryptedKeys () const override |
std::optional< int64_t > | GetOldestKeyPoolTime () const override |
unsigned int | GetKeyPoolSize () const override |
int64_t | GetTimeFirstKey () const override |
std::unique_ptr< CKeyMetadata > | GetMetadata (const CTxDestination &dest) const override |
bool | CanGetAddresses (bool internal=false) const override |
std::unique_ptr< SigningProvider > | GetSolvingProvider (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... | |
std::unique_ptr< FlatSigningProvider > | GetSigningProvider (const CPubKey &pubkey) const |
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... | |
std::optional< common::PSBTError > | 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 () |
WalletDescriptor | GetWalletDescriptor () const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man) |
std::unordered_set< CScript, SaltedSipHasher > | GetScriptPubKeys () const override |
Returns a set of all the scriptPubKeys that this ScriptPubKeyMan watches. More... | |
std::unordered_set< CScript, SaltedSipHasher > | GetScriptPubKeys (int32_t minimum_index) const |
int32_t | GetEndRange () const |
bool | GetDescriptorString (std::string &out, const bool priv) const |
void | UpgradeDescriptorCache () |
![]() | |
ScriptPubKeyMan (WalletStorage &storage) | |
virtual | ~ScriptPubKeyMan ()=default |
virtual util::Result< CTxDestination > | GetNewDestination (const OutputType type) |
virtual isminetype | IsMine (const CScript &script) const |
virtual bool | CheckDecryptionKey (const CKeyingMaterial &master_key) |
Check that the given decryption key is valid for this ScriptPubKeyMan, i.e. it decrypts all of the keys handled by it. More... | |
virtual bool | Encrypt (const CKeyingMaterial &master_key, WalletBatch *batch) |
virtual util::Result< CTxDestination > | GetReservedDestination (const OutputType type, bool internal, 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 std::vector< WalletDestination > | MarkUnusedAddresses (const CScript &script) |
Mark unused addresses as being used Affects all keys up to and including the one determined by provided script. 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 |
virtual bool | Upgrade (int prev_version, int new_version, bilingual_str &error) |
Upgrades the wallet to the specified version. More... | |
virtual bool | HavePrivateKeys () const |
virtual bool | HaveCryptedKeys () const |
virtual void | RewriteDB () |
The action to do when the DB needs rewrite. More... | |
virtual std::optional< int64_t > | GetOldestKeyPoolTime () const |
virtual unsigned int | GetKeyPoolSize () const |
virtual int64_t | GetTimeFirstKey () const |
virtual std::unique_ptr< CKeyMetadata > | GetMetadata (const CTxDestination &dest) const |
virtual std::unique_ptr< SigningProvider > | GetSolvingProvider (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, int sighash, std::map< int, bilingual_str > &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 std::optional< common::PSBTError > | 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 |
Adds script and derivation path information to a PSBT, and optionally signs it. More... | |
virtual uint256 | GetID () const |
virtual std::unordered_set< CScript, SaltedSipHasher > | GetScriptPubKeys () const |
Returns a set of all the scriptPubKeys that this ScriptPubKeyMan watches. More... | |
template<typename... Params> | |
void | WalletLogPrintf (util::ConstevalFormatString< sizeof...(Params)> wallet_fmt, const Params &... params) const |
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases. More... | |
Public Attributes | |
RecursiveMutex | cs_desc_man |
![]() | |
boost::signals2::signal< void(bool fHaveWatchOnly)> | NotifyWatchonlyChanged |
Watch-only address added. More... | |
boost::signals2::signal< void()> | NotifyCanGetAddressesChanged |
Keypool has new keys. More... | |
boost::signals2::signal< void(const ScriptPubKeyMan *spkm, int64_t new_birth_time)> | NotifyFirstKeyTimeChanged |
Birth time changed. More... | |
Protected Member Functions | |
WalletDescriptor m_wallet_descriptor | GUARDED_BY (cs_desc_man) |
bool | TopUpWithDB (WalletBatch &batch, unsigned int size=0) |
Same as 'TopUp' but designed for use within a batch transaction context. 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 | |
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) |
int64_t m_keypool_size | GUARDED_BY (cs_desc_man) |
Number of pre-generated keys/scripts (part of the look-ahead process, used to detect payments) More... | |
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 (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... | |
std::map< int32_t, FlatSigningProvider > | m_map_signing_providers |
Friends | |
class | LegacyDataSPKM |
Additional Inherited Members | |
![]() | |
WalletStorage & | m_storage |
Definition at line 589 of file scriptpubkeyman.h.
|
private |
Definition at line 595 of file scriptpubkeyman.h.
|
private |
Definition at line 596 of file scriptpubkeyman.h.
|
private |
Definition at line 594 of file scriptpubkeyman.h.
|
private |
Definition at line 593 of file scriptpubkeyman.h.
|
inline |
Definition at line 629 of file scriptpubkeyman.h.
|
inline |
Definition at line 634 of file scriptpubkeyman.h.
bool wallet::DescriptorScriptPubKeyMan::AddCryptedKey | ( | const CKeyID & | key_id, |
const CPubKey & | pubkey, | ||
const std::vector< unsigned char > & | crypted_key | ||
) |
Definition at line 2731 of file scriptpubkeyman.cpp.
|
private |
Definition at line 2359 of file scriptpubkeyman.cpp.
Definition at line 2724 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2424 of file scriptpubkeyman.cpp.
|
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 2531 of file scriptpubkeyman.cpp.
bool wallet::DescriptorScriptPubKeyMan::CanUpdateToWalletDescriptor | ( | const WalletDescriptor & | descriptor, |
std::string & | error | ||
) |
Definition at line 2846 of file scriptpubkeyman.cpp.
|
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 2125 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2157 of file scriptpubkeyman.cpp.
|
overridevirtual |
Adds script and derivation path information to a PSBT, and optionally signs it.
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2568 of file scriptpubkeyman.cpp.
bool wallet::DescriptorScriptPubKeyMan::GetDescriptorString | ( | std::string & | out, |
const bool | priv | ||
) | const |
Definition at line 2784 of file scriptpubkeyman.cpp.
int32_t wallet::DescriptorScriptPubKeyMan::GetEndRange | ( | ) | const |
Definition at line 2779 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2684 of file scriptpubkeyman.cpp.
Retrieve the particular key if it is available. Returns nullopt if the key is not in the wallet, or if the wallet is locked.
Definition at line 2224 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2453 of file scriptpubkeyman.cpp.
Definition at line 2199 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2666 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2077 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2446 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2180 of file scriptpubkeyman.cpp.
|
overridevirtual |
Returns a set of all the scriptPubKeys that this ScriptPubKeyMan watches.
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2762 of file scriptpubkeyman.cpp.
std::unordered_set< CScript, SaltedSipHasher > wallet::DescriptorScriptPubKeyMan::GetScriptPubKeys | ( | int32_t | minimum_index | ) | const |
Definition at line 2767 of file scriptpubkeyman.cpp.
std::unique_ptr< FlatSigningProvider > wallet::DescriptorScriptPubKeyMan::GetSigningProvider | ( | const CPubKey & | pubkey | ) | const |
|
private |
Definition at line 2465 of file scriptpubkeyman.cpp.
|
private |
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2526 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2459 of file scriptpubkeyman.cpp.
WalletDescriptor wallet::DescriptorScriptPubKeyMan::GetWalletDescriptor | ( | ) | const |
|
private |
|
private |
|
private |
|
private |
|
inlineprivate |
Number of pre-generated keys/scripts (part of the look-ahead process, used to detect payments)
Definition at line 609 of file scriptpubkeyman.h.
|
protected |
bool wallet::DescriptorScriptPubKeyMan::HasPrivKey | ( | const CKeyID & | keyid | ) | const |
bool wallet::DescriptorScriptPubKeyMan::HasWalletDescriptor | ( | const WalletDescriptor & | desc | ) | const |
Definition at line 2742 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2440 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2434 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2418 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2116 of file scriptpubkeyman.cpp.
|
overridevirtual |
Mark unused addresses as being used Affects all keys up to and including the one determined by provided script.
script | determines the last key to mark as used |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2322 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2188 of file scriptpubkeyman.cpp.
void wallet::DescriptorScriptPubKeyMan::SetCache | ( | const DescriptorCache & | cache | ) |
bool wallet::DescriptorScriptPubKeyMan::SetupDescriptorGeneration | ( | WalletBatch & | batch, |
const CExtKey & | master_key, | ||
OutputType | addr_type, | ||
bool | internal | ||
) |
Setup descriptors based on the given CExtkey.
Definition at line 2391 of file scriptpubkeyman.cpp.
|
overridevirtual |
Sign a message with the given script.
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2550 of file scriptpubkeyman.cpp.
|
overridevirtual |
Creates new signatures and adds them to the transaction.
Returns whether all inputs were signed
Reimplemented from wallet::ScriptPubKeyMan.
Definition at line 2536 of file scriptpubkeyman.cpp.
|
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 2248 of file scriptpubkeyman.cpp.
|
protected |
Same as 'TopUp' but designed for use within a batch transaction context.
Definition at line 2257 of file scriptpubkeyman.cpp.
void wallet::DescriptorScriptPubKeyMan::UpdateWalletDescriptor | ( | WalletDescriptor & | descriptor | ) |
void wallet::DescriptorScriptPubKeyMan::UpgradeDescriptorCache | ( | ) |
Definition at line 2801 of file scriptpubkeyman.cpp.
void wallet::DescriptorScriptPubKeyMan::WriteDescriptor | ( | ) |
|
friend |
Definition at line 591 of file scriptpubkeyman.h.
|
mutable |
Definition at line 639 of file scriptpubkeyman.h.
|
private |
keeps track of whether Unlock has run a thorough check before
Definition at line 606 of file scriptpubkeyman.h.
|
mutableprivate |
Definition at line 616 of file scriptpubkeyman.h.
|
private |
Definition at line 600 of file scriptpubkeyman.h.