Let’s deep dive into the most successful blockchain application — bitcoin, and start from blockchain.info (bc.i).
Ah, I am aware that there were people telling you not to use bc.i, because it is not safe. However bc.i is the longest standing wallet provider in the bitcoin industry, and people there are (finally) upgrading their wallet service for demanded security standards. Wouldn’t it be a good timing for us to learn? To look into the threats and risks a blockchain application is facing, and to fix it if you have the skills.
Get your blockchain.info account if you haven’t. You should see immediately some transactions running on chains.
Check “More…” to see new chain blocks, where transaction records were written on, been generated every few minutes. It means block miners found a block to store your transactions (explained in later chapter). Before a block is chained into the system, it could have accumulated many transaction records on it. Blockchain system introduces immutability, meaning you cannot change records written in the past, through chain of hashed blocks.
By hashing previous block into a value, and store the value in the starting address of next block, and so on, one can verify if a previous record has been altered (see the figure below). If some block in the past is altered, it’s hash value will not be correct comparing to the value stored in next block.
If one “insists” on altering a block, one must re-write all blocks after it in chain. However, doing this won’t make the altered chain recognized by others automatically. Blockchain applications (usually) leverage Byzantine algorithm (based on the famous Byzantine war problem) to reach consensus among several chains on nodes. In other words, every computing node acts like a general in Byzantine war, and they need to verify if every other general is trustworthy and passing the correct information to him. If a node found that one of the chains is different than the rest, it will reject it. Therefore the altered chain will be rejected by other nodes if they don’t agree with the change. Byzantine algorithm allows up to one third nodes failing without halting the system. It means that blockchain is stable and will not be crashed easily if some nodes failed or compromised.
Let’s stop talking around theories, and do a small exercise. Since bc.i now opens their source codes on github, it will be a good start for us to play around their codes.
Visit https://github.com/blockchain/My-Wallet-V3-Frontend and follow the instructions on their page to clone the project. You can also fork the project if you intend to change the codes like I did. I used Github Desktop to clone the forked project.
- install node.js
git clone email@example.com:blockchain/My-Wallet-V3-Frontend.git -b v1.7.32 --single-branch --depth 1
If you encounter permission-related errors on Mac during the
make server, try to modify the “make” file as shown in my branch, then
make server again. This time it will request you to enter current account password, and install some npm modules globally for you. If everything goes as planned, you should see message “Done, without errors,” and the server starts on your http://localhost:8080. Browsing to localhost:8080, you should see the exact web page you saw on blockchain.info, and you are ready to do transaction through your local server.
In the coming chapter, we will explore this app a little more. Not only to understand how it works, but also to create a digital wallet app that suits our own need, or taste. ;) Stay tuned.