The document provides an in-depth overview of how the Bitcoin blockchain works. It discusses key concepts like public and private keys, Bitcoin addresses, transactions, unspent transaction outputs (UTXOs), mining, blocks, and forks. Miners validate transactions by checking signatures and that inputs exceed outputs. Sometimes multiple blocks are found simultaneously, creating a fork that is resolved when the next block builds on the longest chain. The blockchain's past is immutable as each new block contains a hash of the previous block. Bitcoin provides pseudonymity rather than full anonymity. Alternative blockchain designs and applications are also discussed.
As you can see there is a scripting language integrated into Bitcoin. It’s a very simple non turing complete stack based language.
When Alice sent money to Bob she generated that exact LockScript in the transaction. Only Bob can provide the UnlockScript to actually spend the money he received. This is typical to most of bitcoin transactions and it’s called a P2PKH transaction (Pay2PublicKeyHash)
As you can see, with P2SH Alice doesn’t need to generate a very long LockingScript containing all the Pubkeys. She can create it with a simple hash. Only Bob when he wants to spend that money will have to generate a long UnlockingScript. Less bloat on the blockchain, less fees for Alice.
Bonus point, Bob can now generate a btc address containing that 20 bytes hash of the redeem script. These type of addresse start with 3. Alice can simply send money there.
Miners do that job for each transaction and put these transactions into blocks.
The blockchain is a chain of blocks, each block refers to the previous block by hash. Like each transaction refers to a previous transaction.
They add the (Sum of inputs - Sum of outputs) which represents the total fees in the coinbase transaction + the block reward
A faster blocktime would make transactions clear faster but lead to more frequent forks,
whereas a slower block time would decrease the number of forks but make settlement slower.