I've read that calculating how much Bitcoin you have in your wallet is going through the ledger and computing who has given Bitcoins to you and who you have given Bitcoins to. Correct me if this statement is wrong. So when a miner mines a block and earns Bitcoins, who is giving them to him (i.e. what does the transaction look like on the ledger)? Is each Bitcoin some kind of unique identifier (like a number)? If that's true, what's to prevent someone else from stealing his Bitcoins by figuring out what this identifier is?

  • Look up "coinbase transaction". It's like any other transaction except that it has no inputs, so effectively it lets the miner spend coins that didn't previously exist. Nobody is giving them to him. – Nate Eldredge Jan 4 '18 at 22:42
  • If nobody is giving the miner coins (which makes sense) then where are they coming from? – Dave Jan 4 '18 at 22:56
  • They do not come from anywhere. A coin isn't a "thing"; this is just an analogy which breaks down when you look at how the implementation actually works. A block with a valid proof-of-work is allowed by the Bitcoin protocol to contain a transaction which pays the miner with coins that didn't come from any previous transaction. Since everyone follows the protocol and accepts this transaction as valid, it effectively gives the miner new coins. They didn't used to exist and now they do. – Nate Eldredge Jan 4 '18 at 23:15
  • Oh ok, I didn't realize the block itself contained a transaction. So does that mean when the miner mines the block there is somethign in there that identifies him so taht it is clear who owns the bitcoins given as the reward? – Dave Jan 4 '18 at 23:18
  • 1
    Yep, the coinbase transaction has one or more destination addresses just like any other transaction. (Or more precisely, it has outputs that follow the same rules as for normal transactions, so it can pay out coins in all the same ways that someone could pay out coins they already held.) A solo miner would set this to be an address that belongs to him; a pool might set it to a list of addresses corresponding to pool members who are owed payouts, each with an output value corresponding to what they are owed. – Nate Eldredge Jan 4 '18 at 23:21