From eab63bc264a35cf21738e8535773e3d36524c3fe Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 6 Nov 2018 09:23:37 -0500 Subject: [PATCH] Store key origin info in key metadata Store the master key fingerprint and derivation path in the key metadata. hdKeypath is kept to indicate the seed and for backwards compatibility, but all key derivation path output uses the key origin info instead of hdKeypath. --- src/script/sign.h | 16 +++++++++- src/wallet/rpcdump.cpp | 3 +- src/wallet/rpcwallet.cpp | 6 ++-- src/wallet/wallet.cpp | 63 +++++++++++++++++++++++++++++++++------- src/wallet/wallet.h | 7 ++++- src/wallet/walletdb.cpp | 8 +++++ src/wallet/walletdb.h | 15 ++++++++-- 7 files changed, 100 insertions(+), 18 deletions(-) diff --git a/src/script/sign.h b/src/script/sign.h index 64eb3eb8e53..3e9a3b38c66 100644 --- a/src/script/sign.h +++ b/src/script/sign.h @@ -22,13 +22,27 @@ struct CMutableTransaction; struct KeyOriginInfo { - unsigned char fingerprint[4]; + unsigned char fingerprint[4]; //!< First 32 bits of the Hash160 of the public key at the root of the path std::vector path; friend bool operator==(const KeyOriginInfo& a, const KeyOriginInfo& b) { return std::equal(std::begin(a.fingerprint), std::end(a.fingerprint), std::begin(b.fingerprint)) && a.path == b.path; } + + ADD_SERIALIZE_METHODS; + template + inline void SerializationOp(Stream& s, Operation ser_action) + { + READWRITE(fingerprint); + READWRITE(path); + } + + void clear() + { + memset(fingerprint, 0, 4); + path.clear(); + } }; /** An interface to be implemented by keystores that support signing. */ diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index ec49efcf224..8ed912ed1ed 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -13,6 +13,7 @@ #include