Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | void CWallet::DeriveNewChildKey(CKeyMetadata &metadata, CKey &secret) { | ||||
accountKey.Derive(externalChainChildKey, BIP32_HARDENED_KEY_LIMIT); | accountKey.Derive(externalChainChildKey, BIP32_HARDENED_KEY_LIMIT); | ||||
// derive child key at next index, skip keys already known to the wallet | // derive child key at next index, skip keys already known to the wallet | ||||
do { | do { | ||||
// always derive hardened keys | // always derive hardened keys | ||||
// childIndex | BIP32_HARDENED_KEY_LIMIT = derive childIndex in hardened | // childIndex | BIP32_HARDENED_KEY_LIMIT = derive childIndex in hardened | ||||
// child-index-range | // child-index-range | ||||
// example: 1 | BIP32_HARDENED_KEY_LIMIT == 0x80000001 == 2147483649 | // example: 1 | BIP32_HARDENED_KEY_LIMIT == 0x80000001 == 2147483649 | ||||
externalChainChildKey.Derive(childKey, hdChain.nExternalChainCounter | | externalChainChildKey.Derive( | ||||
BIP32_HARDENED_KEY_LIMIT); | childKey, hdChain.nExternalChainCounter | BIP32_HARDENED_KEY_LIMIT); | ||||
metadata.hdKeypath = | metadata.hdKeypath = | ||||
"m/0'/0'/" + std::to_string(hdChain.nExternalChainCounter) + "'"; | "m/0'/0'/" + std::to_string(hdChain.nExternalChainCounter) + "'"; | ||||
metadata.hdMasterKeyID = hdChain.masterKeyID; | metadata.hdMasterKeyID = hdChain.masterKeyID; | ||||
// increment childkey index | // increment childkey index | ||||
hdChain.nExternalChainCounter++; | hdChain.nExternalChainCounter++; | ||||
} while (HaveKey(childKey.key.GetPubKey().GetID())); | } while (HaveKey(childKey.key.GetPubKey().GetID())); | ||||
secret = childKey.key; | secret = childKey.key; | ||||
▲ Show 20 Lines • Show All 4,310 Lines • Show Last 20 Lines |