Blockchain project
Features
- Proof of Work: reward a miner if the new block hash starts by a MINING_DIFFICULTY times 0, such as '000ewfbweg5w1g61we1'.
- Consensus algorithm: the longest chain rule.
- Addresses: version 1 Bitcoin addresses.
TODO
Firsts goes first...
First it must worksBlocks, transactions, hashing method, nodes, etcMining logic (PoW)Wallets, blockchain addresses, transaction verificationAPIsStructure blockchain network: nodes, wallets and consensus algo
- Then make it better
- Build a CLI
- Make structs private
- Checks "to review" comments
- Docker, k8s, etc
- CI/CD
- Implement ICO for wallet creation
- Implement fees.
- Improve logging and error handling
- Not decrease wallet amount when a transaction fails
- Improve APIs with handlers and routers
- Save blockchain state (despite cache)
- Then make it faster
- Synchronizing transactions with P2P
make server-build
make wallet-build
# 3 nodes
make server-run ARGS="-port=5000"
make server-run ARGS="-port=5001"
make server-run ARGS="-port=5002"
# 2 wallets
make wallet-run ARGS="-port 8080 -gateway=http://127.0.0.1:5001"
make wallet-run ARGS="-port 8081 -gateway=http://127.0.0.1:5002"
Technical background of version 1 Bitcoin addresses
- Creating ECDSA private key (32 bytes) and public key (64 bytes).
- Perform sha256 hashing on the public key -> 32 bytes
- Perform RIPEMD-160 hashing on the step2 result -> 20 bytes
- add version byte in front of RIPEMD-160 hash -> 0x00 for Main Network
- Perform sha256 hash on the extended RIPEMD-160 result
- Perform sha256 hash on the result of the previous step5 sha256 hash
- Take the first 4 bytes of the second step6 sha256 hash for checksum
- Add the 4 checksum bytes from step7 at the end of extended RIPEMD-160 hash from step4 -> 25 bytes
- Convert the result from a byte string into base58