MCPcopy Create free account
hub / github.com/LUX-Core/lux / DeriveChildExtKey

Method DeriveChildExtKey

src/hdchain.cpp:154–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void CHDChain::DeriveChildExtKey(uint32_t nAccountIndex, bool internal, uint32_t nChildIndex, CExtKey& extKeyRet)
155{
156 // Use BIP44 keypath scheme i.e. m / purpose' / coin_type' / account' / change / address_index
157 CExtKey masterKey; //hd master key
158 CExtKey purposeKey; //key at m/purpose'
159 CExtKey cointypeKey; //key at m/purpose'/coin_type'
160 CExtKey accountKey; //key at m/purpose'/coin_type'/account'
161 CExtKey changeKey; //key at m/purpose'/coin_type'/account'/change
162 CExtKey childKey; //key at m/purpose'/coin_type'/account'/change/address_index
163
164 masterKey.SetMaster(&vchSeed[0], vchSeed.size());
165
166 // Use hardened derivation for purpose, coin_type and account
167 // (keys >= 0x80000000 are hardened after bip32)
168
169 // derive m/purpose'
170 masterKey.Derive(purposeKey, 44 | 0x80000000);
171 // derive m/purpose'/coin_type'
172 purposeKey.Derive(cointypeKey, Params().ExtCoinType() | 0x80000000);
173 // derive m/purpose'/coin_type'/account'
174 cointypeKey.Derive(accountKey, nAccountIndex | 0x80000000);
175 // derive m/purpose'/coin_type'/account/change
176 accountKey.Derive(changeKey, internal ? 1 : 0);
177 // derive m/purpose'/coin_type'/account/change/address_index
178 changeKey.Derive(extKeyRet, nChildIndex);
179}
180
181void CHDChain::AddAccount()
182{

Callers 2

DeriveNewChildKeyMethod · 0.80
GetKeyMethod · 0.80

Calls 5

SetMasterMethod · 0.80
ExtCoinTypeMethod · 0.80
ParamsClass · 0.70
sizeMethod · 0.45
DeriveMethod · 0.45

Tested by

no test coverage detected