Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
- index dc4fe93..7ebb083 100644
- --- a/src/wallet/wallet.cpp
- +++ b/src/wallet/wallet.cpp
- @@ -163,7 +163,7 @@ void CWallet::DeriveNewChildKey(CWalletDB &walletdb, CKeyMetadata& metadata, CKe
- CKey key; //master key seed (256bit)
- CExtKey masterKey; //hd master key
- CExtKey accountKey; //key at m/0'
- - CExtKey chainChildKey; //key at m/0'/0' (external) or m/0'/1' (internal)
- + CExtKey chainChildKey; //key at m/0'/0'
- CExtKey childKey; //key at m/0'/0'/<n>'
- // try to get the master key
- @@ -176,25 +176,17 @@ void CWallet::DeriveNewChildKey(CWalletDB &walletdb, CKeyMetadata& metadata, CKe
- // use hardened derivation (child keys >= 0x80000000 are hardened after bip32)
- masterKey.Derive(accountKey, BIP32_HARDENED_KEY_LIMIT);
- - // derive m/0'/0' (external chain) OR m/0'/1' (internal chain)
- - assert(internal ? CanSupportFeature(FEATURE_HD_SPLIT) : true);
- - accountKey.Derive(chainChildKey, BIP32_HARDENED_KEY_LIMIT+(internal ? 1 : 0));
- + // derive m/0'/0'
- + accountKey.Derive(chainChildKey, BIP32_HARDENED_KEY_LIMIT);
- // derive child key at next index, skip keys already known to the wallet
- do {
- // always derive hardened keys
- // childIndex | BIP32_HARDENED_KEY_LIMIT = derive childIndex in hardened child-index-range
- // example: 1 | BIP32_HARDENED_KEY_LIMIT == 0x80000001 == 2147483649
- - if (internal) {
- - chainChildKey.Derive(childKey, hdChain.nInternalChainCounter | BIP32_HARDENED_KEY_LIMIT);
- - metadata.hdKeypath = "m/0'/1'/" + std::to_string(hdChain.nInternalChainCounter) + "'";
- - hdChain.nInternalChainCounter++;
- - }
- - else {
- - chainChildKey.Derive(childKey, hdChain.nExternalChainCounter | BIP32_HARDENED_KEY_LIMIT);
- - metadata.hdKeypath = "m/0'/0'/" + std::to_string(hdChain.nExternalChainCounter) + "'";
- - hdChain.nExternalChainCounter++;
- - }
- + chainChildKey.Derive(childKey, hdChain.nExternalChainCounter | BIP32_HARDENED_KEY_LIMIT);
- + metadata.hdKeypath = "m/0'/0'/" + std::to_string(hdChain.nExternalChainCounter) + "'";
- + hdChain.nExternalChainCounter++;
- } while (HaveKey(childKey.key.GetPubKey().GetID()));
- secret = childKey.key;
- metadata.hdMasterKeyID = hdChain.masterKeyID;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement