Advertisement
Guest User

Untitled

a guest
Aug 26th, 2018
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.43 KB | None | 0 0
  1. diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
  2. index dc4fe93..7ebb083 100644
  3. --- a/src/wallet/wallet.cpp
  4. +++ b/src/wallet/wallet.cpp
  5. @@ -163,7 +163,7 @@ void CWallet::DeriveNewChildKey(CWalletDB &walletdb, CKeyMetadata& metadata, CKe
  6.      CKey key;                      //master key seed (256bit)
  7.      CExtKey masterKey;             //hd master key
  8.      CExtKey accountKey;            //key at m/0'
  9. -    CExtKey chainChildKey;         //key at m/0'/0' (external) or m/0'/1' (internal)
  10. +    CExtKey chainChildKey;         //key at m/0'/0'
  11.      CExtKey childKey;              //key at m/0'/0'/<n>'
  12.  
  13.      // try to get the master key
  14. @@ -176,25 +176,17 @@ void CWallet::DeriveNewChildKey(CWalletDB &walletdb, CKeyMetadata& metadata, CKe
  15.      // use hardened derivation (child keys >= 0x80000000 are hardened after bip32)
  16.      masterKey.Derive(accountKey, BIP32_HARDENED_KEY_LIMIT);
  17.  
  18. -    // derive m/0'/0' (external chain) OR m/0'/1' (internal chain)
  19. -    assert(internal ? CanSupportFeature(FEATURE_HD_SPLIT) : true);
  20. -    accountKey.Derive(chainChildKey, BIP32_HARDENED_KEY_LIMIT+(internal ? 1 : 0));
  21. +    // derive m/0'/0'
  22. +    accountKey.Derive(chainChildKey, BIP32_HARDENED_KEY_LIMIT);
  23.  
  24.      // derive child key at next index, skip keys already known to the wallet
  25.      do {
  26.          // always derive hardened keys
  27.          // childIndex | BIP32_HARDENED_KEY_LIMIT = derive childIndex in hardened child-index-range
  28.          // example: 1 | BIP32_HARDENED_KEY_LIMIT == 0x80000001 == 2147483649
  29. -        if (internal) {
  30. -            chainChildKey.Derive(childKey, hdChain.nInternalChainCounter | BIP32_HARDENED_KEY_LIMIT);
  31. -            metadata.hdKeypath = "m/0'/1'/" + std::to_string(hdChain.nInternalChainCounter) + "'";
  32. -            hdChain.nInternalChainCounter++;
  33. -        }
  34. -        else {
  35. -            chainChildKey.Derive(childKey, hdChain.nExternalChainCounter | BIP32_HARDENED_KEY_LIMIT);
  36. -            metadata.hdKeypath = "m/0'/0'/" + std::to_string(hdChain.nExternalChainCounter) + "'";
  37. -            hdChain.nExternalChainCounter++;
  38. -        }
  39. +        chainChildKey.Derive(childKey, hdChain.nExternalChainCounter | BIP32_HARDENED_KEY_LIMIT);
  40. +        metadata.hdKeypath = "m/0'/0'/" + std::to_string(hdChain.nExternalChainCounter) + "'";
  41. +        hdChain.nExternalChainCounter++;
  42.      } while (HaveKey(childKey.key.GetPubKey().GetID()));
  43.      secret = childKey.key;
  44.      metadata.hdMasterKeyID = hdChain.masterKeyID;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement