aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/walletdb.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-06-14 11:11:19 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-06-14 11:44:22 +0200
commitb67a4726dfc3dd7384a151af3cf3b95ba612dd2d (patch)
tree38eafb435829fc2cb1f66b39deaf94d8eba9fb11 /src/wallet/walletdb.h
parentcca1c8cff0119b28beed98ab1a0e397d4a08d521 (diff)
parentafcd77e17936f7ec9bbf7b47f55a211eccc08364 (diff)
downloadbitcoin-b67a4726dfc3dd7384a151af3cf3b95ba612dd2d.tar.xz
Merge #8035: [Wallet] Add simplest BIP32/deterministic key generation implementation
afcd77e Detect -usehd mismatches when wallet.dat already exists (Jonas Schnelli) 17c0131 [Docs] Add release notes and bip update for Bip32/HD wallets (Jonas Schnelli) c022e5b [Wallet] use constant for bip32 hardened key limit (Jonas Schnelli) f190251 [Wallet] Add simplest BIP32/deterministic key generation implementation (Jonas Schnelli)
Diffstat (limited to 'src/wallet/walletdb.h')
-rw-r--r--src/wallet/walletdb.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h
index 00c10ea70f..71b0ff26db 100644
--- a/src/wallet/walletdb.h
+++ b/src/wallet/walletdb.h
@@ -40,6 +40,35 @@ enum DBErrors
DB_NEED_REWRITE
};
+/* simple hd chain data model */
+class CHDChain
+{
+public:
+ uint32_t nExternalChainCounter;
+ CKeyID masterKeyID; //!< master key hash160
+
+ static const int CURRENT_VERSION = 1;
+ int nVersion;
+
+ CHDChain() { SetNull(); }
+ ADD_SERIALIZE_METHODS;
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
+ {
+ READWRITE(this->nVersion);
+ nVersion = this->nVersion;
+ READWRITE(nExternalChainCounter);
+ READWRITE(masterKeyID);
+ }
+
+ void SetNull()
+ {
+ nVersion = CHDChain::CURRENT_VERSION;
+ nExternalChainCounter = 0;
+ masterKeyID.SetNull();
+ }
+};
+
class CKeyMetadata
{
public:
@@ -134,6 +163,9 @@ public:
static bool Recover(CDBEnv& dbenv, const std::string& filename, bool fOnlyKeys);
static bool Recover(CDBEnv& dbenv, const std::string& filename);
+ //! write the hdchain model (external chain child index counter)
+ bool WriteHDChain(const CHDChain& chain);
+
private:
CWalletDB(const CWalletDB&);
void operator=(const CWalletDB&);