File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,8 @@ CPubKey CWallet::GenerateNewKey()
126
126
// childIndex | BIP32_HARDENED_KEY_LIMIT = derive childIndex in hardened child-index-range
127
127
// example: 1 | BIP32_HARDENED_KEY_LIMIT == 0x80000001 == 2147483649
128
128
externalChainChildKey.Derive (childKey, hdChain.nExternalChainCounter | BIP32_HARDENED_KEY_LIMIT);
129
+ metadata.hdKeypath = " m/0'/0'/" +std::to_string (hdChain.nExternalChainCounter )+" '" ;
130
+ metadata.hdMasterKeyID = hdChain.masterKeyID ;
129
131
// increment childkey index
130
132
hdChain.nExternalChainCounter ++;
131
133
} while (HaveKey (childKey.key .GetPubKey ().GetID ()));
Original file line number Diff line number Diff line change @@ -73,9 +73,13 @@ class CHDChain
73
73
class CKeyMetadata
74
74
{
75
75
public:
76
- static const int CURRENT_VERSION=1 ;
76
+ static const int VERSION_BASIC=1 ;
77
+ static const int VERSION_WITH_HDDATA=10 ;
78
+ static const int CURRENT_VERSION=VERSION_WITH_HDDATA;
77
79
int nVersion;
78
80
int64_t nCreateTime; // 0 means unknown
81
+ std::string hdKeypath; // optional HD/bip32 keypath
82
+ CKeyID hdMasterKeyID; // id of the hd masterkey used to derive this key
79
83
80
84
CKeyMetadata ()
81
85
{
@@ -85,6 +89,7 @@ class CKeyMetadata
85
89
{
86
90
nVersion = CKeyMetadata::CURRENT_VERSION;
87
91
nCreateTime = nCreateTime_;
92
+ hdKeypath.clear ();
88
93
}
89
94
90
95
ADD_SERIALIZE_METHODS;
@@ -94,12 +99,18 @@ class CKeyMetadata
94
99
READWRITE (this ->nVersion );
95
100
nVersion = this ->nVersion ;
96
101
READWRITE (nCreateTime);
102
+ if (this ->nVersion >= VERSION_WITH_HDDATA)
103
+ {
104
+ READWRITE (hdKeypath);
105
+ READWRITE (hdMasterKeyID);
106
+ }
97
107
}
98
108
99
109
void SetNull ()
100
110
{
101
111
nVersion = CKeyMetadata::CURRENT_VERSION;
102
112
nCreateTime = 0 ;
113
+ hdKeypath.clear ();
103
114
}
104
115
};
105
116
You can’t perform that action at this time.
0 commit comments