Bitcoin blockchain example
All confirmed transactions are included in the block chain. This way, Bitcoin wallets can calculate their spendable balance and new transactions can be verified to be spending bitcoins that are actually owned by the spender.
The integrity and the chronological order of the block chain are enforced with cryptography. A transaction is a transfer of value between Bitcoin wallets that gets included in the block chain.
Bitcoin wallets keep a secret piece of data called a private key or seed, which is used to sign transactions, providing a mathematical proof that they have come from the owner of the wallet. The signature also prevents the transaction from being altered by anybody once it has been issued. All transactions are broadcast between users and usually begin to be confirmed by the network in the following 10 minutes, through a process called mining.
Mining is a distributed consensus system that is used to confirm waiting transactions by including them in the block chain. It enforces a chronological order in the block chain, protects the neutrality of the network, and allows different computers to agree on the state of the system. To be confirmed, transactions must be packed in a block that fits very strict cryptographic rules that will be verified by the network.
These rules prevent previous blocks from being modified because doing so would invalidate all following blocks. Mining also creates the equivalent of a competitive lottery that prevents any individual from easily adding new blocks consecutively in the block chain. This way, no individuals can control what is included in the block chain or replace parts of the block chain to roll back their own spends. This is only a very short and concise summary of the system.
This transaction order status is pending, waiting for miners to work on them. Miners are just like gold miners, they are working hard to find the gold. They are creating money from thin air but not thick rocks. Miners are listening to the bitcoin blockchain and they are collecting those pending transactions. They can select any transactions from that pending transaction pool, but there is max 1 mb size limit. All of the miners may have different set of transactions. When nodes receive the block, they control all the staff in that block.
There are solution of the puzzle, transactions themselves, signatures, version numbers, etc. This is a trustless environment, no one trusts to each other. For that reason, everything like transactions, their signatures, puzzle itself, block size and many other controls are being done. These controls are being done by every node. This means, one block is being controlled by around nodes.
When a node approves the block, saves it. That event is continuously being done in every 10 minutes. When a block is saved in node, it attaches to the previous block which was saved 10 minutes ago. Saved blocks are creating a chain, blockchain. After a block is saved and added to the chain, you cannot change even one dot, one character inside it. Otherwise all block integrity changes. This is the all process for the above figure.
It is time to answer the questions! First questions for the client side. Bitcoin is a self-service system. You will create your address. Address will be your account number. When you click that button, you will have 2 long string. One will be your address account and the other will be your private key password.
No, but you need to enter the private key when you do a payment. Wallets make you define your own password, as facebook does. Instead of entering around 50 characters, you can use your own 8 chars. Private key is not changing, but wallet makes you feel as it does. There are different algorithms for securely storing your private key.
But usage is not simple yet. If you lose private key, you literally lose. There are many wallets on the internet, What if 2 different people have the same address? Always there is a probability. By the way, wallets are the weakest point in this system. For that reason, generally hacking events are being around the wallets.
By the way, there is no balance field in bitcoin, just there are transactions and transactions are held in nodes. Explained later Wallet makes you see your transactions, as if you see your balance.
It makes your life simpler with its user friendly interface. So I open my wallet, create a transaction order, and send it to nodes. Can they change my transaction order and distribute it to the network? But it is so early for segwit, now. During your payment, you sign your transactions. There is a sign function. Wallets do it automatically and send it to nodes. When nodes receive your order, they verify your sign. All nodes have a verification function.
Nodes put all these data into the verify function. If it is not verified, it means that someone has tried to change your message order. In bitcoin, everything is done with transactions. If you want to send money, you can only use your unspent transactions which you have received before. If I want to send Alice 5. I had to use 5 transactions to gather 6 BTC. When this transaction is done, it means that I cannot use these 5 transactions anymore. By the way, at the right side of the below image, there are 2 addresses.
Input and output totals are equal. If output total is less than 6 BTC, the difference would be a transaction fee for the miner. Be careful, blockchain is immutable, once it is gone, it is gone.
You cannot take your money back: This is a trustless environment, no one trust each other, only trust themselves. For that reason, all nodes do controls by themselves. When I use unspent transactions in my previous payment, nodes control them if they are really unspent. They also control, where that transaction is coming from. Even pre-previous transaction is being controlled, if it is valid or not.
This control continues to the origin of that transaction, till to the genesis transaction! This can be called transaction chain. So it is impossible to insert a made up transaction in the middle. Even if you update all the history records in all nodes with a virus, it will not be enough.
If you change one point in a block, its integrity totally changes. Just remember from Indiana jones, he takes one piece in a temple and in a few seconds temple collapse. Our temple is our block, if you take or change one piece, it collapses.
This traceability feature is important, for the coming essays we will use this for different use cases. We need a system that every node will agree on the order of transactions take place.
Transactions in the same block are theoretically considered to be occurred at the same time. Every miner on the network can create a block from pending transactions unapproved transactions. A cryptographic hash is like a signature for a text or a data file. SHA algorithm generates an almost-unique, fixed size bit byte hash. Hash is a one way function — it cannot be decrypted back.
The output of hash is totally random number. Until to reach below that number, you continuously change the nonce number; perhaps million or billion times. Well this is random number, perhaps you are very lucky, and when you enter the nonce number, will find it at your first trial. But generally, people are not that much lucky.
Puzzle is difficult and costly to solve. To solve the puzzle, miners are working really hard. For that reason, it is called proof of work. If there is such a case, it is called fork. In the blockchain technology; when there is a new release, the probability of the fork is higher. At some blockchain framework; upgrade is not allowed, because it is a pain point now.
It is evolving very fast. In bitcoin history, the longest fork had 53 blocks in August , due to the Value Overflow bug. In March 12, blockchain fork started with release of v0.
If there is a tie, someone has to solve a new block to break the tie. The general rule is always 'follow the longest chain'.