user127058: Hi I'm student studying bitcoin-core.
I tested bitcoin regtest mode, and I want to know when CKey::MakeNewKey() is called.
when I do this,
bitcoin-cli -regtest createwallet "wallet1"
MakeNewKey() function was called, but
bitcoin-cli -regtest getnewaddress or bitcoin-cli -regtest -generate 1
didn't call MakeNewKey() and only call  GetPrivKey() and GetPubKey() in key.cpp
and when GetPrivKey() was called, the part of key32 in serialized key doesn't match of wallet's private key
My questions are,

Is only one private key of my wallet?
Blocks have their own private keys?
If #2 is right, what file make private key and public key of the block


user208: Since Bitcoin Core 0.13, the wallet uses deterministic key derivation.
That means that the wallet stores a single seed, and uses that to derive keys whenever needed. See BIP32 for details.
This has the advantage that a backup of the wallet lasts forever, at least as no other keys are imported. Since the same seed gives rise to the same keys, an older backup will produce the same keys as the real wallet generated after the backup was made, and thus the same payments will be discovered after restoring the backup.
MakeNewKey is for generating a new random key. For deriving keys from seeds, see the CExtKey functions in key.cpp.

127058: <p>Hi I'm student studying bitcoin-core.
I tested bitcoin regtest mode, and I want to know when CKey::MakeNewKey() is called.</p>
<p>when I do this,</p>
<p><strong>bitcoin-cli -regtest createwallet &quot;wallet1&quot;</strong></p>
<p>MakeNewKey() function was called, but</p>
<p><strong>bitcoin-cli -regtest getnewaddress</strong> or <strong>bitcoin-cli -regtest -generate 1</strong></p>
<p>didn't call MakeNewKey() and only call  GetPrivKey() and GetPubKey() in key.cpp</p>
<p>and when GetPrivKey() was called, the part of key32 in serialized key doesn't match of wallet's private key</p>
<p>My questions are,</p>
<ol>
<li>Is only one private key of my wallet?</li>
<li>Blocks have their own private keys?</li>
<li>If #2 is right, what file make private key and public key of the block</li>
</ol>
 208: <p>Since Bitcoin Core 0.13, the wallet uses deterministic key derivation.</p>
<p>That means that the wallet stores a single seed, and uses that to derive keys whenever needed. See BIP32 for details.</p>
<p>This has the advantage that a backup of the wallet lasts forever, at least as no other keys are imported. Since the same seed gives rise to the same keys, an older backup will produce the same keys as the real wallet generated after the backup was made, and thus the same payments will be discovered after restoring the backup.</p>
<p><code>MakeNewKey</code> is for generating a new <strong>random</strong> key. For deriving keys from seeds, see the <code>CExtKey</code> functions in key.cpp.</p>
