| 152 | } |
| 153 | |
| 154 | void 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 | |
| 181 | void CHDChain::AddAccount() |
| 182 | { |
no test coverage detected