This is to track the regression introduced in master, which needs fixing for 0.14. See #9240, #9371, etc.
{
    AssertLockHeld(cs_wallet); 
    bool fCompressed = CanSupportFeature(FEATURE_COMPRPUBKEY); 
    CKey secret;
    
    int64_t nCreationTime = GetTime();
    CKeyMetadata metadata(nCreationTime);
    
    if (IsHDEnabled()) {
        DeriveNewChildKey(metadata, secret);
    } else {
        secret.MakeNewKey(fCompressed);
    }
    
    if (fCompressed)
        SetMinVersion(FEATURE_COMPRPUBKEY);
    CPubKey pubkey = secret.GetPubKey();
    assert(secret.VerifyPubKey(pubkey));
    mapKeyMetadata[pubkey.GetID()] = metadata;
    if (!nTimeFirstKey || nCreationTime < nTimeFirstKey)
        nTimeFirstKey = nCreationTime;
    if (!AddKeyPubKey(secret, pubkey))
        throw std::runtime_error(std::string(__func__) + ": AddKey failed");
    return pubkey;
}
void CWallet::DeriveNewChildKey(CKeyMetadata& metadata, CKey& secret)