Bitcoin ABC 0.26.3
P2P Digital Currency
|
#include <scriptpubkeyman.h>
Public Member Functions | |
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 | KeepDestination (int64_t index, const OutputType &type) override |
void | ReturnDestination (int64_t index, bool internal, const CTxDestination &) override |
bool | TopUp (unsigned int size=0) override |
Fills internal address pool. | |
void | MarkUnusedAddresses (const CScript &script) override |
Mark unused addresses as being used. | |
void | UpgradeKeyMetadata () |
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo. | |
bool | IsHDEnabled () const override |
bool | SetupGeneration (bool force=false) override |
Sets up the key generation stuff, i.e. | |
bool | Upgrade (int prev_version, bilingual_str &error) override |
Upgrades the wallet to the specified version. | |
bool | HavePrivateKeys () const override |
void | RewriteDB () override |
The action to do when the DB needs rewrite. | |
int64_t | GetOldestKeyPoolTime () const override |
size_t | KeypoolCountExternalKeys () 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 |
Returns true if the wallet can give out new addresses. | |
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. | |
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 |
std::map< CKeyID, CKeyMetadata > mapKeyMetadata | GUARDED_BY (cs_KeyStore) |
std::map< CScriptID, CKeyMetadata > m_script_metadata | GUARDED_BY (cs_KeyStore) |
bool | AddKeyPubKey (const CKey &key, const CPubKey &pubkey) override |
Adds a key to the store, and saves it to disk. | |
bool | LoadKey (const CKey &key, const CPubKey &pubkey) |
Adds a key to the store, without saving it to disk (used by LoadWallet) | |
bool | AddCryptedKey (const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret) |
Adds an encrypted key to the store, and saves it to disk. | |
bool | LoadCryptedKey (const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret, bool checksum_valid) |
Adds an encrypted key to the store, without saving it to disk (used by LoadWallet) | |
void | UpdateTimeFirstKey (int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore) |
Update wallet first key creation time. | |
bool | LoadCScript (const CScript &redeemScript) |
Adds a CScript to the store. | |
void | LoadKeyMetadata (const CKeyID &keyID, const CKeyMetadata &metadata) |
Load metadata (used by LoadWallet) | |
void | LoadScriptMetadata (const CScriptID &script_id, const CKeyMetadata &metadata) |
CPubKey | GenerateNewKey (WalletBatch &batch, CHDChain &hd_chain, bool internal=false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore) |
Generate a new key. | |
void | AddHDChain (const CHDChain &chain) |
Set the HD chain model (chain child index counters) and writes it to the database. | |
void | LoadHDChain (const CHDChain &chain) |
Load a HD chain model (used by LoadWallet) | |
const CHDChain & | GetHDChain () const |
void | AddInactiveHDChain (const CHDChain &chain) |
bool | LoadWatchOnly (const CScript &dest) |
Adds a watch-only address to the store, without saving it to disk (used by LoadWallet) | |
bool | HaveWatchOnly (const CScript &dest) const |
Returns whether the watch-only script is in the wallet. | |
bool | HaveWatchOnly () const |
Returns whether there are any watch-only things in the wallet. | |
bool | RemoveWatchOnly (const CScript &dest) |
Remove a watch only script from the keystore. | |
bool | AddWatchOnly (const CScript &dest, int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore) |
bool | GetWatchPubKey (const CKeyID &address, CPubKey &pubkey_out) const |
Fetches a pubkey from mapWatchKeys if it exists there. | |
bool | HaveKey (const CKeyID &address) const override |
bool | GetKey (const CKeyID &address, CKey &keyOut) const override |
bool | GetPubKey (const CKeyID &address, CPubKey &vchPubKeyOut) const override |
bool | AddCScript (const CScript &redeemScript) override |
bool | GetKeyOrigin (const CKeyID &keyid, KeyOriginInfo &info) const override |
void | LoadKeyPool (int64_t nIndex, const CKeyPool &keypool) |
Load a keypool entry. | |
bool | NewKeyPool () |
Mark old keypool keys as used, and generate all new keys. | |
void | MarkPreSplitKeys () EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore) |
bool | ImportScripts (const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore) |
bool | ImportPrivKeys (const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore) |
bool | ImportPubKeys (const std::vector< CKeyID > &ordered_pubkeys, const std::map< CKeyID, CPubKey > &pubkey_map, const std::map< CKeyID, std::pair< CPubKey, KeyOriginInfo > > &key_origins, const bool add_keypool, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore) |
bool | ImportScriptPubKeys (const std::set< CScript > &script_pub_keys, const bool have_solving_data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore) |
bool | CanGenerateKeys () const |
CPubKey | GenerateNewSeed () |
CPubKey | DeriveNewSeed (const CKey &key) |
void | SetHDSeed (const CPubKey &key) |
void | LearnRelatedScripts (const CPubKey &key, OutputType) |
Explicitly make the wallet learn the related scripts for outputs to the given key. | |
void | LearnAllRelatedScripts (const CPubKey &key) |
Same as LearnRelatedScripts, but when the OutputType is not known (and could be anything). | |
void | MarkReserveKeysAsUsed (int64_t keypool_id) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore) |
Marks all keys in the keypool up to and including reserve_key as used. | |
const std::map< CKeyID, int64_t > & | GetAllReserveKeys () const |
std::set< CKeyID > | GetKeys () const override |
ScriptPubKeyMan (WalletStorage &storage) | |
Public Member Functions inherited from ScriptPubKeyMan | |
ScriptPubKeyMan (WalletStorage &storage) | |
virtual | ~ScriptPubKeyMan () |
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 Member Functions inherited from FillableSigningProvider | |
virtual bool | AddKey (const CKey &key) |
virtual bool | HaveCScript (const CScriptID &hash) const override |
virtual std::set< CScriptID > | GetCScripts () const |
virtual bool | GetCScript (const CScriptID &hash, CScript &redeemScriptOut) const override |
Public Member Functions inherited from SigningProvider | |
virtual | ~SigningProvider () |
Private Types | |
using | WatchOnlySet = std::set< CScript > |
using | WatchKeyMap = std::map< CKeyID, CPubKey > |
using | CryptedKeyMap = std::map< CKeyID, std::pair< CPubKey, std::vector< uint8_t > > > |
Private Attributes | |
bool | fDecryptionThoroughlyChecked = true |
keeps track of whether Unlock has run a thorough check before | |
CHDChain | m_hd_chain |
std::unordered_map< CKeyID, CHDChain, SaltedSipHasher > | m_inactive_hd_chains |
std::map< CKeyID, int64_t > | m_pool_key_to_index |
std::map< int64_t, CKeyID > | m_index_to_reserved_key |
Additional Inherited Members | |
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. | |
Public Attributes inherited from FillableSigningProvider | |
RecursiveMutex | cs_KeyStore |
Protected Types inherited from FillableSigningProvider | |
using | KeyMap = std::map< CKeyID, CKey > |
using | ScriptMap = std::map< CScriptID, CScript > |
Protected Member Functions inherited from FillableSigningProvider | |
KeyMap mapKeys | GUARDED_BY (cs_KeyStore) |
Map of key id to unencrypted private keys known by the signing provider. | |
ScriptMap mapScripts | GUARDED_BY (cs_KeyStore) |
(This comment has been elided for clarity since most of it detailed Core SegWit implementation details, see Core commit 005f8a9) | |
Protected Attributes inherited from ScriptPubKeyMan | |
WalletStorage & | m_storage |
Definition at line 317 of file scriptpubkeyman.h.
|
private |
Definition at line 328 of file scriptpubkeyman.h.
|
private |
Definition at line 324 of file scriptpubkeyman.h.
|
private |
Definition at line 323 of file scriptpubkeyman.h.
bool LegacyScriptPubKeyMan::AddCryptedKey | ( | const CPubKey & | vchPubKey, |
const std::vector< uint8_t > & | vchCryptedSecret | ||
) |
Adds an encrypted key to the store, and saves it to disk.
Definition at line 787 of file scriptpubkeyman.cpp.
|
private |
Definition at line 778 of file scriptpubkeyman.cpp.
Reimplemented from FillableSigningProvider.
Definition at line 1488 of file scriptpubkeyman.cpp.
|
private |
Adds a script to the store and saves it to disk.
Definition at line 1493 of file scriptpubkeyman.cpp.
Set the HD chain model (chain child index counters) and writes it to the database.
Definition at line 890 of file scriptpubkeyman.cpp.
Definition at line 906 of file scriptpubkeyman.cpp.
|
private |
Add a KeyOriginInfo to the wallet.
Definition at line 1505 of file scriptpubkeyman.cpp.
|
private |
Definition at line 1278 of file scriptpubkeyman.cpp.
|
overridevirtual |
Adds a key to the store, and saves it to disk.
Reimplemented from FillableSigningProvider.
Definition at line 653 of file scriptpubkeyman.cpp.
Definition at line 740 of file scriptpubkeyman.cpp.
|
private |
Adds a key to the store, and saves it to disk.
Definition at line 660 of file scriptpubkeyman.cpp.
Private version of AddWatchOnly method which does not accept a timestamp, and which will reset the wallet's nTimeFirstKey value to 1 if the watch key did not previously have a timestamp associated with it.
Because this is an inherited virtual method, it is accessible despite being marked private, but it is marked private anyway to encourage use of the other AddWatchOnly which accepts a timestamp and sets nTimeFirstKey more intelligently for more efficient rescans.
Definition at line 874 of file scriptpubkeyman.cpp.
Definition at line 841 of file scriptpubkeyman.cpp.
|
private |
Definition at line 851 of file scriptpubkeyman.cpp.
|
private |
Adds a watch-only address to the store, and saves it to disk.
Definition at line 867 of file scriptpubkeyman.cpp.
bool LegacyScriptPubKeyMan::CanGenerateKeys | ( | ) | const |
Definition at line 1131 of file scriptpubkeyman.cpp.
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 404 of file scriptpubkeyman.cpp.
|
overridevirtual |
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that, combined with sigdata, can produce solving data.
Reimplemented from ScriptPubKeyMan.
Definition at line 526 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 ScriptPubKeyMan.
Definition at line 172 of file scriptpubkeyman.cpp.
|
private |
Definition at line 1034 of file scriptpubkeyman.cpp.
Definition at line 1145 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 215 of file scriptpubkeyman.cpp.
|
overridevirtual |
Adds script and derivation path information to a PSBT, and optionally signs it.
Reimplemented from ScriptPubKeyMan.
Definition at line 573 of file scriptpubkeyman.cpp.
CPubKey LegacyScriptPubKeyMan::GenerateNewKey | ( | WalletBatch & | batch, |
CHDChain & | hd_chain, | ||
bool | internal = false |
||
) |
Generate a new key.
Definition at line 991 of file scriptpubkeyman.cpp.
CPubKey LegacyScriptPubKeyMan::GenerateNewSeed | ( | ) |
Definition at line 1138 of file scriptpubkeyman.cpp.
Definition at line 617 of file scriptpubkeyman.h.
|
inline |
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 630 of file scriptpubkeyman.cpp.
Reimplemented from FillableSigningProvider.
Definition at line 920 of file scriptpubkeyman.cpp.
|
private |
Fetches a key from the keypool.
Definition at line 1331 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from SigningProvider.
Definition at line 939 of file scriptpubkeyman.cpp.
Reimplemented from ScriptPubKeyMan.
Definition at line 510 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from FillableSigningProvider.
Definition at line 1618 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 610 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 23 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 485 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from FillableSigningProvider.
Definition at line 971 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 246 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 522 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 516 of file scriptpubkeyman.cpp.
Fetches a pubkey from mapWatchKeys if it exists there.
Definition at line 960 of file scriptpubkeyman.cpp.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
std::map< CKeyID, CKeyMetadata > mapKeyMetadata LegacyScriptPubKeyMan::GUARDED_BY | ( | cs_KeyStore | ) |
std::map< CScriptID, CKeyMetadata > m_script_metadata LegacyScriptPubKeyMan::GUARDED_BY | ( | cs_KeyStore | ) |
|
privatepure virtual |
|
privatepure virtual |
Reimplemented from FillableSigningProvider.
Definition at line 912 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 453 of file scriptpubkeyman.cpp.
bool LegacyScriptPubKeyMan::HaveWatchOnly | ( | ) | const |
Returns whether there are any watch-only things in the wallet.
Definition at line 809 of file scriptpubkeyman.cpp.
Returns whether the watch-only script is in the wallet.
Definition at line 804 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 400 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 159 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 1297 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 505 of file scriptpubkeyman.cpp.
Same as LearnRelatedScripts, but when the OutputType is not known (and could be anything).
Definition at line 1417 of file scriptpubkeyman.cpp.
void LegacyScriptPubKeyMan::LearnRelatedScripts | ( | const CPubKey & | key, |
OutputType | type | ||
) |
Explicitly make the wallet learn the related scripts for outputs to the given key.
This is purely to make the wallet file compatible with older software, as FillableSigningProvider automatically does this implicitly for all keys now.
Definition at line 1412 of file scriptpubkeyman.cpp.
bool LegacyScriptPubKeyMan::LoadCryptedKey | ( | const CPubKey & | vchPubKey, |
const std::vector< uint8_t > & | vchCryptedSecret, | ||
bool | checksum_valid | ||
) |
Adds an encrypted key to the store, without saving it to disk (used by LoadWallet)
Definition at line 767 of file scriptpubkeyman.cpp.
Adds a CScript to the store.
A sanity check was added in pull #3843 to avoid adding redeemScripts that never can be redeemed. However, old wallets may still contain these. Do not add them to the wallet and warn.
Definition at line 706 of file scriptpubkeyman.cpp.
Load a HD chain model (used by LoadWallet)
Definition at line 885 of file scriptpubkeyman.cpp.
Adds a key to the store, without saving it to disk (used by LoadWallet)
Definition at line 649 of file scriptpubkeyman.cpp.
void LegacyScriptPubKeyMan::LoadKeyMetadata | ( | const CKeyID & | keyID, |
const CKeyMetadata & | metadata | ||
) |
Load metadata (used by LoadWallet)
Definition at line 726 of file scriptpubkeyman.cpp.
Load a keypool entry.
Definition at line 1109 of file scriptpubkeyman.cpp.
void LegacyScriptPubKeyMan::LoadScriptMetadata | ( | const CScriptID & | script_id, |
const CKeyMetadata & | metadata | ||
) |
Definition at line 733 of file scriptpubkeyman.cpp.
Adds a watch-only address to the store, without saving it to disk (used by LoadWallet)
Definition at line 837 of file scriptpubkeyman.cpp.
void LegacyScriptPubKeyMan::MarkPreSplitKeys | ( | ) |
Definition at line 1468 of file scriptpubkeyman.cpp.
Marks all keys in the keypool up to and including reserve_key as used.
Definition at line 1421 of file scriptpubkeyman.cpp.
Mark unused addresses as being used.
Reimplemented from ScriptPubKeyMan.
Definition at line 308 of file scriptpubkeyman.cpp.
bool LegacyScriptPubKeyMan::NewKeyPool | ( | ) |
Mark old keypool keys as used, and generate all new keys.
Definition at line 1191 of file scriptpubkeyman.cpp.
Remove a watch only script from the keystore.
Definition at line 820 of file scriptpubkeyman.cpp.
|
private |
Reserves a key from the keypool and sets nIndex to its index.
[out] | nIndex | the index of the key in keypool |
[out] | keypool | the keypool the key was drawn from, which could be the the pre-split pool if present, or the internal or external pool |
fRequestedInternal | true if the caller would like the key drawn from the internal keypool, false if external is preferred |
std::runtime_error | if keypool read failed, key was invalid, was not found in the wallet, or was misclassified in the internal or external keypool |
Definition at line 1357 of file scriptpubkeyman.cpp.
|
overridevirtual |
Reimplemented from ScriptPubKeyMan.
Definition at line 1310 of file scriptpubkeyman.cpp.
|
overridevirtual |
The action to do when the DB needs rewrite.
Reimplemented from ScriptPubKeyMan.
Definition at line 458 of file scriptpubkeyman.cpp.
|
inlineexplicit |
Definition at line 176 of file scriptpubkeyman.h.
Definition at line 1172 of file scriptpubkeyman.cpp.
Reimplemented from ScriptPubKeyMan.
Definition at line 1630 of file scriptpubkeyman.cpp.
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 from ScriptPubKeyMan.
Definition at line 388 of file scriptpubkeyman.cpp.
|
overridevirtual |
Sign a message with the given script.
Reimplemented from ScriptPubKeyMan.
Definition at line 558 of file scriptpubkeyman.cpp.
|
overridevirtual |
Creates new signatures and adds them to the transaction.
Returns whether all inputs were signed
Reimplemented from ScriptPubKeyMan.
Definition at line 552 of file scriptpubkeyman.cpp.
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 1223 of file scriptpubkeyman.cpp.
|
private |
Like TopUp() but adds keys for inactive HD chains.
Ensures that there are at least -keypool number of keys derived after the given index.
seed_id | the CKeyID for the HD seed. |
index | the index to start generating keys from |
internal | whether the internal chain should be used. true for internal chain, false for external chain. |
Definition at line 263 of file scriptpubkeyman.cpp.
Update wallet first key creation time.
This should be called whenever keys are added to the wallet, with the oldest key creation time.
Definition at line 638 of file scriptpubkeyman.cpp.
|
overridevirtual |
Upgrades the wallet to the specified version.
Reimplemented from ScriptPubKeyMan.
Definition at line 420 of file scriptpubkeyman.cpp.
void LegacyScriptPubKeyMan::UpgradeKeyMetadata | ( | ) |
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
Definition at line 349 of file scriptpubkeyman.cpp.
keeps track of whether Unlock has run a thorough check before
Definition at line 321 of file scriptpubkeyman.h.
|
private |
Definition at line 376 of file scriptpubkeyman.h.
|
private |
Definition at line 377 of file scriptpubkeyman.h.
Definition at line 392 of file scriptpubkeyman.h.
Definition at line 389 of file scriptpubkeyman.h.