/PyCoin

Simple Bitcoin written in Python

Primary LanguagePython

PyCoin

Mini Project for EE4017 Internet Finance

To develop a “Bitcoin” application using Python.

  1. Each group consists of 5 students
  2. Each group to demo in week 12
  3. Each group submits a report in week 12
  4. Requirements: Compulsory features (passing marks) and optional features (additional marks)
  5. Marks based on:
    1. Features implemented
    2. Code complexity; and
    3. The quality of the written report

Compulsory Features

  • Able to generate a new wallet
  • Able to perform transactions
  • Able to generate coins reward
  • Able to generate new blocks using proof-of work consensus protocol
  • Able to broadcast new blocks to the rests of connected peers
  • Able to connect peers and sync the whole blockchain

Optional Features

  • Able to reject malformed blocks
  • Able to check the balance before confirming a transaction
  • Able to give interest to coins holder
  • Able to charge transaction fee from the sender of the transaction
  • Able to demonstrate partial validation using merkle tree
  • Developed a lightweight node that store block header (First criteria must be fulfilled)
  • Able to change difficulty when the hash power of the network change
  • Develop an App on any mobile platform to perform mobile payment using the cryptocurrency network

Requirements

  • Python 3
  • Requests
  • PyCrypto
  • PyPrnt
  • Flask
  • Coverage
# If you have both Python 2 and 3,
pip3 install -r requirements.txt
# If you only have Python 3,
pip install -r requirements.txt

Start

# Node with 127.0.0.1:5000
python3 Server.py 5000
# Node with 127.0.0.1:5001
python3 Server.py 5001
# Node with 127.0.0.1:5002
python3 Server.py 5002

Test

Before initiating test, make sure all 3 nodes are running with ports 5000, 5001, and 5002.
The integration test fails for very first time for unknown reason.
Please run the test twice.

python3 -m unittest

Test with Coverage

bash test.sh