Understand how wallet works My goal is to understand the bitcoin internals.

Here is what i have done:

I have downloaded, maked and installed bitcoin sourcecode from github.

I have launched the bitcoind daemon. Everything seems to work because i can generate addresses with bitcoin-cli.

My first question is: When and How my private/public key was generated ?
I had nothing to do for that and i am wondering when this operation was done.

My second question is: I know this is not a good practice but if i only know my private/public key in clear format (not encrypted): Is there a way for me to "import" this public/private key into my bitcoin wallet.
In other words, can i say if i know my public/private key, i know everything.

Thanks
Welcome to the Bitcoin world.


  My first question is: When and How my private/public key was generated?


Your public key is calculated by your private key.

Where your private key is a randomly chosen number, so let's suppose that now we choose k value as your private key, from this we can apply a unidirectional cryptographic function, ie from the private key I can ALWAYS get my public key but it is impossible to contrary (unless expensive brute force attacks, where the game is not worth the candle)
This hash function is an elliptic curve function, I leave you the reference to a bitcoin book.

So I have my private key K where I apply my asymmetric encryption algorithm and get the public key.

P = hash_fun (K);



  My second question is: I know this is not a good practice but if i only know my private/public key in clear format (not encrypted): Is there a way for me to "import" this public/private key into my bitcoin wallet. In other words, can i say if i know my public/private key, i know everything.


Yes, the wallet is formed by the pair (private key, public key) many wallets keep the whole pair but it is possible to get the public key whenever you want, if you know the private key, but not vice versa.

So your private K key is your wallet, or rather what makes your wallet alive