Determine inactive HD seeds from key metadata and track them in LegacyScriptPubKeyMan

This commit is contained in:
Andrew Chow
2019-12-05 15:23:05 -05:00
parent b59b4504ab
commit 45f2f6a0e8
4 changed files with 116 additions and 4 deletions

View File

@@ -18,6 +18,8 @@
#include <boost/signals2/signal.hpp>
#include <unordered_map>
enum class OutputType;
// Wallet storage things that ScriptPubKeyMans need in order to be able to store things to the wallet database.
@@ -143,6 +145,17 @@ public:
}
};
class KeyIDHasher
{
public:
KeyIDHasher() {}
size_t operator()(const CKeyID& id) const
{
return id.GetUint64(0);
}
};
/*
* 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.
@@ -288,6 +301,7 @@ private:
/* the HD chain data model (external chain counters) */
CHDChain m_hd_chain;
std::unordered_map<CKeyID, CHDChain, KeyIDHasher> m_inactive_hd_chains;
/* HD derive new child key (on internal or external chain) */
void DeriveNewChildKey(WalletBatch& batch, CKeyMetadata& metadata, CKey& secret, CHDChain& hd_chain, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
@@ -397,6 +411,7 @@ public:
/* Set the HD chain model (chain child index counters) */
void SetHDChain(const CHDChain& chain, bool memonly);
const CHDChain& GetHDChain() const { return m_hd_chain; }
void AddInactiveHDChain(const CHDChain& chain);
//! Adds a watch-only address to the store, without saving it to disk (used by LoadWallet)
bool LoadWatchOnly(const CScript &dest);