This is a simple blockchain storing transactions between different wallets.
Wallets are created with new public-private key pairs using PyCryptodome module.
Transactions contain digital signatures, so that tampered transactions can be detected. Transactions are signed using the private key and verified using the public key of a wallet.
New blocks are mined or added to the blockchain when a connected node solves a hard computational problem in a brute-force manner. I have used proof of work as a consensus algorithm. When a node solves this PoW problem, it receives an incentive reward of 200 units.
This computational problem is difficult to solve, but very easy to verify. Hence, it's really to verify authenticity of the chain at each time.
- Add transaction: Adds the transaction to open_transactions.
- Mining pending blocks: Mines transactions in open_transactions and solves PoW problem.
- Printing existing blocks in the blockchain.
- Getting balance of a particular wallet: Gets balance of a wallet from all legitimate transactions.
- Creating a new wallet with a new public-private key pair
- Loading existing public-private key pair from wallet.txt
- Saving public-private key pair to wallet.txt
- Download/clone this repo.
- Run
docker build .
- Note the image ID from the terminal after running the last command.
- Run
docker run -ti <Image ID>