![]() |
PIVX Core
5.6.99
P2P Digital Currency
|
#include <scriptpubkeyman.h>
Public Member Functions | |
| ScriptPubKeyMan (CWallet *parent) | |
| ~ScriptPubKeyMan () | |
| void | SetHDChain (CHDChain &chain, bool memonly) |
| const CHDChain & | GetHDChain () const |
| bool | SetupGeneration (bool newKeypool=true, bool force=false, bool memOnly=false) |
| Sets up the key generation stuff, i.e. More... | |
| bool | Upgrade (const int prev_version, std::string &error) |
| Upgrades the wallet to the specified version. More... | |
| bool | CanGenerateKeys () |
| bool | IsHDEnabled () const |
| int64_t | GetOldestKeyPoolTime () |
| size_t | KeypoolCountExternalKeys () |
| unsigned int | GetKeyPoolSize () const |
| unsigned int | GetStakingKeyPoolSize () const |
| bool | CanGetAddresses (const uint8_t &type=HDChain::ChangeType::EXTERNAL) |
| CPubKey | GenerateNewSeed () |
| CPubKey | DeriveNewSeed (const CKey &key) |
| void | SetHDSeed (const CPubKey &key, bool force=false, bool memOnly=false) |
| void | LoadKeyPool (int64_t nIndex, const CKeyPool &keypool) |
| Load a keypool entry. More... | |
| bool | NewKeyPool () |
| Key pool. More... | |
| void | MarkPreSplitKeys () |
| Update pre HD keys in db with the pre-split flag enabled. More... | |
| bool | TopUp (unsigned int size=0) |
| Fills internal address pool. More... | |
| void | MarkUnusedAddresses (const CScript &script) |
| Mark unused addresses as being used. More... | |
| void | UpdateTimeFirstKey (int64_t nCreateTime) |
| First wallet key time. More... | |
| CPubKey | GenerateNewKey (WalletBatch &batch, const uint8_t &type=HDChain::ChangeType::EXTERNAL) |
| Generate a new key. More... | |
| bool | GetKeyFromPool (CPubKey &key, const uint8_t &changeType=HDChain::ChangeType::EXTERNAL) |
| Fetches a key from the keypool. More... | |
| bool | GetReservedKey (const uint8_t &changeType, int64_t &index, CKeyPool &keypool) |
| Reserve + fetch a key from the keypool. More... | |
| const std::map< CKeyID, int64_t > & | GetAllReserveKeys () const |
| bool | ReserveKeyFromKeyPool (int64_t &nIndex, CKeyPool &keypool, const uint8_t &type=HDChain::ChangeType::EXTERNAL) |
| Reserves a key from the keypool and sets nIndex to its index. More... | |
| void | KeepDestination (int64_t index) |
| void | ReturnDestination (int64_t index, const uint8_t &type, const CTxDestination &) |
Public Attributes | |
| std::set< int64_t > | set_pre_split_keypool |
Private Member Functions | |
| bool | AddKeyPubKeyInner (const CKey &key, const CPubKey &pubkey) |
| bool | AddKeyPubKeyWithDB (WalletBatch &batch, const CKey &key, const CPubKey &pubkey) |
| Adds a key to the store, and saves it to disk. More... | |
| void | AddKeypoolPubkeyWithDB (const CPubKey &pubkey, const uint8_t &type, WalletBatch &batch) |
| void | GeneratePool (WalletBatch &batch, int64_t targetSize, const uint8_t &type) |
| void | DeriveNewChildKey (WalletBatch &batch, CKeyMetadata &metadata, CKey &secret, const uint8_t &type=HDChain::ChangeType::EXTERNAL) |
| void | MarkReserveKeysAsUsed (int64_t keypool_id) |
| Marks all keys in the keypool up to and including reserve_key as used. More... | |
Private Attributes | |
| CWallet * | wallet {nullptr} |
| CHDChain | hdChain |
| WalletBatch * | encrypted_batch = nullptr |
| std::set< int64_t > | setInternalKeyPool |
| std::set< int64_t > | setExternalKeyPool |
| std::set< int64_t > | setStakingKeyPool |
| int64_t | m_max_keypool_index = 0 |
| std::map< CKeyID, int64_t > | m_pool_key_to_index |
| std::map< int64_t, CKeyID > | m_index_to_reserved_key |
Definition at line 24 of file scriptpubkeyman.h.
|
inlineexplicit |
Definition at line 27 of file scriptpubkeyman.h.
|
inline |
Definition at line 28 of file scriptpubkeyman.h.
|
private |
Definition at line 421 of file scriptpubkeyman.cpp.
Definition at line 602 of file scriptpubkeyman.cpp.
|
private |
Adds a key to the store, and saves it to disk.
Definition at line 580 of file scriptpubkeyman.cpp.
| bool ScriptPubKeyMan::CanGenerateKeys | ( | ) |
Definition at line 52 of file scriptpubkeyman.cpp.
| bool ScriptPubKeyMan::CanGetAddresses | ( | const uint8_t & | type = HDChain::ChangeType::EXTERNAL | ) |
Definition at line 64 of file scriptpubkeyman.cpp.
|
private |
Definition at line 480 of file scriptpubkeyman.cpp.
Definition at line 634 of file scriptpubkeyman.cpp.
| CPubKey ScriptPubKeyMan::GenerateNewKey | ( | WalletBatch & | batch, |
| const uint8_t & | type = HDChain::ChangeType::EXTERNAL |
||
| ) |
Generate a new key.
Generate a new key and stores it in db.
Definition at line 445 of file scriptpubkeyman.cpp.
| CPubKey ScriptPubKeyMan::GenerateNewSeed | ( | ) |
Definition at line 627 of file scriptpubkeyman.cpp.
|
private |
|
inline |
|
inline |
| bool ScriptPubKeyMan::GetKeyFromPool | ( | CPubKey & | key, |
| const uint8_t & | changeType = HDChain::ChangeType::EXTERNAL |
||
| ) |
Fetches a key from the keypool.
Definition at line 135 of file scriptpubkeyman.cpp.
| unsigned int ScriptPubKeyMan::GetKeyPoolSize | ( | ) | const |
Definition at line 123 of file scriptpubkeyman.cpp.
| int64_t ScriptPubKeyMan::GetOldestKeyPoolTime | ( | ) |
| bool ScriptPubKeyMan::GetReservedKey | ( | const uint8_t & | changeType, |
| int64_t & | index, | ||
| CKeyPool & | keypool | ||
| ) |
Reserve + fetch a key from the keypool.
Definition at line 161 of file scriptpubkeyman.cpp.
| unsigned int ScriptPubKeyMan::GetStakingKeyPoolSize | ( | ) | const |
Definition at line 129 of file scriptpubkeyman.cpp.
| bool ScriptPubKeyMan::IsHDEnabled | ( | ) | const |
Definition at line 59 of file scriptpubkeyman.cpp.
| void ScriptPubKeyMan::KeepDestination | ( | int64_t | index | ) |
| size_t ScriptPubKeyMan::KeypoolCountExternalKeys | ( | ) |
| void ScriptPubKeyMan::LoadKeyPool | ( | int64_t | nIndex, |
| const CKeyPool & | keypool | ||
| ) |
Load a keypool entry.
Definition at line 539 of file scriptpubkeyman.cpp.
| void ScriptPubKeyMan::MarkPreSplitKeys | ( | ) |
Update pre HD keys in db with the pre-split flag enabled.
Definition at line 308 of file scriptpubkeyman.cpp.
|
private |
Marks all keys in the keypool up to and including reserve_key as used.
Definition at line 260 of file scriptpubkeyman.cpp.
| void ScriptPubKeyMan::MarkUnusedAddresses | ( | const CScript & | script | ) |
Mark unused addresses as being used.
Definition at line 291 of file scriptpubkeyman.cpp.
| bool ScriptPubKeyMan::NewKeyPool | ( | ) |
Key pool.
Mark old keypool keys as used, and generate all new keys.
Definition at line 330 of file scriptpubkeyman.cpp.
| bool ScriptPubKeyMan::ReserveKeyFromKeyPool | ( | int64_t & | nIndex, |
| CKeyPool & | keypool, | ||
| const uint8_t & | type = HDChain::ChangeType::EXTERNAL |
||
| ) |
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 172 of file scriptpubkeyman.cpp.
| void ScriptPubKeyMan::ReturnDestination | ( | int64_t | index, |
| const uint8_t & | type, | ||
| const CTxDestination & | |||
| ) |
| void ScriptPubKeyMan::SetHDChain | ( | CHDChain & | chain, |
| bool | memonly | ||
| ) |
Definition at line 682 of file scriptpubkeyman.cpp.
Definition at line 663 of file scriptpubkeyman.cpp.
| bool ScriptPubKeyMan::SetupGeneration | ( | bool | newKeypool = true, |
| bool | force = false, |
||
| bool | memOnly = false |
||
| ) |
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
Definition at line 10 of file scriptpubkeyman.cpp.
| bool ScriptPubKeyMan::TopUp | ( | unsigned int | size = 0 | ) |
Fills internal address pool.
Fill the key 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
Definition at line 368 of file scriptpubkeyman.cpp.
| void ScriptPubKeyMan::UpdateTimeFirstKey | ( | int64_t | nCreateTime | ) |
First wallet key time.
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 568 of file scriptpubkeyman.cpp.
| bool ScriptPubKeyMan::Upgrade | ( | const int | prev_version, |
| std::string & | error | ||
| ) |
Upgrades the wallet to the specified version.
Definition at line 23 of file scriptpubkeyman.cpp.
|
private |
Definition at line 133 of file scriptpubkeyman.h.
|
private |
Definition at line 130 of file scriptpubkeyman.h.
|
private |
Definition at line 142 of file scriptpubkeyman.h.
|
private |
Definition at line 139 of file scriptpubkeyman.h.
|
private |
Definition at line 140 of file scriptpubkeyman.h.
| std::set<int64_t> ScriptPubKeyMan::set_pre_split_keypool |
Definition at line 124 of file scriptpubkeyman.h.
|
private |
Definition at line 137 of file scriptpubkeyman.h.
|
private |
Definition at line 136 of file scriptpubkeyman.h.
|
private |
Definition at line 138 of file scriptpubkeyman.h.
|
private |
Definition at line 128 of file scriptpubkeyman.h.