Some technical questions about Bitcoin I'm a developer. I've read a lot about Bitcoin structure and how it works. But yet something confuse me.
I would like to share them with you and read your answers:

When a miner solves a block, how other nodes reward it? If they have the source code to generate Bitcoin, why don't they generate it for themeselves?

I know 6 confirmations are enough for a transaction to be valid. What If I run 6 full nodes by myself and hard code their addresses in a wallet to create a fake transaction?


3 . When 51 percent agreement is made? On every transaction? Or each block solved?

When a new transaction is made, do miners check all previous transactions in blockchain for maker person to check if it's lying or not?

If more than one miners create a new block and broadcast it into network, how other nodes would find out which one was the first?


I'm very curious about Bitcoin technology but I couldn't find a source that satisfies me.
The first transaction in the block is one created by the miner, it pays the miner the current block reward + sum of transaction fees for other transactions in the block (if any). If that block is accepted by other nodes, after 100 more blocks the miner can spend the money. Other nodes check that spending of this new money meets all the rules.

Each confirmation is a block added on top of the prior block. You can't fake that, you have to mine it. You have to provide the needed proof of work. Ordinary non-mining wallets can verify a transaction but can't confirm it.

Each node works separately to decide what is valid and what isn't. The 51% attack refers to percentage of hashing power not percentage of nodes. Consensus is more of an emergent phenomenon, it isn't like explicit vote counting.

They already checked them and don't need to check them again. Nodes typically each keep and maintain a list of unspent transaction outputs (UTXOs) - you can think of a UTXO as a valid coin.

They don't care. They keep track of both. They pick one arbitrarily as true.  They regularly compare amount of work in each branch. It's only later that a branch with more work may require a reorganisation (e.g. of UTXO set etc). This happens automatically and isn't a problem.


Before asking follow-up questions you will find it best to  read some existing answers such as

What exactly is Mining?
How many nodes need to validate a newly created block?
51%